Ejemplo n.º 1
0
 /**
  * Checks if current user has a given permission
  *
  * @param __Permission $permission
  * @return bool
  */
 public function hasPermission(__Permission &$permission)
 {
     $roles_collection = new __RolesCollection();
     $roles_collection->fromArray($this->getRoles());
     $roles_equivalent_permission = $roles_collection->getEquivalentPermission();
     return $permission->isJuniorPermissionOf($roles_equivalent_permission);
 }
Ejemplo n.º 2
0
 /**
  * Checks if active roles have a given permission
  *
  * @param integer $permission
  * @return unknown
  */
 public final function hasPermission(__Permission $permission)
 {
     $return_value = false;
     if ($permission == null) {
         $return_value = true;
     } else {
         $active_roles_equivalent_permission = $this->_active_roles->getEquivalentPermission();
         if ($permission->isJuniorPermissionOf($active_roles_equivalent_permission)) {
             $return_value = $permission->checkPermission();
         }
     }
     return $return_value;
 }