Beispiel #1
0
 public function inherit(PermissionsInterface $permissions, $build = true)
 {
     /* @var $permissions Permissions */
     $assigned = $permissions->getAssigned();
     $resources = $permissions->getResources();
     /*
      * Grant resource references permissions.
      */
     foreach ($resources as $resource) {
         /* @var $resource PermissionsResourceInterface */
         $permission = $permissions->getFrom($resource);
         $this->grant($resource, $permission, false);
         unset($assigned[$resource->getPermissionsResourceId()]);
     }
     /*
      * Merge remaining user permissions (w/o resource references)
      */
     $this->assigned = array_merge($this->assigned, $assigned);
     if ($build) {
         $this->build();
     }
     $this->hasChanged = true;
     return $this;
 }
Beispiel #2
0
 public function inherit(PermissionsInterface $permissions, $build = true)
 {
     // Override permissions type temporarly to get the right permissions back
     // from resources which may be aware of the permissions type.
     // Maybe this must be controllable by an additional parameter, but for now
     // we make this default.
     $oldType = $this->type;
     $this->type = $permissions->getType();
     /* @var $permissions Permissions */
     $assigned = $permissions->getAssigned();
     $resources = $permissions->getResources();
     /*
      * Grant resource references permissions.
      */
     foreach ($resources as $resource) {
         /* @var $resource PermissionsResourceInterface */
         $permission = $permissions->getFrom($resource);
         $this->grant($resource, $permission, false);
         unset($assigned[$resource->getPermissionsResourceId()]);
     }
     /*
      * Merge remaining user permissions (w/o resource references)
      */
     $this->assigned = array_merge($this->assigned, $assigned);
     if ($build) {
         $this->build();
     }
     $this->hasChanged = true;
     // restore orginial permissions type
     $this->type = $oldType;
     return $this;
 }
Beispiel #3
0
 /**
  * Sets the Permissions of an Organization
  *
  * @param PermissionsInterface $permissions
  *
  * @return $this
  */
 public function setPermissions(PermissionsInterface $permissions)
 {
     // Assure the user has always all rights.
     if ($this->user) {
         $permissions->grant($this->user, Permissions::PERMISSION_ALL);
     }
     $this->permissions = $permissions;
     return $this;
 }
Beispiel #4
0
 /**
  *
  * @param PermissionsInterface $permissions
  */
 private function setupPermissions(PermissionsInterface $permissions = null)
 {
     if ($this->user) {
         $permissions->grant($this->user, PermissionsInterface::PERMISSION_ALL);
     }
 }