Subversion Repositories SmartDukaan

Rev

Rev 15227 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
15194 anikendra 1
<?php
2
App::uses('AppController', 'Controller');
3
/**
4
 * Acls Controller
5
 *
6
 * @property Acl $Acl
7
 * @property PaginatorComponent $Paginator
8
 */
9
class AclsController extends AppController {
10
 
11
/**
12
 * Components
13
 *
14
 * @var array
15
 */
16
	public $components = array('Paginator');
17
 
15227 anikendra 18
	public function beforeFilter() {		
19
		parent::beforeFilter();
15194 anikendra 20
	}
21
/**
22
 * admin_index method
23
 *
24
 * @return void
25
 */
26
	public function admin_index() {
15311 anikendra 27
		// $this->checkAcl();
15194 anikendra 28
		$this->Acl->recursive = 0;
29
		$this->set('permissions', $this->Paginator->paginate());
30
	}
31
 
15222 anikendra 32
	public function admin_group($id) {
15311 anikendra 33
		// $this->checkAcl();
15222 anikendra 34
		$this->Acl->recursive = 0;
35
		$options = array('conditions'=>array('group_id'=>$id));
36
		$this->Paginator->settings = $options;
37
		$this->set('permissions', $this->Paginator->paginate());
38
		$this->render('admin_index');
39
	}
15227 anikendra 40
 
15194 anikendra 41
/**
42
 * admin_view method
43
 *
44
 * @throws NotFoundException
45
 * @param string $id
46
 * @return void
47
 */
48
	public function admin_view($id = null) {
49
		if (!$this->Acl->exists($id)) {
50
			throw new NotFoundException(__('Invalid acl'));
51
		}
52
		$options = array('conditions' => array('Acl.' . $this->Acl->primaryKey => $id));
53
		$this->set('acl', $this->Acl->find('first', $options));
54
	}
55
 
56
/**
57
 * admin_add method
58
 *
59
 * @return void
60
 */
61
	public function admin_add() {
15311 anikendra 62
		// $this->checkAcl();
15194 anikendra 63
		if ($this->request->is('post')) {
64
			$this->Acl->create();
65
			if ($this->Acl->save($this->request->data)) {
66
				$this->Session->setFlash(__('The acl has been saved.'));
67
				Cache::delete('acls','month');
68
				return $this->redirect(array('action' => 'index'));
69
			} else {
70
				$this->Session->setFlash(__('The acl could not be saved. Please, try again.'));
71
			}
72
		}		
73
		$groups = $this->Acl->Group->find('list');
74
		$this->set(compact('groups'));
75
	}
76
 
77
/**
78
 * admin_edit method
79
 *
80
 * @throws NotFoundException
81
 * @param string $id
82
 * @return void
83
 */
84
	public function admin_edit($id = null) {
85
		if (!$this->Acl->exists($id)) {
86
			throw new NotFoundException(__('Invalid acl'));
87
		}
88
		if ($this->request->is(array('post', 'put'))) {
89
			if ($this->Acl->save($this->request->data)) {
90
				$this->Session->setFlash(__('The acl has been saved.'));
91
				Cache::delete('acls','month');
92
				return $this->redirect(array('action' => 'index'));
93
			} else {
94
				$this->Session->setFlash(__('The acl could not be saved. Please, try again.'));
95
			}
96
		} else {
97
			$options = array('conditions' => array('Acl.' . $this->Acl->primaryKey => $id));
98
			$this->request->data = $this->Acl->find('first', $options);
99
		}		
100
		$groups = $this->Acl->Group->find('list');
101
		$this->set(compact('groups'));
102
	}
103
 
104
/**
105
 * admin_delete method
106
 *
107
 * @throws NotFoundException
108
 * @param string $id
109
 * @return void
110
 */
111
	public function admin_delete($id = null) {
112
		$this->Acl->id = $id;
113
		if (!$this->Acl->exists()) {
114
			throw new NotFoundException(__('Invalid acl'));
115
		}
116
		$this->request->onlyAllow('post', 'delete');
117
		if ($this->Acl->delete()) {
118
			$this->Session->setFlash(__('The acl has been deleted.'));
119
		} else {
120
			$this->Session->setFlash(__('The acl could not be deleted. Please, try again.'));
121
		}
122
		return $this->redirect(array('action' => 'index'));
123
	}}