예제 #1
0
 /**
  * Filter the very basic keywords from the XML  : AJXP_USER, AJXP_INSTALL_PATH, AJXP_DATA_PATH
  * Calls the vars.filter hooks.
  * @static
  * @param $value
  * @param AbstractAjxpUser $resolveUser
  * @return mixed|string
  */
 public static function filter($value, $resolveUser = null)
 {
     if (is_string($value) && strpos($value, "AJXP_USER") !== false) {
         if (AuthService::usersEnabled()) {
             if ($resolveUser != null) {
                 $value = str_replace("AJXP_USER", $resolveUser->getId(), $value);
             } else {
                 $loggedUser = AuthService::getLoggedUser();
                 if ($loggedUser != null) {
                     if ($loggedUser->hasParent() && $loggedUser->getResolveAsParent()) {
                         $loggedUserId = $loggedUser->getParent();
                     } else {
                         $loggedUserId = $loggedUser->getId();
                     }
                     $value = str_replace("AJXP_USER", $loggedUserId, $value);
                 } else {
                     return "";
                 }
             }
         } else {
             $value = str_replace("AJXP_USER", "shared", $value);
         }
     }
     if (is_string($value) && strpos($value, "AJXP_GROUP_PATH") !== false) {
         if (AuthService::usersEnabled()) {
             if ($resolveUser != null) {
                 $loggedUser = $resolveUser;
             } else {
                 $loggedUser = AuthService::getLoggedUser();
             }
             if ($loggedUser != null) {
                 $gPath = $loggedUser->getGroupPath();
                 $value = str_replace("AJXP_GROUP_PATH_FLAT", str_replace("/", "_", trim($gPath, "/")), $value);
                 $value = str_replace("AJXP_GROUP_PATH", $gPath, $value);
             } else {
                 return "";
             }
         } else {
             $value = str_replace(array("AJXP_GROUP_PATH", "AJXP_GROUP_PATH_FLAT"), "shared", $value);
         }
     }
     if (is_string($value) && strpos($value, "AJXP_INSTALL_PATH") !== false) {
         $value = str_replace("AJXP_INSTALL_PATH", AJXP_INSTALL_PATH, $value);
     }
     if (is_string($value) && strpos($value, "AJXP_DATA_PATH") !== false) {
         $value = str_replace("AJXP_DATA_PATH", AJXP_DATA_PATH, $value);
     }
     $tab = array(&$value);
     AJXP_Controller::applyIncludeHook("vars.filter", $tab);
     return $value;
 }
 /**
  * @param AbstractAjxpUser $userObject
  * @param string $rolePrefix get all roles with prefix
  * @param string $includeString get roles in this string
  * @param string $excludeString eliminate roles in this string
  * @param bool $byUserRoles
  * @return array
  */
 public function getUserRoleList($userObject, $rolePrefix, $includeString, $excludeString, $byUserRoles = false)
 {
     if (!$userObject) {
         return array();
     }
     if ($byUserRoles) {
         $allUserRoles = $userObject->getRoles();
     } else {
         $allUserRoles = AuthService::getRolesList(array(), true);
     }
     $allRoles = array();
     if (isset($allUserRoles)) {
         // Exclude
         if ($excludeString) {
             if (strpos($excludeString, "preg:") !== false) {
                 $matchFilterExclude = "/" . str_replace("preg:", "", $excludeString) . "/i";
             } else {
                 $valueFiltersExclude = array_map("trim", explode(",", $excludeString));
                 $valueFiltersExclude = array_map("strtolower", $valueFiltersExclude);
             }
         }
         // Include
         if ($includeString) {
             if (strpos($includeString, "preg:") !== false) {
                 $matchFilterInclude = "/" . str_replace("preg:", "", $includeString) . "/i";
             } else {
                 $valueFiltersInclude = array_map("trim", explode(",", $includeString));
                 $valueFiltersInclude = array_map("strtolower", $valueFiltersInclude);
             }
         }
         foreach ($allUserRoles as $roleId => $role) {
             if (!empty($rolePrefix) && strpos($roleId, $rolePrefix) === false) {
                 continue;
             }
             if (isset($matchFilterExclude) && preg_match($matchFilterExclude, substr($roleId, strlen($rolePrefix)))) {
                 continue;
             }
             if (isset($valueFiltersExclude) && in_array(strtolower(substr($roleId, strlen($rolePrefix))), $valueFiltersExclude)) {
                 continue;
             }
             if (isset($matchFilterInclude) && !preg_match($matchFilterInclude, substr($roleId, strlen($rolePrefix)))) {
                 continue;
             }
             if (isset($valueFiltersInclude) && !in_array(strtolower(substr($roleId, strlen($rolePrefix))), $valueFiltersInclude)) {
                 continue;
             }
             if (is_a($role, "AJXP_Role")) {
                 $roleObject = $role;
             } else {
                 $roleObject = AuthService::getRole($roleId);
             }
             $label = $roleObject->getLabel();
             $label = !empty($label) ? $label : substr($roleId, strlen($rolePrefix));
             $allRoles[$roleId] = $label;
         }
     }
     return $allRoles;
 }
예제 #3
0
 /**
  * Update a user object with the default repositories rights
  *
  * @param AbstractAjxpUser $userObject
  */
 public static function updateDefaultRights(&$userObject)
 {
     if (!$userObject->hasParent()) {
         $changes = false;
         foreach (ConfService::getRepositoriesList() as $repositoryId => $repoObject) {
             if (!self::allowedForCurrentGroup($repoObject, $userObject)) {
                 continue;
             }
             if ($repoObject->isTemplate) {
                 continue;
             }
             if ($repoObject->getDefaultRight() != "") {
                 $changes = true;
                 $userObject->personalRole->setAcl($repositoryId, $repoObject->getDefaultRight());
             }
         }
         if ($changes) {
             $userObject->recomputeMergedRole();
         }
         foreach (AuthService::getRolesList(array(), true) as $roleId => $roleObject) {
             if (!self::allowedForCurrentGroup($roleObject, $userObject)) {
                 continue;
             }
             if ($userObject->getProfile() == "shared" && $roleObject->autoAppliesTo("shared")) {
                 $userObject->addRole($roleObject);
             } else {
                 if ($roleObject->autoAppliesTo("standard")) {
                     $userObject->addRole($roleObject);
                 }
             }
         }
     }
 }
예제 #4
0
 /**
  * AJXP_User Constructor
  * @param $id String User login name.
  * @param $storage AbstractConfDriver User storage implementation.
  * @return AJXP_User
  */
 function AJXP_User($id, $storage = null, $debugEnabled = false)
 {
     parent::AbstractAjxpUser($id, $storage);
     //$this->debugEnabled = true;
     $this->log('Instantiating User');
 }
 function AJXP_User($id, $storage = null)
 {
     parent::AbstractAjxpUser($id, $storage);
     $this->registerForSave = array();
 }
예제 #6
0
 public function setGroupPath($groupPath, $update = false)
 {
     if ($update && isset($this->groupPath) && $groupPath != $this->groupPath) {
         // Update Shared Users groups as well
         $res = dibi::query("SELECT [u.login] FROM [ajxp_users] AS u, [ajxp_user_rights] AS p WHERE [u.login] = [p.login] AND [p.repo_uuid] = %s AND [p.rights] = %s AND [u.groupPath] != %s ", "ajxp.parent_user", $this->getId(), $groupPath);
         foreach ($res as $row) {
             $userId = $row->login;
             // UPDATE USER GROUP AND ROLES
             $u = ConfService::getConfStorageImpl()->createUserObject($userId);
             $u->setGroupPath($groupPath);
             $r = $u->getRoles();
             // REMOVE OLD GROUP ROLES
             foreach (array_keys($r) as $role) {
                 if (strpos($role, "AJXP_GRP_/") === 0) {
                     $u->removeRole($role);
                 }
             }
             $u->recomputeMergedRole();
             $u->save("superuser");
         }
     }
     parent::setGroupPath($groupPath);
     dibi::query('UPDATE [ajxp_users] SET ', array('groupPath' => $groupPath), 'WHERE [login] = %s', $this->getId());
     $this->log('UPDATE GROUP: [Login]: ' . $this->getId() . ' [Group]:' . $groupPath);
 }
예제 #7
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;
 }
 /**
  * Update a user object with the default repositories rights
  *
  * @param AbstractAjxpUser $userObject
  */
 static function updateDefaultRights(&$userObject)
 {
     if (!$userObject->hasParent()) {
         foreach (ConfService::getRepositoriesList() as $repositoryId => $repoObject) {
             if ($repoObject->isTemplate) {
                 continue;
             }
             if ($repoObject->getDefaultRight() != "") {
                 $userObject->setRight($repositoryId, $repoObject->getDefaultRight());
             }
         }
         foreach (AuthService::getRolesList() as $roleId => $roleObject) {
             if ($roleObject->isDefault()) {
                 $userObject->addRole($roleId);
             }
         }
     }
 }
 /**
  * @param AbstractAjxpUser $userObject
  * @return array()
  */
 function getExposedPreferences($userObject)
 {
     $stringPrefs = array("display", "lang", "diapo_autofit", "sidebar_splitter_size", "vertical_splitter_size", "history/last_repository", "pending_folder", "thumb_size", "plugins_preferences", "upload_auto_send", "upload_auto_close", "upload_existing", "action_bar_style", "force_default_repository");
     $jsonPrefs = array("ls_history", "columns_size", "columns_visibility", "gui_preferences");
     $prefs = array();
     if ($userObject->getId() == "guest" && ConfService::getCoreConf("SAVE_GUEST_PREFERENCES", "conf") === false) {
         return array();
     }
     if (ConfService::getCoreConf("SKIP_USER_HISTORY", "conf") === true) {
         $stringPrefs = array_diff($stringPrefs, array("history/last_repository"));
         $jsonPrefs = array("columns_size", "columns_visibility", "gui_preferences");
     }
     foreach ($stringPrefs as $pref) {
         if (strstr($pref, "/") !== false) {
             $parts = explode("/", $pref);
             $value = $userObject->getArrayPref($parts[0], $parts[1]);
             $pref = str_replace("/", "_", $pref);
         } else {
             $value = $userObject->getPref($pref);
         }
         $prefs[$pref] = array("value" => $value, "type" => "string");
     }
     foreach ($jsonPrefs as $pref) {
         $prefs[$pref] = array("value" => $userObject->getPref($pref), "type" => "json");
     }
     return $prefs;
 }
예제 #10
0
 function AJXP_User($id, $storage = null)
 {
     parent::AbstractAjxpUser($id, $storage);
 }
예제 #11
0
 public function abstractUserToAdress(AbstractAjxpUser $user)
 {
     // SHOULD CHECK THAT THIS USER IS "AUTHORIZED" TO AVOID SPAM
     $userEmail = $user->personalRole->filterParameterValue("core.conf", "email", AJXP_REPO_SCOPE_ALL, "");
     if (empty($userEmail)) {
         return false;
     }
     $displayName = $user->personalRole->filterParameterValue("core.conf", "USER_DISPLAY_NAME", AJXP_REPO_SCOPE_ALL, "");
     if (empty($displayName)) {
         $displayName = $user->getId();
     }
     return array("name" => $displayName, "adress" => $userEmail);
 }
 /**
  * @param AbstractAjxpUser $user
  * @return bool
  */
 protected function updateCurrentUserRights($user)
 {
     if ($this->repositoryId == null) {
         return true;
     }
     if (!$user->canSwitchTo($this->repositoryId)) {
         throw new Sabre\DAV\Exception\NotAuthenticated();
     }
 }
 /**
  * @static
  * @param String $type
  * @param String $element
  * @param AbstractAjxpUser $loggedUser
  * @return void
  */
 public static function deleteSharedElement($type, $element, $loggedUser)
 {
     $mess = ConfService::getMessages();
     if ($type == "repository") {
         $repo = ConfService::getRepositoryById($element);
         if (!$repo->hasOwner() || $repo->getOwner() != $loggedUser->getId()) {
             throw new Exception($mess["ajxp_shared.12"]);
         } else {
             $res = ConfService::deleteRepository($element);
             if ($res == -1) {
                 throw new Exception($mess["ajxp_conf.51"]);
             }
         }
     } else {
         if ($type == "user") {
             $confDriver = ConfService::getConfStorageImpl();
             $object = $confDriver->createUserObject($element);
             if (!$object->hasParent() || $object->getParent() != $loggedUser->getId()) {
                 throw new Exception($mess["ajxp_shared.12"]);
             } else {
                 AuthService::deleteUser($element);
             }
         } else {
             if ($type == "file") {
                 $publicletData = self::loadPublicletData($element);
                 if (isset($publicletData["OWNER_ID"]) && $publicletData["OWNER_ID"] == $loggedUser->getId()) {
                     PublicletCounter::delete($element);
                     unlink($publicletData["PUBLICLET_PATH"]);
                 } else {
                     throw new Exception($mess["ajxp_shared.12"]);
                 }
             }
         }
     }
 }
예제 #14
0
 /**
  * @param Repository $repository
  * @param AbstractAjxpUser $user
  * @return Array
  */
 protected function buildIndexLockKey($repository, $user)
 {
     $scope = $repository->securityScope();
     $key = $repository->getId();
     if ($scope == "USER") {
         $key .= "-" . $user->getId();
     } else {
         if ($scope == "GROUP") {
             $key .= "-" . ltrim(str_replace("/", "__", $user->getGroupPath()), "__");
         }
     }
     return $key;
 }
예제 #15
0
 /**
  * Override parent method to keep a reference to the child users
  * @param $parentId
  */
 public function setParent($parentId)
 {
     $u = ConfService::getConfStorageImpl()->createUserObject($parentId);
     $p = $u->getChildrenPointer();
     if ($p == null) {
         $p = array();
     }
     $p[$this->getId()] = $this->getId();
     $u->setChildrenPointer($p);
     $u->save("superuser");
     if (AuthService::getLoggedUser() != null && AuthService::getLoggedUser()->getId() == $parentId) {
         AuthService::updateUser($u);
     }
     parent::setParent($parentId);
 }
 /**
  * @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");
     }
 }
예제 #17
0
 /**
  * @static
  * @param String $type
  * @param String $element
  * @param AbstractAjxpUser $loggedUser
  * @throws Exception
  */
 public static function deleteSharedElement($type, $element, $loggedUser)
 {
     $mess = ConfService::getMessages();
     AJXP_Logger::debug($type . "-" . $element);
     if ($type == "repository") {
         $repo = ConfService::getRepositoryById($element);
         if ($repo == null) {
             return;
         }
         if (!$repo->hasOwner() || $repo->getOwner() != $loggedUser->getId()) {
             throw new Exception($mess["ajxp_shared.12"]);
         } else {
             $res = ConfService::deleteRepository($element);
             if ($res == -1) {
                 throw new Exception($mess["ajxp_conf.51"]);
             }
         }
     } else {
         if ($type == "minisite") {
             $minisiteData = self::loadPublicletData($element);
             $repoId = $minisiteData["REPOSITORY"];
             $repo = ConfService::getRepositoryById($repoId);
             if ($repo == null) {
                 return false;
             }
             if (!$repo->hasOwner() || $repo->getOwner() != $loggedUser->getId()) {
                 throw new Exception($mess["ajxp_shared.12"]);
             } else {
                 $res = ConfService::deleteRepository($repoId);
                 if ($res == -1) {
                     throw new Exception($mess["ajxp_conf.51"]);
                 }
                 // Silently delete corresponding role if it exists
                 AuthService::deleteRole("AJXP_SHARED-" . $repoId);
                 // If guest user created, remove it now.
                 if (isset($minisiteData["PRELOG_USER"])) {
                     AuthService::deleteUser($minisiteData["PRELOG_USER"]);
                 }
                 unlink($minisiteData["PUBLICLET_PATH"]);
             }
         } else {
             if ($type == "user") {
                 $confDriver = ConfService::getConfStorageImpl();
                 $object = $confDriver->createUserObject($element);
                 if (!$object->hasParent() || $object->getParent() != $loggedUser->getId()) {
                     throw new Exception($mess["ajxp_shared.12"]);
                 } else {
                     AuthService::deleteUser($element);
                 }
             } else {
                 if ($type == "file") {
                     $publicletData = self::loadPublicletData($element);
                     if (isset($publicletData["OWNER_ID"]) && $publicletData["OWNER_ID"] == $loggedUser->getId()) {
                         PublicletCounter::delete($element);
                         unlink($publicletData["PUBLICLET_PATH"]);
                     } else {
                         throw new Exception($mess["ajxp_shared.12"]);
                     }
                 }
             }
         }
     }
 }
 /**
  * @param AbstractAjxpUser $userObject
  * @return array()
  */
 public function getExposedPreferences($userObject)
 {
     $stringPrefs = array("lang", "history/last_repository", "pending_folder", "plugins_preferences");
     $jsonPrefs = array("ls_history", "gui_preferences");
     $prefs = array();
     if ($userObject->getId() == "guest" && ConfService::getCoreConf("SAVE_GUEST_PREFERENCES", "conf") === false) {
         return array();
     }
     if (ConfService::getCoreConf("SKIP_USER_HISTORY", "conf") === true) {
         $stringPrefs = array("lang", "pending_folder", "plugins_preferences");
         $jsonPrefs = array("gui_preferences");
         $prefs["SKIP_USER_HISTORY"] = array("value" => "true", "type" => "string");
     }
     foreach ($stringPrefs as $pref) {
         if (strstr($pref, "/") !== false) {
             $parts = explode("/", $pref);
             $value = $userObject->getArrayPref($parts[0], $parts[1]);
             $pref = str_replace("/", "_", $pref);
         } else {
             $value = $userObject->getPref($pref);
         }
         $prefs[$pref] = array("value" => $value, "type" => "string");
     }
     foreach ($jsonPrefs as $pref) {
         $prefs[$pref] = array("value" => $userObject->getPref($pref), "type" => "json");
     }
     $paramNodes = AJXP_PluginsService::searchAllManifests("//server_settings/param[contains(@scope,'user') and @expose='true']", "node", false, false, true);
     if (is_array($paramNodes) && count($paramNodes)) {
         foreach ($paramNodes as $xmlNode) {
             if ($xmlNode->getAttribute("expose") == "true") {
                 $parentNode = $xmlNode->parentNode->parentNode;
                 $pluginId = $parentNode->getAttribute("id");
                 if (empty($pluginId)) {
                     $pluginId = $parentNode->nodeName . "." . $parentNode->getAttribute("name");
                 }
                 $name = $xmlNode->getAttribute("name");
                 $value = $userObject->mergedRole->filterParameterValue($pluginId, $name, AJXP_REPO_SCOPE_ALL, "");
                 $prefs[$name] = array("value" => $value, "type" => "string", "pluginId" => $pluginId);
             }
         }
     }
     return $prefs;
 }
 function getPref($prefName)
 {
     $p = parent::getPref($prefName);
     if (isset($p)) {
         if (strpos($p, '$phpserial$') !== false && strpos($p, '$phpserial$') === 0) {
             $p = substr($p, strlen('$phpserial$'));
             return unserialize($p);
         }
         // old method
         if ($prefName == "CUSTOM_PARAMS") {
             return unserialize($p);
         }
     }
     return $p;
 }
예제 #20
0
 /**
  * @param string $repoId
  * @param Repository $repoObject
  * @param array $exposed
  * @param array $streams
  * @param AbstractAjxpUser $loggedUser
  * @param string $accessStatus
  * @return string
  * @throws Exception
  */
 public static function repositoryToXML($repoId, $repoObject, $exposed, $streams, $loggedUser, $accessStatus = "")
 {
     $statusString = " repository_type=\"" . $repoObject->getRepositoryType() . "\"";
     if (empty($accessStatus)) {
         $accessStatus = $repoObject->getAccessStatus();
     }
     if (!empty($accessStatus)) {
         $statusString .= " access_status=\"{$accessStatus}\" ";
     } else {
         if ($loggedUser != null) {
             $lastConnected = $loggedUser->getArrayPref("repository_last_connected", $repoId);
             if (!empty($lastConnected)) {
                 $statusString .= " last_connection=\"{$lastConnected}\" ";
             }
         }
     }
     $streamString = "";
     if (in_array($repoObject->accessType, $streams)) {
         $streamString = "allowCrossRepositoryCopy=\"true\"";
     }
     if ($repoObject->getUniqueUser()) {
         $streamString .= " user_editable_repository=\"true\" ";
     }
     if ($repoObject->hasContentFilter()) {
         $streamString .= " hasContentFilter=\"true\"";
     }
     $slugString = "";
     $slug = $repoObject->getSlug();
     if (!empty($slug)) {
         $slugString = "repositorySlug=\"{$slug}\"";
     }
     $isSharedString = "";
     $currentUserIsOwner = false;
     $ownerLabel = null;
     if ($repoObject->hasOwner()) {
         $uId = $repoObject->getOwner();
         if (AuthService::usersEnabled() && AuthService::getLoggedUser()->getId() == $uId) {
             $currentUserIsOwner = true;
         }
         $label = ConfService::getUserPersonalParameter("USER_DISPLAY_NAME", $uId, "core.conf", $uId);
         $ownerLabel = $label;
         $isSharedString = 'owner="' . AJXP_Utils::xmlEntities($label) . '"';
     }
     if ($repoObject->securityScope() == "USER" || $currentUserIsOwner) {
         $streamString .= " userScope=\"true\"";
     }
     $descTag = "";
     $public = false;
     if (!empty($_SESSION["CURRENT_MINISITE"])) {
         $public = true;
     }
     $description = $repoObject->getDescription($public, $ownerLabel);
     if (!empty($description)) {
         $descTag = '<description>' . AJXP_Utils::xmlEntities($description, true) . '</description>';
     }
     $roleString = "";
     if ($loggedUser != null) {
         $merged = $loggedUser->mergedRole;
         $params = array();
         foreach ($exposed as $exposed_prop) {
             $metaOptions = $repoObject->getOption("META_SOURCES");
             if (!isset($metaOptions[$exposed_prop["PLUGIN_ID"]])) {
                 continue;
             }
             $value = $exposed_prop["DEFAULT"];
             if (isset($metaOptions[$exposed_prop["PLUGIN_ID"]][$exposed_prop["NAME"]])) {
                 $value = $metaOptions[$exposed_prop["PLUGIN_ID"]][$exposed_prop["NAME"]];
             }
             $value = $merged->filterParameterValue($exposed_prop["PLUGIN_ID"], $exposed_prop["NAME"], $repoId, $value);
             if ($value !== null) {
                 if ($value === true || $value === false) {
                     $value = $value === true ? "true" : "false";
                 }
                 $params[] = '<repository_plugin_param plugin_id="' . $exposed_prop["PLUGIN_ID"] . '" name="' . $exposed_prop["NAME"] . '" value="' . AJXP_Utils::xmlEntities($value) . '"/>';
                 $roleString .= str_replace(".", "_", $exposed_prop["PLUGIN_ID"]) . "_" . $exposed_prop["NAME"] . '="' . AJXP_Utils::xmlEntities($value) . '" ';
             }
         }
         $roleString .= 'acl="' . $merged->getAcl($repoId) . '"';
         if ($merged->hasMask($repoId)) {
             $roleString .= ' hasMask="true" ';
         }
     }
     return "<repo access_type=\"" . $repoObject->accessType . "\" id=\"" . $repoId . "\"{$statusString} {$streamString} {$slugString} {$isSharedString} {$roleString}><label>" . SystemTextEncoding::toUTF8(AJXP_Utils::xmlEntities($repoObject->getDisplay())) . "</label>" . $descTag . $repoObject->getClientSettings() . "</repo>";
 }
예제 #21
0
 /**
  * Update a user object with the default repositories rights
  *
  * @param AbstractAjxpUser $userObject
  */
 function updateDefaultRights(&$userObject)
 {
     foreach (ConfService::getRepositoriesList() as $repositoryId => $repoObject) {
         if ($repoObject->getDefaultRight() != "") {
             $userObject->setRight($repositoryId, $repoObject->getDefaultRight());
         }
     }
 }
예제 #22
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 $parentUser
  * @param string $userName
  * @param string $password
  * @param bool $isHidden
  * @param string $display
  * @return AbstractAjxpUser
  * @throws Exception
  */
 public function createNewUser($parentUser, $userName, $password, $isHidden, $display)
 {
     $confDriver = ConfService::getConfStorageImpl();
     if (ConfService::getAuthDriverImpl()->getOptionAsBool("TRANSMIT_CLEAR_PASS")) {
         $pass = $password;
     } else {
         $pass = md5($password);
     }
     if (!$isHidden) {
         // This is an explicit user creation - check possible limits
         AJXP_Controller::applyHook("user.before_create", array($userName, null, false, false));
         $limit = $parentUser->mergedRole->filterParameterValue("core.conf", "USER_SHARED_USERS_LIMIT", AJXP_REPO_SCOPE_ALL, "");
         if (!empty($limit) && intval($limit) > 0) {
             $count = count($confDriver->getUserChildren($parentUser->getId()));
             if ($count >= $limit) {
                 $mess = ConfService::getMessages();
                 throw new Exception($mess['483']);
             }
         }
     }
     AuthService::createUser($userName, $pass, false, $isHidden);
     $userObject = $confDriver->createUserObject($userName);
     $userObject->personalRole->clearAcls();
     $userObject->setParent($parentUser->getId());
     $userObject->setGroupPath($parentUser->getGroupPath());
     $userObject->setProfile("shared");
     if ($isHidden) {
         $userObject->setHidden(true);
         $userObject->personalRole->setParameterValue("core.conf", "USER_DISPLAY_NAME", $display);
     }
     AJXP_Controller::applyHook("user.after_create", array($userObject));
     return $userObject;
 }