Esempio n. 1
0
 public function getPermission($resource, array $ids = [])
 {
     if (!$this->_guard) {
         return new AclPermission($resource, $ids, true);
     }
     if (in_array($resource, Config::get('acl::allways_allow_resources'))) {
         return new AclPermission($resource, $ids, true);
     }
     $authUser = $this->getAuthUser();
     if (!$authUser) {
         return new AclPermission($resource, [], false);
     }
     $groupResource = GroupResources::getResourceGroup($resource);
     if ($groupResource) {
         $resource = $groupResource;
     }
     if (isset($authUser->permissions[$resource])) {
         $permission = $authUser->getPermission($resource, $ids);
         return $this->applyHook($permission, $ids);
     }
     $result = new AclPermission($resource);
     foreach ($authUser->user_types as $type) {
         if (isset($this->registersRoleProviders[$type])) {
             $permission = $this->registersRoleProviders[$type]->getPermission($resource, $ids);
             $result = $result->mergePermission($permission);
         }
         if ($result->isAllowAll()) {
             break;
         }
     }
     return $this->applyHook($result, $ids);
 }
Esempio n. 2
0
 public function getPermission($resource, array $ids = [])
 {
     if (in_array($resource, Config::get('acl::allways_allow_resources'))) {
         return new AclPermission($resource, $ids, true);
     }
     $groupResource = GroupResources::getResourceGroup($resource);
     if ($groupResource) {
         $resource = $groupResource;
     }
     $result = new AclPermission($resource);
     if ($ids) {
         $result = $result->newSubPermission($ids);
     }
     $result = AclFacade::applyHook($result, $ids, $this);
     $aclUser = $this;
     if (!isset($this->permissions)) {
         $aclUser = self::findWithPermissions($this->getKey());
     }
     if (isset($aclUser->permissions[$resource])) {
         $result = $aclUser->permissions[$resource];
         if ($ids) {
             $result = $result->newSubPermission($ids);
         }
     }
     return $result;
 }