Exemplo n.º 1
0
 public function removePermission(Lynx_Acl_Role_Db $role, Lynx_Acl_Permission_Db $permission)
 {
     $sql = "DELETE FROM `" . $this->_db->tablePrefix() . "role_permissions` WHERE `role_id` = ? AND `permission_id` = ? LIMIT 1";
     if ($this->_db->query($sql, array($role->getId(), $permission->getId()))) {
         return true;
     } else {
         throw new Exception('Could not remove permission');
     }
 }
Exemplo n.º 2
0
 protected function __construct(Lynx_Database $db, Lynx_Auth_Abstract $auth)
 {
     $this->_db = $db;
     $this->_auth = $auth;
     if ($this->_auth->authenticated()) {
         // load permissions
         $Lynx_Acl_Auth_Role_Db = new Lynx_Acl_Auth_Role_Db($db, $auth);
         $this->_roles = $Lynx_Acl_Auth_Role_Db->getRoles();
         $Lynx_Acl_Role_Permission_Db = new Lynx_Acl_Role_Permission_Db($db);
         foreach ($this->_roles as $key => $array) {
             $tmp = new Lynx_Acl_Role_Db($db);
             $tmp->load($array['role_id']);
             $perms = $Lynx_Acl_Role_Permission_Db->getPermissions($tmp);
             $this->_roles[$key] = $tmp;
             if (!empty($perms)) {
                 foreach ($perms as $key => $arr) {
                     $Lynx_Acl_Permission = $this->_permissions[] = new Lynx_Acl_Permission($arr['permission_name'], $arr['permission_id']);
                     $this->allow($this->_roles[$key], $Lynx_Acl_Permission);
                 }
             }
         }
     }
 }