function isAuthorized($user, $controller, $action)
 {
     $aco = new Aco();
     $resource = $aco->findByAlias($controller . "::" . $action);
     if (!empty($resource)) {
         return $this->Acl->check($user, $controller . "::" . $action, '*');
     } else {
         return $this->Acl->check($user, $controller, 'read');
     }
 }
示例#2
0
 function admin_create_basic_acl()
 {
     Configure::write('debug', '2');
     //turn debugging off; debugging breaks ajax
     die('not now!');
     $aco = new Aco();
     $aro = new Aro();
     /*
     $aro->create();
     $aro->save(array('alias' => 'users'));
     $aro->create();
     $aro->save(array('alias' => 'admins', 'parent_id' => 1));
     
     $aco->create();
     $aco->save(array('alias' => 'admin'));
     $aco->create();
     $aco->save(array('alias' => 'site', 'parent_id' => 1));
     */
     //$this->Acl->grant(array('alias' => 'users'), array('alias' => 'site'));
     $rr = $aro->findByAlias('users');
     $rc = $aco->findByAlias('site');
     print_r($rr);
     $this->Acl->grant(array('Aro' => array('alias' => 'users')), array('Aco' => array('alias' => 'site')), '*');
     //$this->Acl->grant(2, 1);
     //$this->Acl->grant(array('alias' => 'admins'), array('alias' => 'admin'));
     $this->set('json', 'a');
 }