本文整理汇总了PHP中AuthService::isReservedUserId方法的典型用法代码示例。如果您正苦于以下问题:PHP AuthService::isReservedUserId方法的具体用法?PHP AuthService::isReservedUserId怎么用?PHP AuthService::isReservedUserId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AuthService
的用法示例。
在下文中一共展示了AuthService::isReservedUserId方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parseSpecificContributions
/**
* Extend parent
* @param DOMNode $contribNode
*/
protected function parseSpecificContributions(&$contribNode)
{
parent::parseSpecificContributions($contribNode);
$disableSharing = false;
$downloadFolder = ConfService::getCoreConf("PUBLIC_DOWNLOAD_FOLDER");
if (empty($downloadFolder) || (!is_dir($downloadFolder) || !is_writable($downloadFolder))) {
$this->logError("Warning on public links, {$downloadFolder} is not writeable!", array("folder" => $downloadFolder, "is_dir" => is_dir($downloadFolder), "is_writeable" => is_writable($downloadFolder)));
}
$xpathesToRemove = array();
if (strpos(ConfService::getRepository()->getAccessType(), "ajxp_") === 0) {
$xpathesToRemove[] = 'action[@name="share-file-minisite"]';
$xpathesToRemove[] = 'action[@name="share-folder-minisite-public"]';
$xpathesToRemove[] = 'action[@name="share-edit-shared"]';
} else {
if (AuthService::usersEnabled()) {
$loggedUser = AuthService::getLoggedUser();
if ($loggedUser != null && AuthService::isReservedUserId($loggedUser->getId())) {
$disableSharing = true;
}
} else {
$disableSharing = true;
}
}
if ($disableSharing) {
// All share- actions
$xpathesToRemove[] = 'action[contains(@name, "share-")]';
} else {
$folderSharingAllowed = $this->getAuthorization("folder", "any");
$fileSharingAllowed = $this->getAuthorization("file", "any");
if ($fileSharingAllowed === false) {
// Share file button
$xpathesToRemove[] = 'action[@name="share-file-minisite"]';
}
if (!$folderSharingAllowed) {
// Share folder button
$xpathesToRemove[] = 'action[@name="share-folder-minisite-public"]';
}
}
foreach ($xpathesToRemove as $xpath) {
$actionXpath = new DOMXPath($contribNode->ownerDocument);
$nodeList = $actionXpath->query($xpath, $contribNode);
foreach ($nodeList as $shareActionNode) {
$contribNode->removeChild($shareActionNode);
}
}
}
示例2: switchAction
//.........这里部分代码省略.........
}
HTMLWriter::charsetHeader("application/json");
echo json_encode($output);
break;
case "user_set_lock":
$userId = AJXP_Utils::decodeSecureMagic($httpVars["user_id"]);
$lock = $httpVars["lock"] == "true" ? true : false;
$lockType = $httpVars["lock_type"];
if (AuthService::userExists($userId)) {
$userObject = ConfService::getConfStorageImpl()->createUserObject($userId);
if (!AuthService::canAdministrate($userObject)) {
throw new Exception("Cannot update user data for " . $userId);
}
if ($lock) {
$userObject->setLock($lockType);
} else {
$userObject->removeLock();
}
$userObject->save("superuser");
}
break;
case "create_user":
if (!isset($httpVars["new_user_login"]) || $httpVars["new_user_login"] == "" || !isset($httpVars["new_user_pwd"]) || $httpVars["new_user_pwd"] == "") {
AJXP_XMLWriter::header();
AJXP_XMLWriter::sendMessage(null, $mess["ajxp_conf.61"]);
AJXP_XMLWriter::close();
return;
}
$original_login = SystemTextEncoding::magicDequote($httpVars["new_user_login"]);
$new_user_login = AJXP_Utils::sanitize($original_login, AJXP_SANITIZE_EMAILCHARS);
if ($original_login != $new_user_login) {
throw new Exception(str_replace("%s", $new_user_login, $mess["ajxp_conf.127"]));
}
if (AuthService::userExists($new_user_login, "w") || AuthService::isReservedUserId($new_user_login)) {
throw new Exception($mess["ajxp_conf.43"]);
}
AuthService::createUser($new_user_login, $httpVars["new_user_pwd"]);
$confStorage = ConfService::getConfStorageImpl();
$newUser = $confStorage->createUserObject($new_user_login);
$basePath = AuthService::getLoggedUser()->getGroupPath();
if (empty($basePath)) {
$basePath = "/";
}
if (!empty($httpVars["group_path"])) {
$newUser->setGroupPath(rtrim($basePath, "/") . "/" . ltrim($httpVars["group_path"], "/"));
} else {
$newUser->setGroupPath($basePath);
}
$newUser->save("superuser");
AJXP_XMLWriter::header();
AJXP_XMLWriter::sendMessage($mess["ajxp_conf.44"], null);
AJXP_XMLWriter::reloadDataNode("", $new_user_login);
AJXP_XMLWriter::close();
break;
case "change_admin_right":
$userId = $httpVars["user_id"];
if (!AuthService::userExists($userId)) {
throw new Exception("Invalid user id!");
}
$confStorage = ConfService::getConfStorageImpl();
$user = $confStorage->createUserObject($userId);
if (!AuthService::canAdministrate($user)) {
throw new Exception("Cannot update user with id " . $userId);
}
$user->setAdmin($httpVars["right_value"] == "1" ? true : false);
$user->save("superuser");
示例3: createSharedRepository
//.........这里部分代码省略.........
$groups[] = $u;
}
}
$uRights[$u] = $rightString;
$uPasses[$u] = isset($httpVars["user_pass_" . $index]) ? $httpVars["user_pass_" . $index] : "";
if ($this->watcher !== false) {
$uWatches[$u] = $uWatch;
}
$index++;
}
$label = AJXP_Utils::decodeSecureMagic($httpVars["repo_label"]);
$description = AJXP_Utils::decodeSecureMagic($httpVars["repo_description"]);
if (isset($httpVars["repository_id"])) {
$editingRepo = ConfService::getRepositoryById($httpVars["repository_id"]);
}
// CHECK USER & REPO DOES NOT ALREADY EXISTS
if ($this->getFilteredOption("AVOID_SHARED_FOLDER_SAME_LABEL", $this->repository->getId()) == true) {
$repos = ConfService::getRepositoriesList();
foreach ($repos as $obj) {
if ($obj->getDisplay() == $label && (!isset($editingRepo) || $editingRepo != $obj)) {
return 101;
}
}
}
$confDriver = ConfService::getConfStorageImpl();
foreach ($users as $userName) {
if (AuthService::userExists($userName)) {
// check that it's a child user
$userObject = $confDriver->createUserObject($userName);
if (ConfService::getCoreConf("ALLOW_CROSSUSERS_SHARING", "conf") != true && (!$userObject->hasParent() || $userObject->getParent() != $loggedUser->id)) {
return 102;
}
} else {
if ($httpVars["create_guest_user"] != "true" && !ConfService::getCoreConf("USER_CREATE_USERS", "conf") || AuthService::isReservedUserId($userName)) {
return 102;
}
if (!isset($httpVars["shared_pass"]) || $httpVars["shared_pass"] == "") {
return 100;
}
}
}
// CREATE SHARED OPTIONS
$options = $accessDriver->makeSharedRepositoryOptions($httpVars, $repository);
$customData = array();
foreach ($httpVars as $key => $value) {
if (substr($key, 0, strlen("PLUGINS_DATA_")) == "PLUGINS_DATA_") {
$customData[substr($key, strlen("PLUGINS_DATA_"))] = $value;
}
}
if (count($customData)) {
$options["PLUGINS_DATA"] = $customData;
}
if (isset($editingRepo)) {
$newRepo = $editingRepo;
if ($editingRepo->getDisplay() != $label) {
$newRepo->setDisplay($label);
ConfService::replaceRepository($httpVars["repository_id"], $newRepo);
}
$editingRepo->setDescription($description);
} else {
if ($repository->getOption("META_SOURCES")) {
$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();
}
示例4: switchAction
//.........这里部分代码省略.........
print AJXP_XMLWriter::replaceAjxpXmlKeywords(ConfService::availableDriversToXML("user_param"));
print "</drivers>";
$wallet = $userObject->getPref("AJXP_WALLET");
if (is_array($wallet) && count($wallet) > 0) {
print "<user_wallet>";
foreach ($wallet as $repoId => $options) {
foreach ($options as $optName => $optValue) {
print "<wallet_data repo_id=\"{$repoId}\" option_name=\"{$optName}\" option_value=\"{$optValue}\"/>";
}
}
print "</user_wallet>";
}
$editPass = $userId != "guest" ? "1" : "0";
$authDriver = ConfService::getAuthDriverImpl();
if (!$authDriver->passwordsEditable()) {
$editPass = "0";
}
print "<edit_options edit_pass=\"" . $editPass . "\" edit_admin_right=\"" . ($userId != "guest" && $userId != $loggedUser->getId() ? "1" : "0") . "\" edit_delete=\"" . ($userId != "guest" && $userId != $loggedUser->getId() && $authDriver->usersEditable() ? "1" : "0") . "\"/>";
print "<ajxp_roles>";
foreach (AuthService::getRolesList() as $roleId => $roleObject) {
print "<role id=\"" . AJXP_Utils::xmlEntities($roleId) . "\"/>";
}
print "</ajxp_roles>";
AJXP_XMLWriter::close("admin_data");
break;
case "create_user":
if (!isset($httpVars["new_user_login"]) || $httpVars["new_user_login"] == "" || !isset($httpVars["new_user_pwd"]) || $httpVars["new_user_pwd"] == "") {
AJXP_XMLWriter::header();
AJXP_XMLWriter::sendMessage(null, $mess["ajxp_conf.61"]);
AJXP_XMLWriter::close();
return;
}
$new_user_login = AJXP_Utils::sanitize(SystemTextEncoding::magicDequote($httpVars["new_user_login"]), AJXP_SANITIZE_EMAILCHARS);
if (AuthService::userExists($new_user_login) || AuthService::isReservedUserId($new_user_login)) {
AJXP_XMLWriter::header();
AJXP_XMLWriter::sendMessage(null, $mess["ajxp_conf.43"]);
AJXP_XMLWriter::close();
return;
}
$confStorage = ConfService::getConfStorageImpl();
$newUser = $confStorage->createUserObject($new_user_login);
$customData = array();
$this->parseParameters($httpVars, $customData);
if (is_array($customData) && count($customData) > 0) {
$newUser->setPref("CUSTOM_PARAMS", $customData);
}
$newUser->save("superuser");
AuthService::createUser($new_user_login, $httpVars["new_user_pwd"]);
AJXP_XMLWriter::header();
AJXP_XMLWriter::sendMessage($mess["ajxp_conf.44"], null);
AJXP_XMLWriter::reloadDataNode("", $new_user_login);
AJXP_XMLWriter::close();
break;
case "change_admin_right":
$userId = $httpVars["user_id"];
if (!AuthService::userExists($userId)) {
throw new Exception("Invalid user id!");
}
$confStorage = ConfService::getConfStorageImpl();
$user = $confStorage->createUserObject($userId);
$user->setAdmin($httpVars["right_value"] == "1" ? true : false);
$user->save("superuser");
AJXP_XMLWriter::header();
AJXP_XMLWriter::sendMessage($mess["ajxp_conf.45"] . $httpVars["user_id"], null);
AJXP_XMLWriter::reloadDataNode();
AJXP_XMLWriter::close();
示例5: createSharedRepository
function createSharedRepository($httpVars, $repository, $accessDriver)
{
// ERRORS
// 100 : missing args
// 101 : repository label already exists
// 102 : user already exists
// 103 : current user is not allowed to share
// SUCCESS
// 200
if (!isset($httpVars["repo_label"]) || $httpVars["repo_label"] == "" || !isset($httpVars["repo_rights"]) || $httpVars["repo_rights"] == "") {
return 100;
}
$loggedUser = AuthService::getLoggedUser();
$actRights = $loggedUser->getSpecificActionsRights($repository->id);
if (isset($actRights["share"]) && $actRights["share"] === false) {
return 103;
}
$users = array();
if (isset($httpVars["shared_user"]) && !empty($httpVars["shared_user"])) {
$users = array_filter(array_map("trim", explode(",", str_replace("\n", ",", $httpVars["shared_user"]))), array("AuthService", "userExists"));
}
if (isset($httpVars["new_shared_user"]) && !empty($httpVars["new_shared_user"])) {
$newshareduser = AJXP_Utils::decodeSecureMagic($httpVars["new_shared_user"], AJXP_SANITIZE_ALPHANUM);
if (!empty($this->pluginConf["SHARED_USERS_TMP_PREFIX"]) && strpos($newshareduser, $this->pluginConf["SHARED_USERS_TMP_PREFIX"]) !== 0) {
$newshareduser = $this->pluginConf["SHARED_USERS_TMP_PREFIX"] . $newshareduser;
}
if (!AuthService::userExists($newshareduser)) {
array_push($users, $newshareduser);
} else {
throw new Exception("User already exists, please choose another name.");
}
}
//$userName = AJXP_Utils::decodeSecureMagic($httpVars["shared_user"], AJXP_SANITIZE_ALPHANUM);
$label = AJXP_Utils::decodeSecureMagic($httpVars["repo_label"]);
$rights = $httpVars["repo_rights"];
if ($rights != "r" && $rights != "w" && $rights != "rw") {
return 100;
}
if (isset($httpVars["repository_id"])) {
$editingRepo = ConfService::getRepositoryById($httpVars["repository_id"]);
}
// CHECK USER & REPO DOES NOT ALREADY EXISTS
$repos = ConfService::getRepositoriesList();
foreach ($repos as $obj) {
if ($obj->getDisplay() == $label && (!isset($editingRepo) || $editingRepo != $obj)) {
return 101;
}
}
$confDriver = ConfService::getConfStorageImpl();
foreach ($users as $userName) {
if (AuthService::userExists($userName)) {
// check that it's a child user
$userObject = $confDriver->createUserObject($userName);
if (ConfService::getCoreConf("ALLOW_CROSSUSERS_SHARING") != true && (!$userObject->hasParent() || $userObject->getParent() != $loggedUser->id)) {
return 102;
}
} else {
if (AuthService::isReservedUserId($userName)) {
return 102;
}
if (!isset($httpVars["shared_pass"]) || $httpVars["shared_pass"] == "") {
return 100;
}
}
}
// CREATE SHARED OPTIONS
$options = $accessDriver->makeSharedRepositoryOptions($httpVars, $repository);
$customData = array();
foreach ($httpVars as $key => $value) {
if (substr($key, 0, strlen("PLUGINS_DATA_")) == "PLUGINS_DATA_") {
$customData[substr($key, strlen("PLUGINS_DATA_"))] = $value;
}
}
if (count($customData)) {
$options["PLUGINS_DATA"] = $customData;
}
if (isset($editingRepo)) {
$newRepo = $editingRepo;
$newRepo->setDisplay($label);
$newRepo->options = array_merge($newRepo->options, $options);
ConfService::replaceRepository($httpVars["repository_id"], $newRepo);
} else {
if ($repository->getOption("META_SOURCES")) {
$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);
ConfService::addRepository($newRepo);
}
if (isset($httpVars["original_users"])) {
$originalUsers = explode(",", $httpVars["original_users"]);
$removeUsers = array_diff($originalUsers, $users);
if (count($removeUsers)) {
foreach ($removeUsers as $user) {
if (AuthService::userExists($user)) {
$userObject = $confDriver->createUserObject($user);
//.........这里部分代码省略.........
示例6: createSharedRepository
//.........这里部分代码省略.........
$editingRepo = ConfService::getRepositoryById($httpVars["repository_id"]);
}
// CHECK USER & REPO DOES NOT ALREADY EXISTS
if ($this->getFilteredOption("AVOID_SHARED_FOLDER_SAME_LABEL", $this->repository->getId()) == true) {
$count = 0;
$similarLabelRepos = ConfService::listRepositoriesWithCriteria(array("display" => $label), $count);
if ($count && !isset($editingRepo)) {
return 101;
}
if ($count && isset($editingRepo)) {
foreach ($similarLabelRepos as $slr) {
if ($slr->getUniqueId() != $editingRepo->getUniqueId()) {
return 101;
}
}
}
/*
$repos = ConfService::getRepositoriesList();
foreach ($repos as $obj) {
if ($obj->getDisplay() == $label && (!isSet($editingRepo) || $editingRepo != $obj)) {
}
}
*/
}
$confDriver = ConfService::getConfStorageImpl();
foreach ($users as $userName) {
if (AuthService::userExists($userName)) {
// check that it's a child user
$userObject = $confDriver->createUserObject($userName);
if (ConfService::getCoreConf("ALLOW_CROSSUSERS_SHARING", "conf") != true && (!$userObject->hasParent() || $userObject->getParent() != $loggedUser->id)) {
return 102;
}
} else {
if ($httpVars["create_guest_user"] != "true" && !ConfService::getCoreConf("USER_CREATE_USERS", "conf") || AuthService::isReservedUserId($userName)) {
return 102;
}
if (!isset($httpVars["shared_pass"]) || $httpVars["shared_pass"] == "") {
return 100;
}
}
}
// CREATE SHARED OPTIONS
$options = $accessDriver->makeSharedRepositoryOptions($httpVars, $repository);
$customData = array();
foreach ($httpVars as $key => $value) {
if (substr($key, 0, strlen("PLUGINS_DATA_")) == "PLUGINS_DATA_") {
$customData[substr($key, strlen("PLUGINS_DATA_"))] = $value;
}
}
if (count($customData)) {
$options["PLUGINS_DATA"] = $customData;
}
if (isset($editingRepo)) {
$this->getShareStore()->testUserCanEditShare($editingRepo->getOwner());
$newRepo = $editingRepo;
$replace = false;
if ($editingRepo->getDisplay() != $label) {
$newRepo->setDisplay($label);
$replace = true;
}
if ($editingRepo->getDescription() != $description) {
$newRepo->setDescription($description);
$replace = true;
}
if ($replace) {
ConfService::replaceRepository($httpVars["repository_id"], $newRepo);
示例7: createUsersFromParameters
/**
* @param $httpVars
* @param array $users
* @param array $groups
* @throws Exception
*/
public function createUsersFromParameters($httpVars, &$users = array(), &$groups = array())
{
$index = 0;
$allowCrossUserSharing = ConfService::getCoreConf("ALLOW_CROSSUSERS_SHARING", "conf");
$allowSharedUsersCreation = ConfService::getCoreConf("USER_CREATE_USERS", "conf");
$loggedUser = AuthService::getLoggedUser();
$confDriver = ConfService::getConfStorageImpl();
$mess = ConfService::getMessages();
while (isset($httpVars[PARAM_USER_LOGIN_PREFIX . $index])) {
$eType = $httpVars[PARAM_USER_ENTRY_TYPE . $index];
$rightString = ($httpVars[PARAM_USER_RIGHT_READ_PREFIX . $index] == "true" ? "r" : "") . ($httpVars[PARAM_USER_RIGHT_WRITE_PREFIX . $index] == "true" ? "w" : "");
$uWatch = false;
if ($this->watcher !== false) {
$uWatch = $httpVars[PARAM_USER_RIGHT_WATCH_PREFIX . $index] == "true" ? true : false;
}
if (empty($rightString)) {
$index++;
continue;
}
if ($eType == "user") {
$u = AJXP_Utils::decodeSecureMagic($httpVars[PARAM_USER_LOGIN_PREFIX . $index], AJXP_SANITIZE_EMAILCHARS);
$userExistsRead = AuthService::userExists($u);
if (!$userExistsRead && !isset($httpVars[PARAM_USER_PASS_PREFIX . $index])) {
$index++;
continue;
} else {
if (AuthService::userExists($u, "w") && isset($httpVars[PARAM_USER_PASS_PREFIX . $index])) {
throw new Exception(str_replace("%s", $u, $mess["share_center.222"]));
}
}
if ($userExistsRead) {
$userObject = $confDriver->createUserObject($u);
if ($allowCrossUserSharing != true && (!$userObject->hasParent() || $userObject->getParent() != $loggedUser->getId())) {
throw new Exception($mess["share_center.221"]);
}
} else {
if (!$allowSharedUsersCreation || AuthService::isReservedUserId($u)) {
throw new Exception($mess["share_center.220"]);
}
if (!empty($this->options["SHARED_USERS_TMP_PREFIX"]) && strpos($u, $this->options["SHARED_USERS_TMP_PREFIX"]) !== 0) {
$u = $this->options["SHARED_USERS_TMP_PREFIX"] . $u;
}
}
$entry = array("ID" => $u, "TYPE" => "user");
} else {
$u = AJXP_Utils::decodeSecureMagic($httpVars[PARAM_USER_LOGIN_PREFIX . $index]);
if (strpos($u, "/AJXP_TEAM/") === 0) {
if (method_exists($confDriver, "teamIdToUsers")) {
$teamUsers = $confDriver->teamIdToUsers(str_replace("/AJXP_TEAM/", "", $u));
foreach ($teamUsers as $userId) {
$users[$userId] = array("ID" => $userId, "TYPE" => "user", "RIGHT" => $rightString);
if ($this->watcher !== false) {
$users[$userId]["WATCH"] = $uWatch;
}
}
}
$index++;
continue;
}
$entry = array("ID" => $u, "TYPE" => "group");
}
$entry["RIGHT"] = $rightString;
$entry["PASSWORD"] = isset($httpVars[PARAM_USER_PASS_PREFIX . $index]) ? $httpVars[PARAM_USER_PASS_PREFIX . $index] : "";
if ($this->watcher !== false) {
$entry["WATCH"] = $uWatch;
}
if ($entry["TYPE"] == "user") {
$users[$entry["ID"]] = $entry;
} else {
if ($entry["ID"] == "AJXP_GRP_/") {
$entry["ID"] = "AJXP_GRP_" . AuthService::filterBaseGroup("/");
}
$groups[$entry["ID"]] = $entry;
}
$index++;
}
}