Example #1
0
 /**
  * undocumented function
  *
  * @return void
  * @access public
  */
 function admin_go()
 {
     Assert::false($this->isGet(), '404');
     $validTypes = array('gifts', 'transactions', 'users', 'appeals');
     $type = $this->data['Search']['resource'];
     Assert::true(in_array($type, $validTypes), '404');
     $url = array('controller' => $type, 'action' => 'index', 'all', '?' => 'keyword=' . $this->data['Search']['keyword']);
     $this->redirect($url);
 }
Example #2
0
 /**
  * undocumented function
  *
  * @return void
  * @access public
  */
 function admin_delete($id)
 {
     $role = $this->Role->findById($id);
     Assert::notEmpty($role, '404');
     Assert::false(in_array($role['Role']['name'], $this->Role->unEditable), '403');
     $this->Role->del($id);
     $msg = __('Role was successfully removed.', true);
     $this->Message->add($msg, 'ok', true, array('action' => 'admin_index'));
 }
Example #3
0
 /**
  * undocumented function
  *
  * @return void
  * @access public
  */
 function beforeFilter()
 {
     if (!defined('CAKEPHP_UNIT_TEST_EXECUTION')) {
         Assert::false($this->name == 'App', '404');
         Assert::true(!!$this->action, '404');
     }
     $this->Session = $this->AppSession;
     ClassRegistry::addObject('Component.Session', $this->Session);
     ClassRegistry::addObject('Component.RequestHandler', $this->RequestHandler);
     ClassRegistry::addObject('Component.Cookie', $this->Cookie);
     ClassRegistry::addObject('Component.Email', $this->Email);
     ClassRegistry::addObject('Component.Pgp', $this->Pgp);
     $this->_loadPermissions();
     $this->_setLanguage();
     $this->_loadPluginConfigs();
     if ($this->isAdmin()) {
         $this->layout = 'admin';
     }
     if (defined('CAKEPHP_UNIT_TEST_EXECUTION')) {
         return;
     }
     $this->RequestHandler->setContent('list', 'text/html');
     if (empty($this->ignoreUserSession)) {
         $rules = Configure::read('App.userPermissions.' . User::get('Role.name'));
         Assert::notEmpty($rules, '500');
         $canAccess = Common::requestAllowed($this->name, $this->action, $rules, true);
         if (!$canAccess) {
             Assert::true(User::is('guest'), '403');
             if ($this->isOkForSessionRedirect()) {
                 $this->Session->write($this->loginRedirectSesskey, $this->here);
             }
             $this->Session->write('cant_access', true);
             return $this->redirect('/admin/auth/login', '403', true);
         }
         if (!User::is('guest') && $this->name == 'auth' && $this->action == 'login') {
             $url = '/admin/home';
             if ($this->Session->check($this->loginRedirectSesskey)) {
                 $url = $this->Session->read($this->loginRedirectSesskey);
             }
             $this->redirect($url);
         }
     }
     $here = $this->params['url']['url'];
     if (!empty($here) && $here[0] != '/') {
         $here = '/' . $here;
     }
     $this->setJson('here', $here);
     $ajax = $isAjax = false;
     if ($this->isAjax()) {
         $this->layout = 'ajax';
         $ajax = $isAjax = true;
     }
     $this->set(compact('ajax', 'isAjax', 'here'));
 }