示例#1
0
 /**
  * @param AJXP_Role $role
  * @param AbstractAjxpUser|null $userObject
  */
 public function updateRole($role, $userObject = null)
 {
     if ($userObject != null) {
         // This a personal role, save differently
         $userObject->personalRole = $role;
         $userObject->save("superuser");
     } else {
         $all = AJXP_Utils::loadSerialFile($this->rolesSerialFile);
         $all[$role->getId()] = $role;
         AJXP_Utils::saveSerialFile($this->rolesSerialFile, $all);
     }
 }
 /**
  * @param AbstractAjxpUser $userObject
  */
 public function updateUserObject(&$userObject)
 {
     $applyRole = $this->getOption("AUTO_APPLY_ROLE");
     if (!empty($applyRole)) {
         $rObject = AuthService::getRole($applyRole, true);
         $userObject->addRole($rObject);
         $userObject->save("superuser");
     }
 }
示例#3
0
 /**
  * @param AbstractAjxpUser $loggedUser
  * @param String|int $parameterId
  * @return bool
  */
 public static function switchUserToActiveRepository($loggedUser, $parameterId = -1)
 {
     if (isset($_SESSION["PENDING_REPOSITORY_ID"]) && isset($_SESSION["PENDING_FOLDER"])) {
         $loggedUser->setArrayPref("history", "last_repository", $_SESSION["PENDING_REPOSITORY_ID"]);
         $loggedUser->setPref("pending_folder", $_SESSION["PENDING_FOLDER"]);
         $loggedUser->save("user");
         AuthService::updateUser($loggedUser);
         unset($_SESSION["PENDING_REPOSITORY_ID"]);
         unset($_SESSION["PENDING_FOLDER"]);
     }
     $currentRepoId = ConfService::getCurrentRepositoryId();
     $lastRepoId = $loggedUser->getArrayPref("history", "last_repository");
     $defaultRepoId = AuthService::getDefaultRootId();
     if ($defaultRepoId == -1) {
         return false;
     } else {
         if ($lastRepoId !== "" && $lastRepoId !== $currentRepoId && $parameterId == -1 && $loggedUser->canSwitchTo($lastRepoId)) {
             ConfService::switchRootDir($lastRepoId);
         } else {
             if ($parameterId != -1 && $loggedUser->canSwitchTo($parameterId)) {
                 ConfService::switchRootDir($parameterId);
             } else {
                 if (!$loggedUser->canSwitchTo($currentRepoId)) {
                     ConfService::switchRootDir($defaultRepoId);
                 }
             }
         }
     }
     return true;
 }
示例#4
0
 /**
  * Update a user with admin rights and return it
  * @param AbstractAjxpUser $adminUser
  * @return AbstractAjxpUser
  */
 public static function updateAdminRights($adminUser)
 {
     if ($adminUser->personalRole->getAcl('ajxp_conf') != "rw") {
         $adminUser->personalRole->setAcl('ajxp_conf', 'rw');
         $adminUser->recomputeMergedRole();
         $adminUser->save("superuser");
     }
     return $adminUser;
 }