Subversion Repositories SmartDukaan

Rev

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

<?php
App::uses('AppController', 'Controller');
/**
 * Acls Controller
 *
 * @property Acl $Acl
 * @property PaginatorComponent $Paginator
 */
class AclsController extends AppController {

/**
 * Components
 *
 * @var array
 */
        public $components = array('Paginator');

        public function beforeFilter() {                
                parent::beforeFilter();
        }
/**
 * admin_index method
 *
 * @return void
 */
        public function admin_index() {
                // $this->checkAcl();
                $this->Acl->recursive = 0;
                $this->set('permissions', $this->Paginator->paginate());
        }

        public function admin_group($id) {
                // $this->checkAcl();
                $this->Acl->recursive = 0;
                $options = array('conditions'=>array('group_id'=>$id));
                $this->Paginator->settings = $options;
                $this->set('permissions', $this->Paginator->paginate());
                $this->render('admin_index');
        }

/**
 * admin_view method
 *
 * @throws NotFoundException
 * @param string $id
 * @return void
 */
        public function admin_view($id = null) {
                if (!$this->Acl->exists($id)) {
                        throw new NotFoundException(__('Invalid acl'));
                }
                $options = array('conditions' => array('Acl.' . $this->Acl->primaryKey => $id));
                $this->set('acl', $this->Acl->find('first', $options));
        }

/**
 * admin_add method
 *
 * @return void
 */
        public function admin_add() {
                // $this->checkAcl();
                if ($this->request->is('post')) {
                        $this->Acl->create();
                        if ($this->Acl->save($this->request->data)) {
                                $this->Session->setFlash(__('The acl has been saved.'));
                                Cache::delete('acls','month');
                                return $this->redirect(array('action' => 'index'));
                        } else {
                                $this->Session->setFlash(__('The acl could not be saved. Please, try again.'));
                        }
                }               
                $groups = $this->Acl->Group->find('list');
                $this->set(compact('groups'));
        }

/**
 * admin_edit method
 *
 * @throws NotFoundException
 * @param string $id
 * @return void
 */
        public function admin_edit($id = null) {
                if (!$this->Acl->exists($id)) {
                        throw new NotFoundException(__('Invalid acl'));
                }
                if ($this->request->is(array('post', 'put'))) {
                        if ($this->Acl->save($this->request->data)) {
                                $this->Session->setFlash(__('The acl has been saved.'));
                                Cache::delete('acls','month');
                                return $this->redirect(array('action' => 'index'));
                        } else {
                                $this->Session->setFlash(__('The acl could not be saved. Please, try again.'));
                        }
                } else {
                        $options = array('conditions' => array('Acl.' . $this->Acl->primaryKey => $id));
                        $this->request->data = $this->Acl->find('first', $options);
                }               
                $groups = $this->Acl->Group->find('list');
                $this->set(compact('groups'));
        }

/**
 * admin_delete method
 *
 * @throws NotFoundException
 * @param string $id
 * @return void
 */
        public function admin_delete($id = null) {
                $this->Acl->id = $id;
                if (!$this->Acl->exists()) {
                        throw new NotFoundException(__('Invalid acl'));
                }
                $this->request->onlyAllow('post', 'delete');
                if ($this->Acl->delete()) {
                        $this->Session->setFlash(__('The acl has been deleted.'));
                } else {
                        $this->Session->setFlash(__('The acl could not be deleted. Please, try again.'));
                }
                return $this->redirect(array('action' => 'index'));
        }}