~mparic/+junk/openauctionlive

« back to all changes in this revision

Viewing changes to app/controllers/events_controller.php

  • Committer: Michael Paric
  • Date: 2012-01-07 20:21:14 UTC
  • Revision ID: mparic@compbizsolutions.com-20120107202114-6q89jiel6y3rbwgc
Updated validation rules to prevent duplicate Bid and Bidder entries; updated return message color for successful form entry to differentiate from error; added simlink in img/ for image to be used in reports - just change what auction_logo.jpg points to instead of changing View code.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
 
4
4
        var $name = 'Events';
5
5
 
6
 
  function beforeRender(){
7
 
    
8
 
    $this->set('navigation','main_nav_' . $this->Auth->user('role'));
9
 
    
10
 
    $this->set('subNavigation','events_' . $this->Auth->user('role'));
11
 
    
12
 
  }
 
6
  function beforeRender(){    
 
7
        $this->set('navigation','main_nav_' . $this->Auth->user('role'));    
 
8
        $this->set('subNavigation','events_' . $this->Auth->user('role'));    
 
9
        }
13
10
    
14
11
        function index() {
15
 
          $this->isAuthorized();
 
12
                $this->isAuthorized();
16
13
                $this->Event->recursive = 0;
17
 
          $this->set('events', $this->paginate());
 
14
                $this->set('events', $this->paginate());
18
15
        }
19
16
 
20
17
        function view($id=null) {
21
 
          $id = ($id) ? $id : $this->Session->read('event_id');
 
18
                $id = ($id) ? $id : $this->Session->read('event_id');
22
19
                $this->set('event', $this->Event->read(null, $id));
23
20
        }
24
21
 
29
26
                        $this->Event->create();
30
27
                        if ($this->Event->save($this->data)) {
31
28
                          $this->Session->write('event_id',$this->Event->id);
32
 
                                $this->Session->setFlash(__('The event has been saved', true));
 
29
                                $this->Session->setFlash(__('The event has been saved', true),'default', array('class'=>'success-message'));
33
30
                                $this->redirect(array('action' => 'index'));
34
31
                        } else {
35
32
                                $this->Session->setFlash(__('The event could not be saved. Please, try again.', true));
40
37
        }
41
38
 
42
39
        function edit($id = null) {
43
 
          $this->isAuthorized();
 
40
                $this->isAuthorized();
44
41
                if (!$id && empty($this->data)) {
45
42
                        $this->Session->setFlash(__('Invalid event', true));
46
43
                        $this->redirect(array('action' => 'index'));
47
44
                }
48
45
                if (!empty($this->data)) {
49
46
                        if ($this->Event->save($this->data)) {
50
 
                                $this->Session->setFlash(__('The event has been saved', true));
 
47
                                $this->Session->setFlash(__('The event has been saved', true),'default', array('class'=>'success-message'));
51
48
                                $this->redirect(array('action' => 'index'));
52
49
                        } else {
53
50
                                $this->Session->setFlash(__('The event could not be saved. Please, try again.', true));
61
58
        }
62
59
 
63
60
        function delete($id = null) {
64
 
          $this->isAuthorized();
 
61
                $this->isAuthorized();
65
62
                if (!$id) {
66
63
                        $this->Session->setFlash(__('Invalid id for event', true));
67
64
                        $this->redirect(array('action'=>'index'));
68
65
                }
69
66
                if ($this->Event->delete($id)) {
70
 
                        $this->Session->setFlash(__('Event deleted', true));
 
67
                        $this->Session->setFlash(__('Event deleted', true),'default', array('class'=>'success-message'));
71
68
                        $this->redirect(array('action'=>'index'));
72
69
                }
73
70
                $this->Session->setFlash(__('Event was not deleted', true));