本文整理汇总了PHP中AuthService::userExists方法的典型用法代码示例。如果您正苦于以下问题:PHP AuthService::userExists方法的具体用法?PHP AuthService::userExists怎么用?PHP AuthService::userExists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AuthService
的用法示例。
在下文中一共展示了AuthService::userExists方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: filter
/**
* 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|String $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) {
if (is_string($resolveUser)) {
$resolveUserId = $resolveUser;
} else {
$resolveUserId = $resolveUser->getId();
}
$value = str_replace("AJXP_USER", $resolveUserId, $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) {
if (is_string($resolveUser) && AuthService::userExists($resolveUser)) {
$loggedUser = ConfService::getConfStorageImpl()->createUserObject($resolveUser);
} else {
$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;
}
示例2: tryToLogUser
function tryToLogUser(&$httpVars, $isLast = false)
{
$localHttpLogin = $_SERVER["REMOTE_USER"];
$localHttpPassw = isset($_SERVER['PHP_AUTH_PW']) ? $_SERVER['PHP_AUTH_PW'] : "";
if (!isset($localHttpLogin)) {
return false;
}
if (!AuthService::userExists($localHttpLogin) && $this->pluginConf["CREATE_USER"] === true) {
AuthService::createUser($localHttpLogin, $localHttpPassw, isset($this->pluginConf["AJXP_ADMIN"]) && $this->pluginConf["AJXP_ADMIN"] == $localHttpLogin);
}
$res = AuthService::logUser($localHttpLogin, $localHttpPassw, true);
if ($res > 0) {
return true;
}
return false;
}
示例3: receiveAction
public function receiveAction($action, $httpVars, $filesVars)
{
$provider = $this->getFilteredOption("AVATAR_PROVIDER");
$type = $this->getFilteredOption("GRAVATAR_TYPE");
if ($action == "get_avatar_url") {
$url = "";
$suffix = "";
switch ($provider) {
case "gravatar":
default:
if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') {
$url = "https://secure.gravatar.com";
} else {
$url = "http://www.gravatar.com";
}
$url .= "/avatar/";
$suffix .= "?s=80&r=g&d=" . $type;
break;
case "libravatar":
$url = "";
// Federated Servers are not supported here without libravatar.org. Should query DNS server first.
if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') {
$url = "https://seccdn.libravatar.org";
} else {
$url = "http://cdn.libravatar.org";
}
$url .= "/avatar/";
$suffix = "?s=80&d=" . $type;
break;
}
if (isset($httpVars["userid"])) {
$userid = $httpVars["userid"];
if (AuthService::usersEnabled() && AuthService::userExists($userid)) {
$confDriver = ConfService::getConfStorageImpl();
$user = $confDriver->createUserObject($userid);
$userEmail = $user->personalRole->filterParameterValue("core.conf", "email", AJXP_REPO_SCOPE_ALL, "");
if (!empty($userEmail)) {
$url .= md5(strtolower(trim($userEmail)));
}
}
}
$url .= $suffix;
print $url;
}
}
示例4: getDigestHash
public function getDigestHash($realm, $username)
{
if (!AuthService::userExists($username)) {
return false;
}
$confDriver = ConfService::getConfStorageImpl();
$user = $confDriver->createUserObject($username);
$webdavData = $user->getPref("AJXP_WEBDAV_DATA");
if (empty($webdavData) || !isset($webdavData["ACTIVE"]) || $webdavData["ACTIVE"] !== true || !isset($webdavData["PASS"]) && !isset($webdavData["HA1"])) {
return false;
}
if (isset($webdavData["HA1"])) {
return $webdavData["HA1"];
} else {
$pass = $this->_decodePassword($webdavData["PASS"], $username);
return md5("{$username}:{$realm}:{$pass}");
}
}
示例5: actionReceive
protected function actionReceive($parameters)
{
$targetUser = \AJXP_Utils::sanitize($parameters["shareWith"], AJXP_SANITIZE_EMAILCHARS);
if (!\AuthService::userExists($targetUser)) {
throw new UserNotFoundException();
}
$token = \AJXP_Utils::sanitize($parameters["token"], AJXP_SANITIZE_ALPHANUM);
$remoteId = \AJXP_Utils::sanitize($parameters["remoteId"], AJXP_SANITIZE_ALPHANUM);
$documentName = \AJXP_Utils::sanitize($parameters["name"], AJXP_SANITIZE_FILENAME);
$sender = \AJXP_Utils::sanitize($parameters["owner"], AJXP_SANITIZE_EMAILCHARS);
$remote = $parameters["remote"];
$testParts = parse_url($remote);
if (!is_array($testParts) || empty($testParts["scheme"]) || empty($testParts["host"])) {
throw new InvalidArgumentsException();
}
$endpoints = OCSClient::findEndpointsForURL($remote);
$share = new RemoteShare();
$share->setUser($targetUser);
$share->setOcsRemoteId($remoteId);
$share->setOcsToken($token);
$share->setDocumentName($documentName);
$share->setSender($sender);
$share->setReceptionDate(time());
$share->setStatus(OCS_INVITATION_STATUS_PENDING);
$share->setHost(rtrim($remote, '/'));
$share->setOcsServiceUrl(rtrim($remote, '/') . $endpoints['share']);
$share->setOcsDavUrl(rtrim($remote, '/') . $endpoints['webdav']);
$share->pingRemoteDAVPoint();
$store = new SQLStore();
$newShare = $store->storeRemoteShare($share);
$response = $this->buildResponse("ok", 200, "Successfully received share, waiting for user response.", array("id" => $newShare->getId()));
$this->sendResponse($response, $this->getFormat($parameters));
$userRole = \AuthService::getRole("AJXP_USR_/" . $targetUser);
if ($userRole !== false) {
// Artificially "touch" user role
// to force repositories reload if he is logged in
\AuthService::updateRole($userRole);
}
}
示例6: switch
}
if ($_SERVER['PHP_SELF'] != $authPlug->getOption("LOGIN_URL")) {
$plugInAction = "WRONG_URL";
}
} else {
if ($secret != $authPlug->getOption("SECRET")) {
$plugInAction = "WRONG_SECRET";
}
}
switch ($plugInAction) {
case 'login':
$login = $AJXP_GLUE_GLOBALS["login"];
$autoCreate = $AJXP_GLUE_GLOBALS["autoCreate"];
if (is_array($login)) {
$newSession = new SessionSwitcher("AjaXplorer");
if ($autoCreate && !AuthService::userExists($login["name"])) {
$isAdmin = isset($login["right"]) && $login["right"] == "admin";
AuthService::createUser($login["name"], $login["password"], $isAdmin);
}
if (isset($AJXP_GLUE_GLOBALS["checkPassord"]) && $AJXP_GLUE_GLOBALS["checkPassord"] === TRUE) {
$result = AuthService::logUser($login["name"], $login["password"], false, false, -1);
} else {
$result = AuthService::logUser($login["name"], $login["password"], true);
}
// Update default rights (this could go in the trunk...)
if ($result == 1) {
$userObject = AuthService::getLoggedUser();
if ($userObject->isAdmin()) {
AuthService::updateAdminRights($userObject);
} else {
AuthService::updateDefaultRights($userObject);
示例7: tryToLogUser
//.........这里部分代码省略.........
phpCAS::setNoCasServerValidation();
}
/**
* Debug
*/
if ($this->cas_debug_mode) {
// logfile name by date:
$today = getdate();
$file_path = AJXP_DATA_PATH . '/logs/phpcas_' . $today['year'] . '-' . $today['month'] . '-' . $today['mday'] . '.txt';
empty($this->cas_debug_file) ? $file_path : ($file_path = $this->cas_debug_file);
phpCAS::setDebug($file_path);
}
phpCAS::forceAuthentication();
} else {
AJXP_Logger::error(__FUNCTION__, "Could not start phpCAS mode CLIENT, please verify the configuration", "");
return false;
}
break;
case PHPCAS_MODE_PROXY:
/**
* If in login page, user click on login via CAS, the page will be reload with manuallyredirectocas is set.
* Or force redirect to cas login page even the force redirect is set in configuration of this module
*
*/
if ($this->checkConfigurationForProxyMode()) {
AJXP_Logger::info(__FUNCTION__, "Start phpCAS mode Proxy: ", "sucessfully");
/**
* init phpCAS in mode proxy
*/
phpCAS::proxy(CAS_VERSION_2_0, $this->cas_server, $this->cas_port, $this->cas_uri, false);
if (!empty($this->cas_certificate_path)) {
phpCAS::setCasServerCACert($this->cas_certificate_path);
} else {
phpCAS::setNoCasServerValidation();
}
/**
* Debug
*/
if ($this->cas_debug_mode) {
// logfile name by date:
$today = getdate();
$file_path = AJXP_DATA_PATH . '/logs/phpcas_' . $today['year'] . '-' . $today['month'] . '-' . $today['mday'] . '.txt';
empty($this->cas_debug_file) ? $file_path : ($file_path = $this->cas_debug_file);
phpCAS::setDebug($file_path);
}
if (!empty($this->cas_setFixedCallbackURL)) {
phpCAS::setFixedCallbackURL($this->cas_setFixedCallbackURL);
}
//
/**
* PTG storage
*/
$this->setPTGStorage();
phpCAS::forceAuthentication();
/**
* Get proxy ticket (PT) for SAMBA to authentication at CAS via pam_cas
* In fact, we can use any other service. Of course, it should be enabled in CAS
*
*/
$err_code = null;
$serviceURL = $this->cas_proxied_service;
AJXP_Logger::debug(__FUNCTION__, "Try to get proxy ticket for service: ", $serviceURL);
$res = phpCAS::serviceSMB($serviceURL, $err_code);
if (!empty($res)) {
$_SESSION['PROXYTICKET'] = $res;
AJXP_Logger::info(__FUNCTION__, "Get Proxy ticket successfully ", "");
} else {
AJXP_Logger::info(__FUNCTION__, "Could not get Proxy ticket. ", "");
}
break;
} else {
AJXP_Logger::error(__FUNCTION__, "Could not start phpCAS mode PROXY, please verify the configuration", "");
return false;
}
default:
return false;
break;
}
AJXP_Logger::debug(__FUNCTION__, "Call phpCAS::getUser() after forceAuthentication ", "");
$cas_user = phpCAS::getUser();
if (!AuthService::userExists($cas_user) && $this->is_AutoCreateUser) {
AuthService::createUser($cas_user, openssl_random_pseudo_bytes(20));
}
if (AuthService::userExists($cas_user)) {
$res = AuthService::logUser($cas_user, "", true);
if ($res > 0) {
AJXP_Safe::storeCredentials($cas_user, $_SESSION['PROXYTICKET']);
$_SESSION['LOGGED_IN_BY_CAS'] = true;
if (!empty($this->cas_additional_role)) {
$userObj = ConfService::getConfStorageImpl()->createUserObject($cas_user);
$roles = $userObj->getRoles();
$cas_RoleID = $this->cas_additional_role;
$userObj->addRole(AuthService::getRole($cas_RoleID, true));
AuthService::updateUser($userObj);
}
return true;
}
}
return false;
}
示例8: createSharedRepository
/**
* @param Array $httpVars
* @param Repository $repository
* @param AbstractAccessDriver $accessDriver
* @param null $uniqueUser
* @throws Exception
* @return int|Repository
*/
public function createSharedRepository($httpVars, $repository, $accessDriver, $uniqueUser = null)
{
// 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"] == "") {
return 100;
}
$foldersharing = $this->getFilteredOption("ENABLE_FOLDER_SHARING", $this->repository->getId());
if (isset($foldersharing) && $foldersharing === false) {
return 103;
}
$loggedUser = AuthService::getLoggedUser();
$actRights = $loggedUser->mergedRole->listActionsStatesFor($repository);
if (isset($actRights["share"]) && $actRights["share"] === false) {
return 103;
}
$users = array();
$uRights = array();
$uPasses = array();
$groups = array();
$index = 0;
$prefix = $this->getFilteredOption("SHARED_USERS_TMP_PREFIX", $this->repository->getId());
while (isset($httpVars["user_" . $index])) {
$eType = $httpVars["entry_type_" . $index];
$rightString = ($httpVars["right_read_" . $index] == "true" ? "r" : "") . ($httpVars["right_write_" . $index] == "true" ? "w" : "");
if ($this->watcher !== false) {
$uWatch = $httpVars["right_watch_" . $index] == "true" ? true : false;
}
if (empty($rightString)) {
$index++;
continue;
}
if ($eType == "user") {
$u = AJXP_Utils::decodeSecureMagic($httpVars["user_" . $index], AJXP_SANITIZE_EMAILCHARS);
if (!AuthService::userExists($u) && !isset($httpVars["user_pass_" . $index])) {
$index++;
continue;
} else {
if (AuthService::userExists($u) && isset($httpVars["user_pass_" . $index])) {
throw new Exception("User {$u} already exists, please choose another name.");
}
}
if (!AuthService::userExists($u, "r") && !empty($prefix) && strpos($u, $prefix) !== 0) {
$u = $prefix . $u;
}
$users[] = $u;
} else {
$u = AJXP_Utils::decodeSecureMagic($httpVars["user_" . $index]);
if (strpos($u, "/AJXP_TEAM/") === 0) {
$confDriver = ConfService::getConfStorageImpl();
if (method_exists($confDriver, "teamIdToUsers")) {
$teamUsers = $confDriver->teamIdToUsers(str_replace("/AJXP_TEAM/", "", $u));
foreach ($teamUsers as $userId) {
$users[] = $userId;
$uRights[$userId] = $rightString;
if ($this->watcher !== false) {
$uWatches[$userId] = $uWatch;
}
}
}
$index++;
continue;
} else {
$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;
}
}
}
//.........这里部分代码省略.........
示例9: switchAction
//.........这里部分代码省略.........
if (!isset($httpVars["role_id"]) || !isset($httpVars["default_value"])) {
AJXP_XMLWriter::header();
AJXP_XMLWriter::sendMessage(null, $mess["ajxp_conf.61"]);
AJXP_XMLWriter::close();
return;
}
$role = AuthService::getRole($httpVars["role_id"]);
if ($role === false) {
throw new Exception("Cannot find role!");
}
$role->setDefault($httpVars["default_value"] == "true");
AuthService::updateRole($role);
AJXP_XMLWriter::header("admin_data");
print AJXP_XMLWriter::writeRoleRepositoriesData($role);
AJXP_XMLWriter::close("admin_data");
break;
case "get_custom_params":
$confStorage = ConfService::getConfStorageImpl();
AJXP_XMLWriter::header("admin_data");
$confDriver = ConfService::getConfStorageImpl();
$customData = $confDriver->options['CUSTOM_DATA'];
if (is_array($customData) && count($customData) > 0) {
print "<custom_data>";
foreach ($customData as $custName => $custValue) {
print "<param name=\"{$custName}\" type=\"string\" label=\"{$custValue}\" description=\"\" value=\"\"/>";
}
print "</custom_data>";
}
AJXP_XMLWriter::close("admin_data");
break;
case "edit_user":
$confStorage = ConfService::getConfStorageImpl();
$userId = $httpVars["user_id"];
if (!AuthService::userExists($userId)) {
throw new Exception("Invalid user id!");
}
$userObject = $confStorage->createUserObject($userId);
//print_r($userObject);
AJXP_XMLWriter::header("admin_data");
AJXP_XMLWriter::sendUserData($userObject, true);
// Add CUSTOM USER DATA
$confDriver = ConfService::getConfStorageImpl();
$customData = $confDriver->options['CUSTOM_DATA'];
if (is_array($customData) && count($customData) > 0) {
$userCustom = $userObject->getPref("CUSTOM_PARAMS");
print "<custom_data>";
foreach ($customData as $custName => $custValue) {
$value = isset($userCustom[$custName]) ? $userCustom[$custName] : '';
print "<param name=\"{$custName}\" type=\"string\" label=\"{$custValue}\" description=\"\" value=\"{$value}\"/>";
}
print "</custom_data>";
}
// Add WALLET DATA : DEFINITIONS AND VALUES
print "<drivers>";
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>";
}
示例10: _performAuthentication
protected function _performAuthentication($data, $method = "BASIC")
{
if (!AuthService::userExists($data->username)) {
AJXP_Logger::debug("not exists! " . $data->username);
return false;
}
$confDriver = ConfService::getConfStorageImpl();
$user = $confDriver->createUserObject($data->username);
$webdavData = $user->getPref("AJXP_WEBDAV_DATA");
if (empty($webdavData) || !isset($webdavData["ACTIVE"]) || $webdavData["ACTIVE"] !== true || !isset($webdavData["PASS"])) {
return false;
}
//$webdavData = array("PASS" => $this->_encodePassword("admin", "admin"));
$passCheck = false;
if ($method == "BASIC") {
if ($this->_decodePassword($webdavData["PASS"], $data->username) == $data->password) {
$passCheck = true;
}
} else {
if ($method == "DIGEST") {
$passCheck = $this->checkDigest($data, $this->_decodePassword($webdavData["PASS"], $data->username));
}
}
if ($passCheck) {
AuthService::logUser($data->username, null, true);
$res = $this->updateCurrentUserRights(AuthService::getLoggedUser());
if ($res === false) {
return false;
}
if (ConfService::getCoreConf("SESSION_SET_CREDENTIALS", "auth")) {
AJXP_Safe::storeCredentials($data->username, $this->_decodePassword($webdavData["PASS"], $data->username));
}
return true;
} else {
return false;
}
}
示例11: getAuthorLabel
public function getAuthorLabel()
{
if (array_key_exists($this->getAuthor(), self::$usersCaches)) {
if (self::$usersCaches[$this->getAuthor()] != 'AJXP_USER_DONT_EXISTS') {
$uLabel = self::$usersCaches[$this->getAuthor()];
}
} else {
if (AuthService::userExists($this->getAuthor())) {
$obj = ConfService::getConfStorageImpl()->createUserObject($this->getAuthor());
$uLabel = $obj->personalRole->filterParameterValue("core.conf", "USER_DISPLAY_NAME", AJXP_REPO_SCOPE_ALL, "");
self::$usersCaches[$this->getAuthor()] = $uLabel;
} else {
self::$usersCaches[$this->getAuthor()] = 'AJXP_USER_DONT_EXISTS';
}
}
if (!empty($uLabel)) {
return $uLabel;
} else {
return $this->getAuthor();
}
}
示例12: editTeamUsers
private function editTeamUsers($teamId, $users, $teamLabel = null)
{
if ($teamLabel == null) {
$res = dibi::query("SELECT [team_label] FROM [ajxp_user_teams] WHERE [team_id] = %s AND [owner_id] = %s", $teamId, AuthService::getLoggedUser()->getId());
$teamLabel = $res->fetchSingle();
}
// Remove old users
dibi::query("DELETE FROM [ajxp_user_teams] WHERE [team_id] = %s", $teamId);
foreach ($users as $userId) {
if (!AuthService::userExists($userId, "r")) {
continue;
}
dibi::query("INSERT INTO [ajxp_user_teams] ([team_id],[user_id],[team_label],[owner_id]) VALUES (%s,%s,%s,%s)", $teamId, $userId, $teamLabel, AuthService::getLoggedUser()->getId());
}
}
示例13: replaceVars
protected function replaceVars($tplString, $mess, $rich = true)
{
$tplString = SystemTextEncoding::fromUTF8($tplString);
$repoId = $this->getNode()->getRepositoryId();
if (ConfService::getRepositoryById($repoId) != null) {
$repoLabel = ConfService::getRepositoryById($repoId)->getDisplay();
} else {
$repoLabel = "Repository";
}
$uLabel = "";
if (array_key_exists($this->getAuthor(), self::$usersCaches)) {
$uLabel = self::$usersCaches[$this->getAuthor()];
} else {
if (strstr($tplString, "AJXP_USER") !== false && AuthService::userExists($this->getAuthor())) {
$obj = ConfService::getConfStorageImpl()->createUserObject($this->getAuthor());
$uLabel = $obj->personalRole->filterParameterValue("core.conf", "USER_DISPLAY_NAME", AJXP_REPO_SCOPE_ALL, "");
self::$usersCaches[$this->getAuthor()] = $uLabel;
}
}
if (empty($uLabel)) {
$uLabel = $this->getAuthor();
}
$em = $rich ? "<em>" : "";
$me = $rich ? "</em>" : "";
$replaces = array("AJXP_NODE_PATH" => $em . $this->getRoot($this->getNode()->getPath()) . $me, "AJXP_NODE_LABEL" => $em . $this->getNode()->getLabel() . $me, "AJXP_PARENT_PATH" => $em . $this->getRoot(dirname($this->getNode()->getPath())) . $me, "AJXP_PARENT_LABEL" => $em . $this->getRoot(basename(dirname($this->getNode()->getPath()))) . $me, "AJXP_REPOSITORY_ID" => $em . $repoId . $me, "AJXP_REPOSITORY_LABEL" => $em . $repoLabel . $me, "AJXP_LINK" => $this->getMainLink(), "AJXP_USER" => $uLabel, "AJXP_DATE" => SystemTextEncoding::fromUTF8(AJXP_Utils::relativeDate($this->getDate(), $mess)));
if ($replaces["AJXP_NODE_LABEL"] == $em . $me) {
$replaces["AJXP_NODE_LABEL"] = $em . "[" . $replaces["AJXP_REPOSITORY_LABEL"] . "]" . $me;
}
if ($replaces["AJXP_PARENT_LABEL"] == $em . $me) {
$replaces["AJXP_PARENT_LABEL"] = $em . "[" . $replaces["AJXP_REPOSITORY_LABEL"] . "]" . $me;
}
if ((strstr($tplString, "AJXP_TARGET_FOLDER") !== false || strstr($tplString, "AJXP_SOURCE_FOLDER")) && isset($this->secondaryNode)) {
$p = $this->secondaryNode->getPath();
if ($this->secondaryNode->isLeaf()) {
$p = $this->getRoot(dirname($p));
}
$replaces["AJXP_TARGET_FOLDER"] = $replaces["AJXP_SOURCE_FOLDER"] = $em . $p . $me;
}
if ((strstr($tplString, "AJXP_TARGET_LABEL") !== false || strstr($tplString, "AJXP_SOURCE_LABEL") !== false) && isset($this->secondaryNode)) {
$replaces["AJXP_TARGET_LABEL"] = $replaces["AJXP_SOURCE_LABEL"] = $em . $this->secondaryNode->getLabel() . $me;
}
return str_replace(array_keys($replaces), array_values($replaces), $tplString);
}
示例14: 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);
//.........这里部分代码省略.........
示例15: getWatchesOnNode
public function getWatchesOnNode($node, $watchType)
{
$IDS = array();
$currentUserId = "shared";
if (AuthService::getLoggedUser() != null) {
$currentUserId = AuthService::getLoggedUser()->getId();
}
$meta = $this->metaStore->retrieveMetadata($node, self::$META_WATCH_NAMESPACE, false, AJXP_METADATA_SCOPE_REPOSITORY);
if (AuthService::getLoggedUser() != null) {
$usersMeta = $this->metaStore->retrieveMetadata($node, self::$META_WATCH_USERS_NAMESPACE, false, AJXP_METADATA_SCOPE_REPOSITORY);
if ($watchType == self::$META_WATCH_CHANGE && isset($usersMeta[self::$META_WATCH_USERS_CHANGE])) {
$usersMeta = $usersMeta[self::$META_WATCH_USERS_CHANGE];
} else {
if ($watchType == self::$META_WATCH_READ && isset($usersMeta[self::$META_WATCH_USERS_READ])) {
$usersMeta = $usersMeta[self::$META_WATCH_USERS_READ];
} else {
$usersMeta = null;
}
}
}
if (isset($meta) && is_array($meta)) {
foreach ($meta as $id => $type) {
if ($type == $watchType || $type == self::$META_WATCH_BOTH) {
$IDS[] = $id;
}
}
}
if (isset($usersMeta) && is_array($usersMeta)) {
foreach ($usersMeta as $id => $targetUsers) {
if (in_array($currentUserId, $targetUsers)) {
$IDS[] = $id;
}
}
}
if (count($IDS)) {
$changes = false;
foreach ($IDS as $index => $id) {
if ($currentUserId == $id && !AJXP_SERVER_DEBUG) {
// In non-debug mode, do not send notifications to watcher!
unset($IDS[$index]);
continue;
}
if (!AuthService::userExists($id)) {
$changes = true;
unset($meta[$id]);
unset($IDS[$index]);
}
}
if ($changes) {
$this->metaStore->setMetadata($node, self::$META_WATCH_NAMESPACE, $meta, false, AJXP_METADATA_SCOPE_REPOSITORY);
}
}
return $IDS;
}