Subversion Repositories SmartDukaan

Rev

Rev 15222 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 15222 Rev 15227
Line 13... Line 13...
13
 *
13
 *
14
 * @var array
14
 * @var array
15
 */
15
 */
16
	public $components = array('Paginator');
16
	public $components = array('Paginator');
17
 
17
 
18
/**
-
 
19
 * index method
-
 
20
 *
-
 
21
 * @return void
-
 
22
 */
-
 
23
	public function index() {
18
	public function beforeFilter() {		
24
		$this->Acl->recursive = 0;
19
		parent::beforeFilter();
25
		$this->set('acls', $this->Paginator->paginate());
-
 
26
	}	
-
 
27
 
-
 
28
/**
-
 
29
 * view method
-
 
30
 *
-
 
31
 * @throws NotFoundException
-
 
32
 * @param string $id
-
 
33
 * @return void
-
 
34
 */
-
 
35
	public function view($id = null) {
-
 
36
		if (!$this->Acl->exists($id)) {
-
 
37
			throw new NotFoundException(__('Invalid acl'));
-
 
38
		}
-
 
39
		$options = array('conditions' => array('Acl.' . $this->Acl->primaryKey => $id));
-
 
40
		$this->set('acl', $this->Acl->find('first', $options));
-
 
41
	}
20
	}
42
 
-
 
43
/**
-
 
44
 * add method
-
 
45
 *
-
 
46
 * @return void
-
 
47
 */
-
 
48
	public function add() {
-
 
49
		if ($this->request->is('post')) {
-
 
50
			$this->Acl->create();
-
 
51
			if ($this->Acl->save($this->request->data)) {
-
 
52
				$this->Session->setFlash(__('The acl has been saved.'));
-
 
53
				return $this->redirect(array('action' => 'index'));
-
 
54
			} else {
-
 
55
				$this->Session->setFlash(__('The acl could not be saved. Please, try again.'));
-
 
56
			}
-
 
57
		}
-
 
58
		Cache::delete('acls');
-
 
59
		$groups = $this->Acl->Group->find('list');
-
 
60
		$this->set(compact('groups'));
-
 
61
	}
-
 
62
 
-
 
63
/**
-
 
64
 * edit method
-
 
65
 *
-
 
66
 * @throws NotFoundException
-
 
67
 * @param string $id
-
 
68
 * @return void
-
 
69
 */
-
 
70
	public function edit($id = null) {
-
 
71
		if (!$this->Acl->exists($id)) {
-
 
72
			throw new NotFoundException(__('Invalid acl'));
-
 
73
		}
-
 
74
		if ($this->request->is(array('post', 'put'))) {
-
 
75
			if ($this->Acl->save($this->request->data)) {
-
 
76
				$this->Session->setFlash(__('The acl has been saved.'));
-
 
77
				return $this->redirect(array('action' => 'index'));
-
 
78
			} else {
-
 
79
				$this->Session->setFlash(__('The acl could not be saved. Please, try again.'));
-
 
80
			}
-
 
81
		} else {
-
 
82
			$options = array('conditions' => array('Acl.' . $this->Acl->primaryKey => $id));
-
 
83
			$this->request->data = $this->Acl->find('first', $options);
-
 
84
		}
-
 
85
		$groups = $this->Acl->Group->find('list');
-
 
86
		$this->set(compact('groups'));
-
 
87
	}
-
 
88
 
-
 
89
/**
-
 
90
 * delete method
-
 
91
 *
-
 
92
 * @throws NotFoundException
-
 
93
 * @param string $id
-
 
94
 * @return void
-
 
95
 */
-
 
96
	public function delete($id = null) {
-
 
97
		$this->Acl->id = $id;
-
 
98
		if (!$this->Acl->exists()) {
-
 
99
			throw new NotFoundException(__('Invalid acl'));
-
 
100
		}
-
 
101
		$this->request->onlyAllow('post', 'delete');
-
 
102
		if ($this->Acl->delete()) {
-
 
103
			$this->Session->setFlash(__('The acl has been deleted.'));
-
 
104
		} else {
-
 
105
			$this->Session->setFlash(__('The acl could not be deleted. Please, try again.'));
-
 
106
		}
-
 
107
		return $this->redirect(array('action' => 'index'));
-
 
108
	}
-
 
109
 
-
 
110
/**
21
/**
111
 * admin_index method
22
 * admin_index method
112
 *
23
 *
113
 * @return void
24
 * @return void
114
 */
25
 */
115
	public function admin_index() {
26
	public function admin_index() {
-
 
27
		$this->checkAcl();
116
		$this->Acl->recursive = 0;
28
		$this->Acl->recursive = 0;
117
		$this->set('permissions', $this->Paginator->paginate());
29
		$this->set('permissions', $this->Paginator->paginate());
118
	}
30
	}
119
 
31
 
120
	public function admin_group($id) {
32
	public function admin_group($id) {
-
 
33
		$this->checkAcl();
121
		$this->Acl->recursive = 0;
34
		$this->Acl->recursive = 0;
122
		$options = array('conditions'=>array('group_id'=>$id));
35
		$options = array('conditions'=>array('group_id'=>$id));
123
		$this->Paginator->settings = $options;
36
		$this->Paginator->settings = $options;
124
		$this->set('permissions', $this->Paginator->paginate());
37
		$this->set('permissions', $this->Paginator->paginate());
125
		$this->render('admin_index');
38
		$this->render('admin_index');
126
	}
39
	}
127
	
40
 
128
/**
41
/**
129
 * admin_view method
42
 * admin_view method
130
 *
43
 *
131
 * @throws NotFoundException
44
 * @throws NotFoundException
132
 * @param string $id
45
 * @param string $id
Line 144... Line 57...
144
 * admin_add method
57
 * admin_add method
145
 *
58
 *
146
 * @return void
59
 * @return void
147
 */
60
 */
148
	public function admin_add() {
61
	public function admin_add() {
-
 
62
		$this->checkAcl();
149
		if ($this->request->is('post')) {
63
		if ($this->request->is('post')) {
150
			$this->Acl->create();
64
			$this->Acl->create();
151
			if ($this->Acl->save($this->request->data)) {
65
			if ($this->Acl->save($this->request->data)) {
152
				$this->Session->setFlash(__('The acl has been saved.'));
66
				$this->Session->setFlash(__('The acl has been saved.'));
153
				Cache::delete('acls','month');
67
				Cache::delete('acls','month');