Esempio n. 1
0
 protected function beforeSave()
 {
     if (parent::beforeSave()) {
         if (isset($this->originalAttributeValues['group']) && $this->originalAttributeValues['group'][1] > 0) {
             //copy to new object, so we can populate the old parent group as the related group.
             //otherwise it gets passed by reference. We need the old $this->group information to properly
             //utilize the groupBeingRemovedFromGroup method.
             $group = unserialize(serialize($this));
             $group->group = Group::getById($this->originalAttributeValues['group'][1]);
             ReadPermissionsOptimizationUtil::groupBeingRemovedFromGroup($group);
             assert('$this->originalAttributeValues["group"][1] != $this->group->id');
         }
         return true;
     } else {
         return false;
     }
 }
Esempio n. 2
0
 /**
  * If a user is removed from a role, raise two events signaling a potential change in
  * Rights/Policies for this user.
  * @see Item::beforeSave()
  */
 protected function beforeSave()
 {
     if (parent::beforeSave()) {
         if (isset($this->originalAttributeValues['role']) && $this->originalAttributeValues['role'][1] > 0) {
             AllPermissionsOptimizationUtil::userBeingRemovedFromRole($this, Role::getById($this->originalAttributeValues['role'][1]));
             $this->onChangeRights();
             $this->onChangePolicies();
         }
         return true;
     } else {
         return false;
     }
 }