本文整理汇总了PHP中AuthService::filterBaseGroup方法的典型用法代码示例。如果您正苦于以下问题:PHP AuthService::filterBaseGroup方法的具体用法?PHP AuthService::filterBaseGroup怎么用?PHP AuthService::filterBaseGroup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AuthService
的用法示例。
在下文中一共展示了AuthService::filterBaseGroup方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getUsersForRepository
/**
* @param string $repositoryId
* @return AbstractAjxpUser[]
*/
public function getUsersForRepository($repositoryId)
{
$result = array();
$authDriver = ConfService::getAuthDriverImpl();
$confDriver = ConfService::getConfStorageImpl();
$users = $authDriver->listUsers(AuthService::filterBaseGroup("/"));
foreach (array_keys($users) as $id) {
$object = $confDriver->createUserObject($id);
if ($object->canSwitchTo($repositoryId)) {
$result[$id] = $object;
}
}
return $result;
}
示例2: switchAction
//.........这里部分代码省略.........
$userId = $httpVars["user_id"];
$userObject = ConfService::getConfStorageImpl()->createUserObject($userId);
if ($userObject == null || !$userObject->hasParent() || $userObject->getParent() != AuthService::getLoggedUser()->getId()) {
throw new Exception("You are not allowed to edit this user");
}
AuthService::deleteUser($userId);
echo "SUCCESS";
break;
case "user_list_authorized_users":
$defaultFormat = "html";
HTMLWriter::charsetHeader();
if (!ConfService::getAuthDriverImpl()->usersEditable()) {
break;
}
$loggedUser = AuthService::getLoggedUser();
$crtValue = $httpVars["value"];
$usersOnly = isset($httpVars["users_only"]) && $httpVars["users_only"] == "true";
$existingOnly = isset($httpVars["existing_only"]) && $httpVars["existing_only"] == "true";
if (!empty($crtValue)) {
$regexp = '^' . $crtValue;
} else {
$regexp = null;
}
$skipDisplayWithoutRegexp = ConfService::getCoreConf("USERS_LIST_REGEXP_MANDATORY", "conf");
if ($skipDisplayWithoutRegexp && $regexp == null) {
print "<ul></ul>";
break;
}
$limit = intval(ConfService::getCoreConf("USERS_LIST_COMPLETE_LIMIT", "conf"));
$searchAll = ConfService::getCoreConf("CROSSUSERS_ALLGROUPS", "conf");
$displayAll = ConfService::getCoreConf("CROSSUSERS_ALLGROUPS_DISPLAY", "conf");
$baseGroup = "/";
if ($regexp == null && !$displayAll || $regexp != null && !$searchAll) {
$baseGroup = AuthService::filterBaseGroup("/");
}
AuthService::setGroupFiltering(false);
$allUsers = AuthService::listUsers($baseGroup, $regexp, 0, $limit, false);
if (!$usersOnly) {
$allGroups = array();
$roleOrGroup = ConfService::getCoreConf("GROUP_OR_ROLE", "conf");
$rolePrefix = $excludeString = $includeString = null;
if (!is_array($roleOrGroup)) {
$roleOrGroup = array("group_switch_value" => $roleOrGroup);
}
$listRoleType = false;
if (isset($roleOrGroup["PREFIX"])) {
$rolePrefix = $loggedUser->mergedRole->filterParameterValue("core.conf", "PREFIX", null, $roleOrGroup["PREFIX"]);
$excludeString = $loggedUser->mergedRole->filterParameterValue("core.conf", "EXCLUDED", null, $roleOrGroup["EXCLUDED"]);
$includeString = $loggedUser->mergedRole->filterParameterValue("core.conf", "INCLUDED", null, $roleOrGroup["INCLUDED"]);
$listUserRolesOnly = $loggedUser->mergedRole->filterParameterValue("core.conf", "LIST_ROLE_BY", null, $roleOrGroup["LIST_ROLE_BY"]);
if (is_array($listUserRolesOnly) && isset($listUserRolesOnly["group_switch_value"])) {
switch ($listUserRolesOnly["group_switch_value"]) {
case "userroles":
$listRoleType = true;
break;
case "allroles":
$listRoleType = false;
break;
default:
break;
}
}
}
switch (strtolower($roleOrGroup["group_switch_value"])) {
case 'user':
// donothing
示例3: updateUserObject
//.........这里部分代码省略.........
if (isset($matchFilter) && !preg_match($matchFilter, $uniqValueWithPrefix)) {
continue;
}
if (isset($valueFilters) && !in_array($uniqValueWithPrefix, $valueFilters)) {
continue;
}
$roleToAdd = AuthService::getRole($uniqValueWithPrefix, true);
$roleToAdd->setLabel($uniqValue);
AuthService::updateRole($roleToAdd);
$userObject->addRole($roleToAdd);
$changes = true;
}
} else {
foreach ($entry[$key] as $uniqValue) {
if (isset($matchFilter) && !preg_match($matchFilter, $uniqValue)) {
continue;
}
if (isset($valueFilters) && !in_array($uniqValue, $valueFilters)) {
continue;
}
if (!in_array($uniqValue, array_keys($userObject->getRoles())) && !empty($uniqValue)) {
$userObject->addRole(AuthService::getRole($uniqValue, true));
$changes = true;
}
}
}
break;
case "group_path":
if ($key == "memberof") {
$filter = $params["MAPPING_LOCAL_PARAM"];
if (strpos($filter, "preg:") !== false) {
$matchFilter = "/" . str_replace("preg:", "", $filter) . "/i";
} else {
if (!empty($filter)) {
$valueFilters = array_map("trim", explode(",", $filter));
}
}
foreach ($memberValues as $uniqValue => $fullDN) {
if (isset($matchFilter) && !preg_match($matchFilter, $uniqValue)) {
continue;
}
if (isset($valueFilters) && !in_array($uniqValue, $valueFilters)) {
continue;
}
if ($userObject->personalRole->filterParameterValue("auth.ldap", "MEMBER_OF", AJXP_REPO_SCOPE_ALL, "") == $fullDN) {
//break;
}
$humanName = $uniqValue;
$branch = array();
$this->buildGroupBranch($uniqValue, $branch);
$parent = "/";
if (count($branch)) {
$parent = "/" . implode("/", array_reverse($branch));
}
if (!ConfService::getConfStorageImpl()->groupExists(rtrim(AuthService::filterBaseGroup($parent), "/") . "/" . $fullDN)) {
AuthService::createGroup($parent, $fullDN, $humanName);
}
$userObject->setGroupPath(rtrim($parent, "/") . "/" . $fullDN, true);
// Update Roles from groupPath
$b = array_reverse($branch);
$b[] = $fullDN;
for ($i = 1; $i <= count($b); $i++) {
$userObject->addRole(AuthService::getRole("AJXP_GRP_/" . implode("/", array_slice($b, 0, $i)), true));
}
$userObject->personalRole->setParameterValue("auth.ldap", "MEMBER_OF", $fullDN);
$userObject->recomputeMergedRole();
$changes = true;
}
}
break;
case "profile":
if ($userObject->getProfile() != $value) {
$changes = true;
$userObject->setProfile($value);
AuthService::updateAutoApplyRole($userObject);
}
break;
case "plugin_param":
default:
if (strpos($params["MAPPING_LOCAL_PARAM"], "/") !== false) {
list($pId, $param) = explode("/", $params["MAPPING_LOCAL_PARAM"]);
} else {
$pId = $this->getId();
$param = $params["MAPPING_LOCAL_PARAM"];
}
if ($userObject->personalRole->filterParameterValue($pId, $param, AJXP_REPO_SCOPE_ALL, "") != $value) {
$userObject->personalRole->setParameterValue($pId, $param, $value);
$userObject->recomputeMergedRole();
$changes = true;
}
break;
}
}
}
}
if ($changes) {
$userObject->save("superuser");
}
}
}
示例4: switchAction
//.........这里部分代码省略.........
}
$gLabel = AJXP_Utils::decodeSecureMagic($httpVars["group_label"]);
AuthService::createGroup($basePath, $gName, $gLabel);
AJXP_XMLWriter::header();
AJXP_XMLWriter::sendMessage($mess["ajxp_conf.124"], null);
AJXP_XMLWriter::reloadDataNode();
AJXP_XMLWriter::close();
break;
case "create_role":
$roleId = AJXP_Utils::sanitize(SystemTextEncoding::magicDequote($httpVars["role_id"]), AJXP_SANITIZE_HTML_STRICT);
if (!strlen($roleId)) {
throw new Exception($mess[349]);
}
if (AuthService::getRole($roleId) !== false) {
throw new Exception($mess["ajxp_conf.65"]);
}
$r = new AJXP_Role($roleId);
if (AuthService::getLoggedUser() != null && AuthService::getLoggedUser()->getGroupPath() != null) {
$r->setGroupPath(AuthService::getLoggedUser()->getGroupPath());
}
AuthService::updateRole($r);
AJXP_XMLWriter::header();
AJXP_XMLWriter::sendMessage($mess["ajxp_conf.66"], null);
AJXP_XMLWriter::reloadDataNode("", $httpVars["role_id"]);
AJXP_XMLWriter::close();
break;
case "edit_role":
$roleId = SystemTextEncoding::magicDequote($httpVars["role_id"]);
$roleGroup = false;
$userObject = null;
$groupLabel = null;
if (strpos($roleId, "AJXP_GRP_") === 0) {
$groupPath = substr($roleId, strlen("AJXP_GRP_"));
$filteredGroupPath = AuthService::filterBaseGroup($groupPath);
$groups = AuthService::listChildrenGroups(AJXP_Utils::forwardSlashDirname($groupPath));
$key = "/" . basename($groupPath);
if (!array_key_exists($key, $groups)) {
throw new Exception("Cannot find group with this id!");
}
$roleId = "AJXP_GRP_" . $filteredGroupPath;
$groupLabel = $groups[$key];
$roleGroup = true;
}
if (strpos($roleId, "AJXP_USR_") === 0) {
$usrId = str_replace("AJXP_USR_/", "", $roleId);
$userObject = ConfService::getConfStorageImpl()->createUserObject($usrId);
if (!AuthService::canAdministrate($userObject)) {
throw new Exception("Cant find user!");
}
$role = $userObject->personalRole;
} else {
$role = AuthService::getRole($roleId, $roleGroup);
}
if ($role === false) {
throw new Exception("Cant find role! ");
}
if (isset($httpVars["format"]) && $httpVars["format"] == "json") {
HTMLWriter::charsetHeader("application/json");
$roleData = $role->getDataArray(true);
$allReps = ConfService::getRepositoriesList("all", false);
$repos = array();
if (!empty($userObject)) {
// USER
foreach ($allReps as $repositoryId => $repositoryObject) {
if (!AuthService::canAssign($repositoryObject, $userObject) || $repositoryObject->isTemplate || $repositoryObject->getAccessType() == "ajxp_conf" && !$userObject->isAdmin() || $repositoryObject->getUniqueUser() != null && $repositoryObject->getUniqueUser() != $userObject->getId()) {
continue;
示例5: createSharedRepository
//.........这里部分代码省略.........
$options["META_SOURCES"] = $repository->getOption("META_SOURCES");
foreach ($options["META_SOURCES"] as $index => $data) {
if (isset($data["USE_SESSION_CREDENTIALS"]) && $data["USE_SESSION_CREDENTIALS"] === true) {
$options["META_SOURCES"][$index]["ENCODED_CREDENTIALS"] = AJXP_Safe::getEncodedCredentialString();
}
}
}
$newRepo = $repository->createSharedChild($label, $options, $repository->id, $loggedUser->id, null);
$gPath = $loggedUser->getGroupPath();
if (!empty($gPath) && !ConfService::getCoreConf("CROSSUSERS_ALLGROUPS", "conf")) {
$newRepo->setGroupPath($gPath);
}
$newRepo->setDescription($description);
ConfService::addRepository($newRepo);
}
$file = AJXP_Utils::decodeSecureMagic($httpVars["file"]);
if (isset($editingRepo)) {
$currentRights = $this->computeSharedRepositoryAccessRights($httpVars["repository_id"], false, $this->urlBase . $file);
$originalUsers = array_keys($currentRights["USERS"]);
$removeUsers = array_diff($originalUsers, $users);
if (count($removeUsers)) {
foreach ($removeUsers as $user) {
if (AuthService::userExists($user)) {
$userObject = $confDriver->createUserObject($user);
$userObject->personalRole->setAcl($newRepo->getUniqueId(), "");
$userObject->save("superuser");
}
}
}
$originalGroups = array_keys($currentRights["GROUPS"]);
$removeGroups = array_diff($originalGroups, $groups);
if (count($removeGroups)) {
foreach ($removeGroups as $groupId) {
$role = AuthService::getRole("AJXP_GRP_" . AuthService::filterBaseGroup($groupId));
if ($role !== false) {
$role->setAcl($newRepo->getUniqueId(), "");
AuthService::updateRole($role);
}
}
}
}
foreach ($users as $userName) {
if (AuthService::userExists($userName, "r")) {
// check that it's a child user
$userObject = $confDriver->createUserObject($userName);
} else {
if (ConfService::getAuthDriverImpl()->getOption("TRANSMIT_CLEAR_PASS")) {
$pass = $uPasses[$userName];
} else {
$pass = md5($uPasses[$userName]);
}
$limit = $loggedUser->personalRole->filterParameterValue("core.conf", "USER_SHARED_USERS_LIMIT", AJXP_REPO_SCOPE_ALL, "");
if (!empty($limit) && intval($limit) > 0) {
$count = count(ConfService::getConfStorageImpl()->getUserChildren($loggedUser->getId()));
if ($count >= $limit) {
$mess = ConfService::getMessages();
throw new Exception($mess['483']);
}
}
AuthService::createUser($userName, $pass);
$userObject = $confDriver->createUserObject($userName);
$userObject->personalRole->clearAcls();
$userObject->setParent($loggedUser->id);
$userObject->setGroupPath($loggedUser->getGroupPath());
$userObject->setProfile("shared");
if (isset($httpVars["minisite"])) {
示例6: computeSharedRepositoryAccessRights
/**
* @param String $repoId
* @param $mixUsersAndGroups
* @param $currentFileUrl
* @return array
*/
public function computeSharedRepositoryAccessRights($repoId, $mixUsersAndGroups, $currentFileUrl = null)
{
$roles = AuthService::getRolesForRepository($repoId);
$sharedEntries = $sharedGroups = $sharedRoles = array();
$mess = ConfService::getMessages();
foreach ($roles as $rId) {
$role = AuthService::getRole($rId);
if ($role == null) {
continue;
}
$RIGHT = $role->getAcl($repoId);
if (empty($RIGHT)) {
continue;
}
$ID = $rId;
$WATCH = false;
if (strpos($rId, "AJXP_USR_/") === 0) {
$userId = substr($rId, strlen('AJXP_USR_/'));
$role = AuthService::getRole($rId);
$userObject = ConfService::getConfStorageImpl()->createUserObject($userId);
$LABEL = $role->filterParameterValue("core.conf", "USER_DISPLAY_NAME", AJXP_REPO_SCOPE_ALL, "");
if (empty($LABEL)) {
$LABEL = $userId;
}
$TYPE = $userObject->hasParent() ? "tmp_user" : "user";
if ($this->watcher !== false && $currentFileUrl != null) {
$WATCH = $this->watcher->hasWatchOnNode(new AJXP_Node($currentFileUrl), $userId, MetaWatchRegister::$META_WATCH_USERS_NAMESPACE);
}
$ID = $userId;
} else {
if (strpos($rId, "AJXP_GRP_/") === 0) {
if (empty($loadedGroups)) {
$displayAll = ConfService::getCoreConf("CROSSUSERS_ALLGROUPS_DISPLAY", "conf");
if ($displayAll) {
AuthService::setGroupFiltering(false);
}
$loadedGroups = AuthService::listChildrenGroups();
if ($displayAll) {
AuthService::setGroupFiltering(true);
} else {
$baseGroup = AuthService::filterBaseGroup("/");
foreach ($loadedGroups as $loadedG => $loadedLabel) {
unset($loadedGroups[$loadedG]);
$loadedGroups[rtrim($baseGroup, "/") . "/" . ltrim($loadedG, "/")] = $loadedLabel;
}
}
}
$groupId = substr($rId, strlen('AJXP_GRP_'));
if (isset($loadedGroups[$groupId])) {
$LABEL = $loadedGroups[$groupId];
}
if ($groupId == "/") {
$LABEL = $mess["447"];
}
if (empty($LABEL)) {
$LABEL = $groupId;
}
$TYPE = "group";
} else {
if ($rId == "ROOT_ROLE") {
$rId = "AJXP_GRP_/";
$TYPE = "group";
$LABEL = $mess["447"];
} else {
$role = AuthService::getRole($rId);
$LABEL = $role->getLabel();
$TYPE = 'group';
}
}
}
if (empty($LABEL)) {
$LABEL = $rId;
}
$entry = array("ID" => $ID, "TYPE" => $TYPE, "LABEL" => $LABEL, "RIGHT" => $RIGHT);
if ($WATCH) {
$entry["WATCH"] = $WATCH;
}
if ($TYPE == "group") {
$sharedGroups[$entry["ID"]] = $entry;
} else {
$sharedEntries[$entry["ID"]] = $entry;
}
}
if (!$mixUsersAndGroups) {
return array("USERS" => $sharedEntries, "GROUPS" => $sharedGroups);
} else {
return array_merge(array_values($sharedGroups), array_values($sharedEntries));
}
/*
$users = AuthService::getUsersForRepository($repoId);
//var_dump($roles);
$baseGroup = "/";
$groups = AuthService::listChildrenGroups($baseGroup);
$mess = ConfService::getMessages();
//.........这里部分代码省略.........
示例7: listRepositories
public function listRepositories()
{
AJXP_XMLWriter::sendFilesListComponentConfig('<columns switchGridMode="filelist"><column messageId="ajxp_conf.8" attributeName="ajxp_label" sortType="String"/><column messageId="user_dash.9" attributeName="parent_label" sortType="String"/><column messageId="user_dash.9" attributeName="repo_accesses" sortType="String"/></columns>');
$repoArray = array();
$loggedUser = AuthService::getLoggedUser();
$count = 0;
$repos = ConfService::listRepositoriesWithCriteria(array("owner_user_id" => $loggedUser->getId()), $count);
$searchAll = ConfService::getCoreConf("CROSSUSERS_ALLGROUPS", "conf");
$displayAll = ConfService::getCoreConf("CROSSUSERS_ALLGROUPS_DISPLAY", "conf");
if ($searchAll || $displayAll) {
$baseGroup = "/";
} else {
$baseGroup = AuthService::filterBaseGroup("/");
}
AuthService::setGroupFiltering(false);
$users = AuthService::listUsers($baseGroup);
$minisites = $this->listSharedFiles("minisites");
foreach ($repos as $repoIndex => $repoObject) {
if ($repoObject->getAccessType() == "ajxp_conf") {
continue;
}
if (!$repoObject->hasOwner() || $repoObject->getOwner() != $loggedUser->getId()) {
continue;
}
if (is_numeric($repoIndex)) {
$repoIndex = "" . $repoIndex;
}
$name = (isset($minisites[$repoIndex]) ? "[Minisite] " : "") . AJXP_Utils::xmlEntities(SystemTextEncoding::toUTF8($repoObject->getDisplay()));
$repoArray[$name] = $repoIndex;
}
// Sort the list now by name
ksort($repoArray);
foreach ($repoArray as $name => $repoIndex) {
$repoObject =& $repos[$repoIndex];
$repoAccesses = array();
foreach ($users as $userId => $userObject) {
if ($userObject->getId() == $loggedUser->getId()) {
continue;
}
$label = $userObject->personalRole->filterParameterValue("core.conf", "USER_DISPLAY_NAME", AJXP_REPO_SCOPE_ALL, $userId);
if (empty($label)) {
$label = $userId;
}
$acl = $userObject->mergedRole->getAcl($repoObject->getId());
if (!empty($acl)) {
$repoAccesses[] = $label . " (" . $acl . ")";
}
}
$parent = $repoObject->getParentId();
$parentRepo =& $repos[$parent];
$parentLabel = $this->metaIcon("folder-open") . $parentRepo->getDisplay();
$repoPath = $repoObject->getOption("PATH");
$parentPath = $parentRepo->getOption("PATH");
$parentLabel .= " (" . str_replace($parentPath, "", $repoPath) . ")";
$metaData = array("repository_id" => $repoIndex, "icon" => "document_open_remote.png", "openicon" => "document_open_remote.png", "parentname" => "/repositories", "parent_label" => $parentLabel, "repo_accesses" => count($repoAccesses) ? $this->metaIcon("share-sign") . implode(", ", $repoAccesses) : "", "ajxp_mime" => "shared_repository");
AJXP_XMLWriter::renderNode("/repositories/{$repoIndex}", $name, true, $metaData);
}
}
示例8: computeSharedRepositoryAccessRights
/**
* @param String $repoId
* @param bool $mixUsersAndGroups
* @param AJXP_Node|null $watcherNode
* @return array
*/
public function computeSharedRepositoryAccessRights($repoId, $mixUsersAndGroups, $watcherNode = null)
{
$roles = AuthService::getRolesForRepository($repoId);
$sharedEntries = $sharedGroups = array();
$mess = ConfService::getMessages();
foreach ($roles as $rId) {
$role = AuthService::getRole($rId);
if ($role == null) {
continue;
}
$RIGHT = $role->getAcl($repoId);
if (empty($RIGHT)) {
continue;
}
$ID = $rId;
$WATCH = false;
$HIDDEN = false;
$AVATAR = false;
if (strpos($rId, "AJXP_USR_/") === 0) {
$userId = substr($rId, strlen('AJXP_USR_/'));
$role = AuthService::getRole($rId);
$userObject = ConfService::getConfStorageImpl()->createUserObject($userId);
$LABEL = $role->filterParameterValue("core.conf", "USER_DISPLAY_NAME", AJXP_REPO_SCOPE_ALL, "");
$AVATAR = $role->filterParameterValue("core.conf", "avatar", AJXP_REPO_SCOPE_ALL, "");
if (empty($LABEL)) {
$LABEL = $userId;
}
$TYPE = $userObject->hasParent() ? "tmp_user" : "user";
$HIDDEN = $userObject->isHidden();
if ($this->watcher !== false && $watcherNode != null) {
$WATCH = $this->watcher->hasWatchOnNode($watcherNode, $userId, MetaWatchRegister::$META_WATCH_USERS_NAMESPACE);
}
$ID = $userId;
} else {
if ($rId == "AJXP_GRP_" . AuthService::filterBaseGroup("/")) {
$TYPE = "group";
$LABEL = $mess["447"];
} else {
if (strpos($rId, "AJXP_GRP_/") === 0) {
if (empty($loadedGroups)) {
$displayAll = ConfService::getCoreConf("CROSSUSERS_ALLGROUPS_DISPLAY", "conf");
if ($displayAll) {
AuthService::setGroupFiltering(false);
}
$loadedGroups = AuthService::listChildrenGroups();
if ($displayAll) {
AuthService::setGroupFiltering(true);
} else {
$baseGroup = AuthService::filterBaseGroup("/");
foreach ($loadedGroups as $loadedG => $loadedLabel) {
unset($loadedGroups[$loadedG]);
$loadedGroups[rtrim($baseGroup, "/") . "/" . ltrim($loadedG, "/")] = $loadedLabel;
}
}
}
$groupId = substr($rId, strlen('AJXP_GRP_'));
if (isset($loadedGroups[$groupId])) {
$LABEL = $loadedGroups[$groupId];
}
/*
if($groupId == AuthService::filterBaseGroup("/")){
$LABEL = $mess["447"];
}
*/
if (empty($LABEL)) {
$LABEL = $groupId;
}
$TYPE = "group";
} else {
$role = AuthService::getRole($rId);
$LABEL = $role->getLabel();
$TYPE = 'group';
}
}
}
if (empty($LABEL)) {
$LABEL = $rId;
}
$entry = array("ID" => $ID, "TYPE" => $TYPE, "LABEL" => $LABEL, "RIGHT" => $RIGHT);
if ($WATCH) {
$entry["WATCH"] = $WATCH;
}
if ($HIDDEN) {
$entry["HIDDEN"] = true;
}
if ($AVATAR !== false) {
$entry["AVATAR"] = $AVATAR;
}
if ($TYPE == "group") {
$sharedGroups[$entry["ID"]] = $entry;
} else {
$sharedEntries[$entry["ID"]] = $entry;
}
}
//.........这里部分代码省略.........