Example #1
0
 public function migrateDeprectated($repositoriesList, AjxpRole $oldRole)
 {
     $repositoriesList["ajxp.all"] = "";
     foreach ($repositoriesList as $repoId => $repoObject) {
         $right = $oldRole->getRight($repoId);
         if (!empty($right)) {
             $this->setAcl($repoId, $right);
         }
         $actions = $oldRole->getSpecificActionsRights($repoId);
         if (count($actions)) {
             foreach ($actions as $act => $status) {
                 if ($repoId == "ajxp.all") {
                     $this->setActionState(AJXP_PLUGINS_SCOPE_ALL, $act, AJXP_REPO_SCOPE_ALL, $status);
                 } else {
                     $this->setActionState(AJXP_PLUGINS_SCOPE_ALL, $act, $repoId, $status);
                 }
             }
         }
     }
     $this->setGroupPath($oldRole->getGroupPath());
     if ($oldRole->isDefault()) {
         $this->setAutoApplies(array("all"));
     }
 }
 /**
  * Create or update role
  *
  * @param AjxpRole $roleObject
  */
 static function updateRole($roleObject)
 {
     $roles = self::getRolesList();
     $roles[$roleObject->getId()] = $roleObject;
     self::saveRolesList($roles);
 }
 /**
  * Send repositories access for given role as XML
  *
  * @param AjxpRole $role
  * @return string
  */
 static function writeRoleRepositoriesData($role)
 {
     $st = "<repositories>";
     foreach (ConfService::getRepositoriesList() as $repoId => $repoObject) {
         $toLast = false;
         if ($repoObject->getAccessType() == "ajxp_conf") {
             continue;
         }
         if ($repoObject->getAccessType() == "ajxp_shared" && !AuthService::usersEnabled()) {
             continue;
         }
         $rightString = " r=\"" . ($role->canRead($repoId) ? "1" : "0") . "\" w=\"" . ($role->canWrite($repoId) ? "1" : "0") . "\"";
         $string = "<repo access_type=\"" . $repoObject->accessType . "\" id=\"" . $repoId . "\"{$rightString}><label>" . SystemTextEncoding::toUTF8(AJXP_Utils::xmlEntities($repoObject->getDisplay())) . "</label></repo>";
         if ($toLast) {
             $lastString = $string;
         } else {
             $st .= $string;
         }
     }
     if (isset($lastString)) {
         $st .= $lastString;
     }
     $st .= "</repositories>";
     $st .= "<actions_rights>";
     foreach ($role->getSpecificActionsRights("ajxp.all") as $actionId => $actionValue) {
         $st .= "<action name=\"{$actionId}\" value=\"" . ($actionValue ? "true" : "false") . "\"/>";
     }
     $st .= "</actions_rights>";
     return $st;
 }