Exemple #1
0
 /**
  * @param AJXP_Role $role
  * @return AJXP_Role
  */
 public function override(AJXP_Role $role)
 {
     $newRole = new AJXP_Role($role->getId());
     $roleAcl = $role->listAcls();
     $newAcls = $this->array_merge_recursive2($roleAcl, $this->listAcls());
     foreach ($newAcls as $repoId => $rightString) {
         //if($rightString == AJXP_VALUE_CLEAR) continue;
         if (empty($rightString) && !empty($roleAcl[$repoId])) {
             $rightString = $roleAcl[$repoId];
         }
         $newRole->setAcl($repoId, $rightString);
     }
     $roleParameters = $role->listParameters(true);
     $newParams = $this->array_merge_recursive2($roleParameters, $this->listParameters(true));
     foreach ($newParams as $repoId => $data) {
         foreach ($data as $pluginId => $param) {
             foreach ($param as $parameterName => $parameterValue) {
                 if ($parameterValue === true || $parameterValue === false) {
                     $newRole->setParameterValue($pluginId, $parameterName, $parameterValue, $repoId);
                     continue;
                 }
                 if ($parameterValue == AJXP_VALUE_CLEAR) {
                     continue;
                 }
                 if ($parameterValue === "" && !empty($roleParameters[$repoId][$pluginId][$parameterName])) {
                     $parameterValue = $newParams[$repoId][$pluginId][$parameterName];
                 }
                 $newRole->setParameterValue($pluginId, $parameterName, $parameterValue, $repoId);
             }
         }
     }
     $newActions = $this->array_merge_recursive2($role->listActionsStates(), $this->listActionsStates());
     foreach ($newActions as $repoId => $data) {
         foreach ($data as $pluginId => $action) {
             foreach ($action as $actionName => $actionState) {
                 $newRole->setActionState($pluginId, $actionName, $repoId, $actionState);
             }
         }
     }
     $roleMasks = $role->listMasks();
     $allKeys = array_merge(array_keys($this->masks), array_keys($roleMasks));
     foreach ($allKeys as $repoId) {
         if (isset($roleMasks[$repoId]) && isset($this->masks[$repoId])) {
             $newRole->setMask($repoId, $roleMasks[$repoId]->override($this->masks[$repoId]));
         } else {
             if (isset($roleMasks[$repoId])) {
                 $newRole->setMask($repoId, $roleMasks[$repoId]);
             } else {
                 $newRole->setMask($repoId, $this->masks[$repoId]);
             }
         }
     }
     return $newRole;
 }
 /**
  * @param AJXP_Role $role
  * @return Repository[]
  */
 public function listRepositoriesForRole($role)
 {
     $acls = $role->listAcls();
     if (!count($acls)) {
         return array();
     }
     $limitRepositories = array_keys($acls);
     $res = dibi::query('SELECT * FROM [ajxp_repo] WHERE [uuid] IN (%s) ORDER BY [display] ASC', $limitRepositories);
     $all = $res->fetchAll();
     return $this->initRepoArrayFromDbFetch($all);
 }
 /**
  * @param AJXP_Role $role
  * @return AJXP_Role
  */
 public function override(AJXP_Role $role)
 {
     $newRole = new AJXP_Role($role->getId());
     $newAcls = $this->array_merge_recursive2($role->listAcls(), $this->listAcls());
     foreach ($newAcls as $repoId => $rightString) {
         if ($rightString == AJXP_VALUE_CLEAR) {
             continue;
         }
         $newRole->setAcl($repoId, $rightString);
     }
     $newParams = $this->array_merge_recursive2($role->listParameters(true), $this->listParameters(true));
     foreach ($newParams as $repoId => $data) {
         foreach ($data as $pluginId => $param) {
             foreach ($param as $parameterName => $parameterValue) {
                 if ($parameterValue === true || $parameterValue === false) {
                     $newRole->setParameterValue($pluginId, $parameterName, $parameterValue, $repoId);
                     continue;
                 }
                 if ($parameterValue == AJXP_VALUE_CLEAR) {
                     continue;
                 }
                 $newRole->setParameterValue($pluginId, $parameterName, $parameterValue, $repoId);
             }
         }
     }
     $newActions = $this->array_merge_recursive2($role->listActionsStates(), $this->listActionsStates());
     foreach ($newActions as $repoId => $data) {
         foreach ($data as $pluginId => $action) {
             foreach ($action as $actionName => $actionState) {
                 $newRole->setActionState($pluginId, $actionName, $repoId, $actionState);
             }
         }
     }
     return $newRole;
 }