本文整理汇总了PHP中ConfService::getCurrentRepositoryId方法的典型用法代码示例。如果您正苦于以下问题:PHP ConfService::getCurrentRepositoryId方法的具体用法?PHP ConfService::getCurrentRepositoryId怎么用?PHP ConfService::getCurrentRepositoryId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConfService
的用法示例。
在下文中一共展示了ConfService::getCurrentRepositoryId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: switchUserToActiveRepository
/**
* @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;
}
示例2: header
}
//Set language
$loggedUser = AuthService::getLoggedUser();
if ($loggedUser != null && $loggedUser->getPref("lang") != "") {
ConfService::setLanguage($loggedUser->getPref("lang"));
} else {
if (isset($_COOKIE["AJXP_lang"])) {
ConfService::setLanguage($_COOKIE["AJXP_lang"]);
}
}
//------------------------------------------------------------
// SPECIAL HANDLING FOR FANCY UPLOADER RIGHTS FOR THIS ACTION
//------------------------------------------------------------
if (AuthService::usersEnabled()) {
$loggedUser = AuthService::getLoggedUser();
if ($action == "upload" && ($loggedUser == null || !$loggedUser->canWrite(ConfService::getCurrentRepositoryId() . "")) && isset($_FILES['Filedata'])) {
header('HTTP/1.0 ' . '410 Not authorized');
die('Error 410 Not authorized!');
}
}
// THIS FIRST DRIVERS DO NOT NEED ID CHECK
//$ajxpDriver = AJXP_PluginsService::findPlugin("gui", "ajax");
$authDriver = ConfService::getAuthDriverImpl();
// DRIVERS BELOW NEED IDENTIFICATION CHECK
if (!AuthService::usersEnabled() || ConfService::getCoreConf("ALLOW_GUEST_BROWSING", "auth") || AuthService::getLoggedUser() != null) {
$confDriver = ConfService::getConfStorageImpl();
$Driver = ConfService::loadRepositoryDriver();
}
AJXP_PluginsService::getInstance()->initActivePlugins();
require_once AJXP_BIN_FOLDER . "/class.AJXP_Controller.php";
$xmlResult = AJXP_Controller::findActionAndApply($action, array_merge($_GET, $_POST), $_FILES);
示例3: switchAction
public function switchAction($action, $httpVars, $fileVars)
{
if (!isset($this->actions[$action])) {
return;
}
$xmlBuffer = "";
foreach ($httpVars as $getName => $getValue) {
${$getName} = AJXP_Utils::securePath($getValue);
}
if (isset($dir) && $action != "upload") {
$dir = SystemTextEncoding::fromUTF8($dir);
}
$mess = ConfService::getMessages();
switch ($action) {
//------------------------------------
// SWITCH THE ROOT REPOSITORY
//------------------------------------
case "switch_repository":
if (!isset($repository_id)) {
break;
}
$dirList = ConfService::getRepositoriesList();
/** @var $repository_id string */
if (!isset($dirList[$repository_id])) {
$errorMessage = "Trying to switch to an unkown repository!";
break;
}
ConfService::switchRootDir($repository_id);
// Load try to init the driver now, to trigger an exception
// if it's not loading right.
ConfService::loadRepositoryDriver();
if (AuthService::usersEnabled() && AuthService::getLoggedUser() != null) {
$user = AuthService::getLoggedUser();
$activeRepId = ConfService::getCurrentRepositoryId();
$user->setArrayPref("history", "last_repository", $activeRepId);
$user->save("user");
}
//$logMessage = "Successfully Switched!";
$this->logInfo("Switch Repository", array("rep. id" => $repository_id));
break;
//------------------------------------
// SEND XML REGISTRY
//------------------------------------
//------------------------------------
// SEND XML REGISTRY
//------------------------------------
case "get_xml_registry":
case "state":
$regDoc = AJXP_PluginsService::getXmlRegistry();
$changes = AJXP_Controller::filterRegistryFromRole($regDoc);
if ($changes) {
AJXP_PluginsService::updateXmlRegistry($regDoc);
}
$clone = $regDoc->cloneNode(true);
$clonePath = new DOMXPath($clone);
$serverCallbacks = $clonePath->query("//serverCallback|hooks");
foreach ($serverCallbacks as $callback) {
$callback->parentNode->removeChild($callback);
}
$xPath = '';
if (isset($httpVars["xPath"])) {
$xPath = ltrim(AJXP_Utils::securePath($httpVars["xPath"]), "/");
}
if (!empty($xPath)) {
$nodes = $clonePath->query($xPath);
if ($httpVars["format"] == "json") {
$data = AJXP_XMLWriter::xmlToArray($nodes->item(0));
HTMLWriter::charsetHeader("application/json");
echo json_encode($data);
} else {
AJXP_XMLWriter::header("ajxp_registry_part", array("xPath" => $xPath));
if ($nodes->length) {
print AJXP_XMLWriter::replaceAjxpXmlKeywords($clone->saveXML($nodes->item(0)));
}
AJXP_XMLWriter::close("ajxp_registry_part");
}
} else {
AJXP_Utils::safeIniSet("zlib.output_compression", "4096");
if ($httpVars["format"] == "json") {
$data = AJXP_XMLWriter::xmlToArray($clone);
HTMLWriter::charsetHeader("application/json");
echo json_encode($data);
} else {
header('Content-Type: application/xml; charset=UTF-8');
print AJXP_XMLWriter::replaceAjxpXmlKeywords($clone->saveXML());
}
}
break;
//------------------------------------
// BOOKMARK BAR
//------------------------------------
//------------------------------------
// BOOKMARK BAR
//------------------------------------
case "get_bookmarks":
$bmUser = null;
if (AuthService::usersEnabled() && AuthService::getLoggedUser() != null) {
$bmUser = AuthService::getLoggedUser();
} else {
if (!AuthService::usersEnabled()) {
//.........这里部分代码省略.........
示例4: getBookmarks
public function getBookmarks()
{
if (isset($this->bookmarks) && isset($this->bookmarks[ConfService::getCurrentRepositoryId()])) {
return $this->bookmarks[ConfService::getCurrentRepositoryId()];
}
return array();
}
示例5: publishPermissionsMask
/**
* @param string $actionName
* @param array $httpVars
* @param array $fileVars
*/
public function publishPermissionsMask($actionName, $httpVars, $fileVars)
{
$mask = array();
HTMLWriter::charsetHeader("application/json");
if (!AuthService::usersEnabled() || AuthService::getLoggedUser() == null) {
print json_encode($mask);
return;
}
$repoId = ConfService::getCurrentRepositoryId();
$role = AuthService::getLoggedUser()->mergedRole;
if ($role->hasMask($repoId)) {
$fullMask = $role->getMask($repoId);
foreach ($fullMask->flattenTree() as $path => $permission) {
// Do not show if "deny".
if ($permission->denies()) {
continue;
}
$mask[$path] = array("read" => $permission->canRead(), "write" => $permission->canWrite());
}
}
print json_encode($mask);
return;
}
示例6: file_put_contents
if (!$res) {
AuthService::disconnect();
$requireAuth = true;
}
*/
}
if (isset($loggingResult) && $loggingResult != 1) {
AJXP_XMLWriter::header();
AJXP_XMLWriter::loggingResult($loggingResult, false, false, "");
AJXP_XMLWriter::close();
if ($optStatusFile) {
file_put_contents($optStatusFile, "ERROR:No user logged");
}
}
} else {
AJXP_Logger::debug(ConfService::getCurrentRepositoryId());
}
//Set language
$loggedUser = AuthService::getLoggedUser();
if ($loggedUser != null && $loggedUser->getPref("lang") != "") {
ConfService::setLanguage($loggedUser->getPref("lang"));
} else {
if (isset($_COOKIE["AJXP_lang"])) {
ConfService::setLanguage($_COOKIE["AJXP_lang"]);
}
}
$mess = ConfService::getMessages();
// THIS FIRST DRIVERS DO NOT NEED ID CHECK
//$ajxpDriver = AJXP_PluginsService::findPlugin("gui", "ajax");
$authDriver = ConfService::getAuthDriverImpl();
// DRIVERS BELOW NEED IDENTIFICATION CHECK
示例7: clientChannelMethod
/**
* @param $action
* @param $httpVars
* @param $fileVars
*
*/
public function clientChannelMethod($action, $httpVars, $fileVars)
{
if (!$this->msgExchanger) {
return;
}
switch ($action) {
case "client_register_channel":
$this->msgExchanger->suscribeToChannel($httpVars["channel"], $httpVars["client_id"]);
break;
case "client_unregister_channel":
$this->msgExchanger->unsuscribeFromChannel($httpVars["channel"], $httpVars["client_id"]);
break;
case "client_consume_channel":
if (AuthService::usersEnabled()) {
$user = AuthService::getLoggedUser();
if ($user == null) {
AJXP_XMLWriter::header();
AJXP_XMLWriter::requireAuth();
AJXP_XMLWriter::close();
return;
}
$GROUP_PATH = $user->getGroupPath();
if ($GROUP_PATH == null) {
$GROUP_PATH = false;
}
$uId = $user->getId();
} else {
$GROUP_PATH = '/';
$uId = 'shared';
}
$currentRepository = ConfService::getCurrentRepositoryId();
$currentRepoMasks = array();
$regexp = null;
AJXP_Controller::applyHook("role.masks", array($currentRepository, &$currentRepoMasks, AJXP_Permission::READ));
if (count($currentRepoMasks)) {
$regexps = array();
foreach ($currentRepoMasks as $path) {
$regexps[] = '^' . preg_quote($path, '/');
}
$regexp = '/' . implode("|", $regexps) . '/';
}
$channelRepository = str_replace("nodes:", "", $httpVars["channel"]);
if ($channelRepository != $currentRepository) {
AJXP_XMLWriter::header();
echo "<require_registry_reload repositoryId=\"{$currentRepository}\"/>";
AJXP_XMLWriter::close();
return;
}
$data = $this->msgExchanger->consumeInstantChannel($httpVars["channel"], $httpVars["client_id"], $uId, $GROUP_PATH);
if (count($data)) {
AJXP_XMLWriter::header();
ksort($data);
foreach ($data as $messageObject) {
if (isset($regexp) && isset($messageObject->nodePathes)) {
$pathIncluded = false;
foreach ($messageObject->nodePathes as $nodePath) {
if (preg_match($regexp, $nodePath)) {
$pathIncluded = true;
break;
}
}
if (!$pathIncluded) {
continue;
}
}
echo $messageObject->content;
}
AJXP_XMLWriter::close();
}
break;
default:
break;
}
}
示例8: httpPut
//.........这里部分代码省略.........
protected function httpPut($uri)
{
$body = $this->httpRequest->getBody();
// Intercepting Content-Range
if ($this->httpRequest->getHeader('Content-Range')) {
/**
Content-Range is dangerous for PUT requests: PUT per definition
stores a full resource. draft-ietf-httpbis-p2-semantics-15 says
in section 7.6:
An origin server SHOULD reject any PUT request that contains a
Content-Range header field, since it might be misinterpreted as
partial content (or might be partial content that is being mistakenly
PUT as a full representation). Partial content updates are possible
by targeting a separately identified resource with state that
overlaps a portion of the larger resource, or by using a different
method that has been specifically defined for partial updates (for
example, the PATCH method defined in [RFC5789]).
This clarifies RFC2616 section 9.6:
The recipient of the entity MUST NOT ignore any Content-*
(e.g. Content-Range) headers that it does not understand or implement
and MUST return a 501 (Not Implemented) response in such cases.
OTOH is a PUT request with a Content-Range currently the only way to
continue an aborted upload request and is supported by curl, mod_dav,
Tomcat and others. Since some clients do use this feature which results
in unexpected behaviour (cf PEAR::HTTP_WebDAV_Client 1.0.1), we reject
all PUT requests with a Content-Range for now.
*/
throw new Exception\NotImplemented('PUT with Content-Range is not allowed.');
}
// Intercepting the Finder problem
if (($expected = $this->httpRequest->getHeader('X-Expected-Entity-Length')) && $expected > 0) {
/**
Many webservers will not cooperate well with Finder PUT requests,
because it uses 'Chunked' transfer encoding for the request body.
The symptom of this problem is that Finder sends files to the
server, but they arrive as 0-length files in PHP.
If we don't do anything, the user might think they are uploading
files successfully, but they end up empty on the server. Instead,
we throw back an error if we detect this.
The reason Finder uses Chunked, is because it thinks the files
might change as it's being uploaded, and therefore the
Content-Length can vary.
Instead it sends the X-Expected-Entity-Length header with the size
of the file at the very start of the request. If this header is set,
but we don't get a request body we will fail the request to
protect the end-user.
*/
// Only reading first byte
$firstByte = fread($body, 1);
if (strlen($firstByte) !== 1) {
throw new Exception\Forbidden('This server is not compatible with OS/X finder. Consider using a different WebDAV client or webserver.');
}
// The body needs to stay intact, so we copy everything to a
// temporary stream.
$newBody = fopen('php://temp', 'r+');
fwrite($newBody, $firstByte);
stream_copy_to_stream($body, $newBody);
rewind($newBody);
$body = $newBody;
}
if ($this->tree->nodeExists($uri)) {
$node = $this->tree->getNodeForPath($uri);
// Checking If-None-Match and related headers.
if (!$this->checkPreconditions()) {
return;
}
// If the node is a collection, we'll deny it
if (!$node instanceof IFile) {
throw new Exception\Conflict('PUT is not allowed on non-files.');
}
if (!$this->broadcastEvent('beforeWriteContent', array($uri, $node, &$body))) {
return false;
}
$etag = $node->put($body);
$this->broadcastEvent('afterWriteContent', array($uri, $node));
$this->httpResponse->setHeader('Content-Length', '0');
if ($etag) {
$this->httpResponse->setHeader('ETag', $etag);
}
$this->httpResponse->sendStatus(204);
} else {
$etag = null;
// If we got here, the resource didn't exist yet.
if (!$this->createFile($this->getRequestUri(), $body, $etag)) {
// For one reason or another the file was not created.
return;
}
$this->httpResponse->setHeader('Content-Length', '0');
if ($etag) {
$this->httpResponse->setHeader('ETag', $etag);
}
$this->httpResponse->sendStatus(201);
}
$repositories = \ConfService::getRepositoriesList("user");
\AJXP_Logger::info(__CLASS__, "Upload", array("files" => $repositories[\ConfService::getCurrentRepositoryId()]->getSlug() . "/" . $uri));
}
示例9: loadUserFeed
public function loadUserFeed($actionName, $httpVars, $fileVars)
{
if (!$this->eventStore) {
return array();
}
$u = AuthService::getLoggedUser();
if ($u == null) {
if ($httpVars["format"] == "html") {
return array();
}
AJXP_XMLWriter::header();
AJXP_XMLWriter::close();
return array();
}
$userId = $u->getId();
$userGroup = $u->getGroupPath();
$authRepos = array();
$crtRepId = ConfService::getCurrentRepositoryId();
if (isset($httpVars["repository_id"]) && $u->mergedRole->canRead($httpVars["repository_id"])) {
$authRepos[] = $httpVars["repository_id"];
} else {
if (isset($httpVars["current_repository"])) {
$authRepos[] = $crtRepId;
} else {
$accessibleRepos = ConfService::getAccessibleRepositories(AuthService::getLoggedUser(), false, true, false);
$authRepos = array_keys($accessibleRepos);
}
}
$offset = isset($httpVars["offset"]) ? intval($httpVars["offset"]) : 0;
$limit = isset($httpVars["limit"]) ? intval($httpVars["limit"]) : 15;
if (!isset($httpVars["feed_type"]) || $httpVars["feed_type"] == "notif" || $httpVars["feed_type"] == "all") {
$res = $this->eventStore->loadEvents($authRepos, isset($httpVars["path"]) ? $httpVars["path"] : "", $userGroup, $offset, $limit, false, $userId);
} else {
$res = array();
}
$mess = ConfService::getMessages();
$format = "html";
if (isset($httpVars["format"])) {
$format = $httpVars["format"];
}
if ($format == "html") {
echo "<h2>" . $mess["notification_center.4"] . "</h2>";
echo "<ul class='notification_list'>";
} else {
if ($format == "json") {
$jsonNodes = array();
} else {
if ($format != 'array') {
AJXP_XMLWriter::header();
}
}
}
// APPEND USER ALERT IN THE SAME QUERY FOR NOW
if (!isset($httpVars["feed_type"]) || $httpVars["feed_type"] == "alert" || $httpVars["feed_type"] == "all") {
$this->loadUserAlerts("", array_merge($httpVars, array("skip_container_tags" => "true")), $fileVars);
}
restore_error_handler();
$index = 1;
foreach ($res as $n => $object) {
$args = $object->arguments;
$oldNode = isset($args[0]) ? $args[0] : null;
$newNode = isset($args[1]) ? $args[1] : null;
$copy = isset($args[2]) && $args[2] === true ? true : null;
$notif = $this->generateNotificationFromChangeHook($oldNode, $newNode, $copy, "unify");
if ($notif !== false && $notif->getNode() !== false) {
$notif->setAuthor($object->author);
$notif->setDate(intval($object->date));
if ($format == "html") {
$p = $notif->getNode()->getPath();
echo "<li data-ajxpNode='{$p}'>";
echo $notif->getDescriptionShort(true);
echo "</li>";
} else {
$node = $notif->getNode();
if ($node == null) {
$this->logInfo("Warning", "Empty node stored in notification " . $notif->getAuthor() . "/ " . $notif->getAction());
continue;
}
try {
$node->loadNodeInfo();
} catch (Exception $e) {
continue;
}
$node->event_description = ucfirst($notif->getDescriptionBlock()) . " " . $mess["notification.tpl.block.user_link"] . " " . $notif->getAuthorLabel();
$node->event_description_long = $notif->getDescriptionLong(true);
$node->event_date = SystemTextEncoding::fromUTF8(AJXP_Utils::relativeDate($notif->getDate(), $mess));
$node->short_date = AJXP_Utils::relativeDate($notif->getDate(), $mess, true);
$node->event_time = $notif->getDate();
$node->event_type = "notification";
$node->event_id = $object->event_id;
if ($node->getRepository() != null) {
$node->repository_id = '' . $node->getRepository()->getId();
if ($node->repository_id != $crtRepId && $node->getRepository()->getDisplay() != null) {
$node->event_repository_label = "[" . $node->getRepository()->getDisplay() . "]";
}
}
$node->event_author = $notif->getAuthor();
// Replace PATH, to make sure they will be distinct children of the loader node
$node->real_path = $node->getPath();
$node->setLabel(basename($node->getPath()));
//.........这里部分代码省略.........
示例10: switchAction
//.........这里部分代码省略.........
try {
AJXP_Controller::applyHook("node.before_change", array(&$currentNode, strlen($code)));
} catch (Exception $e) {
header("Content-Type:text/plain");
print $e->getMessage();
return;
}
if (!is_file($fileName) || !$this->isWriteable($fileName, "file")) {
header("Content-Type:text/plain");
print !$this->isWriteable($fileName, "file") ? "1001" : "1002";
return;
}
$fp = fopen($fileName, "w");
fputs($fp, $code);
fclose($fp);
clearstatcache(true, $fileName);
AJXP_Controller::applyHook("node.change", array($currentNode, $currentNode, false));
header("Content-Type:text/plain");
print $mess[115];
break;
//------------------------------------
// COPY / MOVE
//------------------------------------
//------------------------------------
// COPY / MOVE
//------------------------------------
case "copy":
case "move":
//throw new AJXP_Exception("", 113);
if ($selection->isEmpty()) {
throw new AJXP_Exception("", 113);
}
$loggedUser = AuthService::getLoggedUser();
if ($loggedUser != null && !$loggedUser->canWrite(ConfService::getCurrentRepositoryId())) {
throw new AJXP_Exception("You are not allowed to write", 207);
}
$success = $error = array();
$dest = AJXP_Utils::decodeSecureMagic($httpVars["dest"]);
$this->filterUserSelectionToHidden(array($httpVars["dest"]));
if ($selection->inZip()) {
// Set action to copy anycase (cannot move from the zip).
$action = "copy";
$this->extractArchive($dest, $selection, $error, $success);
} else {
$move = $action == "move" ? true : false;
if ($move && isset($httpVars["force_copy_delete"])) {
$move = false;
}
$this->copyOrMove($dest, $selection->getFiles(), $error, $success, $move);
}
if (count($error)) {
throw new AJXP_Exception(SystemTextEncoding::toUTF8(join("\n", $error)));
} else {
if (isset($httpVars["force_copy_delete"])) {
$errorMessage = $this->delete($selection->getFiles(), $logMessages);
if ($errorMessage) {
throw new AJXP_Exception(SystemTextEncoding::toUTF8($errorMessage));
}
$this->logInfo("Copy/Delete", array("files" => $this->addSlugToPath($selection), "destination" => $this->addSlugToPath($dest)));
} else {
$this->logInfo($action == "move" ? "Move" : "Copy", array("files" => $this->addSlugToPath($selection), "destination" => $this->addSlugToPath($dest)));
}
$logMessage = join("\n", $success);
}
if (!isset($nodesDiffs)) {
$nodesDiffs = $this->getNodesDiffArray();
示例11: loadUserFeed
public function loadUserFeed($actionName, $httpVars, $fileVars)
{
if (!$this->eventStore) {
return;
}
$u = AuthService::getLoggedUser();
if ($u == null) {
if ($httpVars["format"] == "html") {
return;
}
AJXP_XMLWriter::header();
AJXP_XMLWriter::close();
return;
}
$userId = $u->getId();
$userGroup = $u->getGroupPath();
$authRepos = array();
$crtRepId = ConfService::getCurrentRepositoryId();
if (isset($httpVars["repository_id"]) && $u->mergedRole->canRead($httpVars["repository_id"])) {
$authRepos[] = $httpVars["repository_id"];
} else {
$acls = AuthService::getLoggedUser()->mergedRole->listAcls();
foreach ($acls as $repoId => $rightString) {
if ($rightString == "r" | $rightString == "rw") {
$authRepos[] = $repoId;
}
}
}
$offset = isset($httpVars["offset"]) ? intval($httpVars["offset"]) : 0;
$limit = isset($httpVars["limit"]) ? intval($httpVars["limit"]) : 15;
$res = $this->eventStore->loadEvents($authRepos, $userId, $userGroup, $offset, $limit, isset($httpVars["repository_id"]) ? false : true);
$mess = ConfService::getMessages();
$format = "html";
if (isset($httpVars["format"])) {
$format = $httpVars["format"];
}
if ($format == "html") {
echo "<h2>" . $mess["notification_center.4"] . "</h2>";
echo "<ul class='notification_list'>";
} else {
AJXP_XMLWriter::header();
}
// APPEND USER ALERT IN THE SAME QUERY FOR NOW
$this->loadUserAlerts("", array_merge($httpVars, array("skip_container_tags" => "true")), $fileVars);
restore_error_handler();
$index = 1;
foreach ($res as $n => $object) {
$args = $object->arguments;
$oldNode = isset($args[0]) ? $args[0] : null;
$newNode = isset($args[1]) ? $args[1] : null;
$copy = isset($args[2]) && $args[2] === true ? true : null;
$notif = $this->generateNotificationFromChangeHook($oldNode, $newNode, $copy, "unify");
if ($notif !== false && $notif->getNode() !== false) {
$notif->setAuthor($object->author);
$notif->setDate(intval($object->date));
if ($format == "html") {
$p = $notif->getNode()->getPath();
echo "<li data-ajxpNode='{$p}'>";
echo $notif->getDescriptionShort(true);
echo "</li>";
} else {
$node = $notif->getNode();
if ($node == null) {
$this->logInfo("Warning", "Empty node stored in notification " . $notif->getAuthor() . "/ " . $notif->getAction());
continue;
}
try {
$node->loadNodeInfo();
} catch (Exception $e) {
continue;
}
$node->event_description = ucfirst($notif->getDescriptionBlock()) . " " . $mess["notification.tpl.block.user_link"] . " " . $notif->getAuthor();
$node->event_description_long = $notif->getDescriptionLong(true);
$node->event_date = AJXP_Utils::relativeDate($notif->getDate(), $mess);
$node->event_id = $object->event_id;
if ($node->getRepository() != null) {
$node->repository_id = '' . $node->getRepository()->getId();
if ($node->repository_id != $crtRepId && $node->getRepository()->getDisplay() != null) {
$node->event_repository_label = "[" . $node->getRepository()->getDisplay() . "]";
}
}
$node->event_author = $notif->getAuthor();
// Replace PATH, to make sure they will be distinct children of the loader node
$node->real_path = $node->getPath();
$node->setLabel(basename($node->getPath()));
$url = parse_url($node->getUrl());
$node->setUrl($url["scheme"] . "://" . $url["host"] . "/notification_" . $index);
$index++;
AJXP_XMLWriter::renderAjxpNode($node);
}
}
}
if ($format == "html") {
echo "</ul>";
} else {
AJXP_XMLWriter::close();
}
}
示例12: switchAction
//.........这里部分代码省略.........
$outputArray = array();
$testedParams = array();
$passed = AJXP_Utils::runTests($outputArray, $testedParams);
if (!$passed && !isset($httpVars["ignore_tests"])) {
AJXP_Utils::testResultsToTable($outputArray, $testedParams);
die;
} else {
AJXP_Utils::testResultsToFile($outputArray, $testedParams);
}
}
$root = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
$configUrl = ConfService::getCoreConf("SERVER_URL");
if (!empty($configUrl)) {
$root = '/' . ltrim(parse_url($configUrl, PHP_URL_PATH), '/');
if (strlen($root) > 1) {
$root = rtrim($root, '/') . '/';
}
} else {
preg_match('/ws-(.)*\\/|settings|dashboard|welcome|user/', $root, $matches, PREG_OFFSET_CAPTURE);
if (count($matches)) {
$capture = $matches[0][1];
$root = substr($root, 0, $capture);
}
}
$START_PARAMETERS = array("BOOTER_URL" => "index.php?get_action=get_boot_conf", "MAIN_ELEMENT" => "ajxp_desktop", "APPLICATION_ROOT" => $root, "REBASE" => $root);
if (AuthService::usersEnabled()) {
AuthService::preLogUser(isset($httpVars["remote_session"]) ? $httpVars["remote_session"] : "");
AuthService::bootSequence($START_PARAMETERS);
if (AuthService::getLoggedUser() != null || AuthService::logUser(null, null) == 1) {
if (AuthService::getDefaultRootId() == -1) {
AuthService::disconnect();
} else {
$loggedUser = AuthService::getLoggedUser();
if (!$loggedUser->canRead(ConfService::getCurrentRepositoryId()) && AuthService::getDefaultRootId() != ConfService::getCurrentRepositoryId()) {
ConfService::switchRootDir(AuthService::getDefaultRootId());
}
}
}
}
AJXP_Utils::parseApplicationGetParameters($_GET, $START_PARAMETERS, $_SESSION);
$confErrors = ConfService::getErrors();
if (count($confErrors)) {
$START_PARAMETERS["ALERT"] = implode(", ", array_values($confErrors));
}
// PRECOMPUTE BOOT CONF
if (!preg_match('/MSIE 7/', $_SERVER['HTTP_USER_AGENT']) && !preg_match('/MSIE 8/', $_SERVER['HTTP_USER_AGENT'])) {
$preloadedBootConf = $this->computeBootConf();
AJXP_Controller::applyHook("loader.filter_boot_conf", array(&$preloadedBootConf));
$START_PARAMETERS["PRELOADED_BOOT_CONF"] = $preloadedBootConf;
}
// PRECOMPUTE REGISTRY
if (!isset($START_PARAMETERS["FORCE_REGISTRY_RELOAD"])) {
$clone = ConfService::getFilteredXMLRegistry(true, true);
$clonePath = new DOMXPath($clone);
$serverCallbacks = $clonePath->query("//serverCallback|hooks");
foreach ($serverCallbacks as $callback) {
$callback->parentNode->removeChild($callback);
}
$START_PARAMETERS["PRELOADED_REGISTRY"] = AJXP_XMLWriter::replaceAjxpXmlKeywords($clone->saveXML());
}
$JSON_START_PARAMETERS = json_encode($START_PARAMETERS);
$crtTheme = $this->pluginConf["GUI_THEME"];
$additionalFrameworks = $this->getFilteredOption("JS_RESOURCES_BEFORE");
$ADDITIONAL_FRAMEWORKS = "";
if (!empty($additionalFrameworks)) {
$frameworkList = explode(",", $additionalFrameworks);
示例13: clientChannelMethod
/**
* @param $action
* @param $httpVars
* @param $fileVars
*
*/
public function clientChannelMethod($action, $httpVars, $fileVars)
{
if (!$this->msgExchanger) {
return;
}
switch ($action) {
case "client_register_channel":
$this->msgExchanger->suscribeToChannel($httpVars["channel"], $httpVars["client_id"]);
break;
case "client_unregister_channel":
$this->msgExchanger->unsuscribeFromChannel($httpVars["channel"], $httpVars["client_id"]);
break;
case "client_consume_channel":
if (AuthService::usersEnabled()) {
$user = AuthService::getLoggedUser();
if ($user == null) {
AJXP_XMLWriter::header();
AJXP_XMLWriter::requireAuth();
AJXP_XMLWriter::close();
return;
}
$GROUP_PATH = $user->getGroupPath();
if ($GROUP_PATH == null) {
$GROUP_PATH = false;
}
$uId = $user->getId();
} else {
$GROUP_PATH = '/';
$uId = 'shared';
}
$currentRepository = ConfService::getCurrentRepositoryId();
$channelRepository = str_replace("nodes:", "", $httpVars["channel"]);
if ($channelRepository != $currentRepository) {
AJXP_XMLWriter::header();
echo "<require_registry_reload repositoryId=\"{$currentRepository}\"/>";
AJXP_XMLWriter::close();
return;
}
//session_write_close();
$startTime = time();
$maxTime = $startTime + (30 - 3);
// while (true) {
$data = $this->msgExchanger->consumeInstantChannel($httpVars["channel"], $httpVars["client_id"], $uId, $GROUP_PATH);
if (count($data)) {
AJXP_XMLWriter::header();
ksort($data);
foreach ($data as $messageObject) {
echo $messageObject->content;
}
AJXP_XMLWriter::close();
}
// break;
// } else if (time() >= $maxTime) {
// break;
// }
//
// sleep(3);
// }
break;
default:
break;
}
}
示例14: getUserXML
/**
* Extract all the user data and put it in XML
* @static
* @param null $userObject * @internal param bool $details
* @return string
*/
public static function getUserXML($userObject = null)
{
$buffer = "";
$loggedUser = AuthService::getLoggedUser();
$confDriver = ConfService::getConfStorageImpl();
if ($userObject != null) {
$loggedUser = $userObject;
}
if (!AuthService::usersEnabled()) {
$buffer .= "<user id=\"shared\">";
$buffer .= "<active_repo id=\"" . ConfService::getCurrentRepositoryId() . "\" write=\"1\" read=\"1\"/>";
$buffer .= AJXP_XMLWriter::writeRepositoriesData(null);
$buffer .= "</user>";
} else {
if ($loggedUser != null) {
$lock = $loggedUser->getLock();
$buffer .= "<user id=\"" . $loggedUser->id . "\">";
$buffer .= "<active_repo id=\"" . ConfService::getCurrentRepositoryId() . "\" write=\"" . ($loggedUser->canWrite(ConfService::getCurrentRepositoryId()) ? "1" : "0") . "\" read=\"" . ($loggedUser->canRead(ConfService::getCurrentRepositoryId()) ? "1" : "0") . "\"/>";
$buffer .= AJXP_XMLWriter::writeRepositoriesData($loggedUser);
$buffer .= "<preferences>";
$preferences = $confDriver->getExposedPreferences($loggedUser);
foreach ($preferences as $prefName => $prefData) {
$atts = "";
if (isset($prefData["exposed"]) && $prefData["exposed"] == true) {
foreach ($prefData as $k => $v) {
if ($k == "name") {
continue;
}
if ($k == "value") {
$k = "default";
}
$atts .= "{$k}='{$v}' ";
}
}
if (isset($prefData["pluginId"])) {
$atts .= "pluginId='" . $prefData["pluginId"] . "' ";
}
if ($prefData["type"] == "string") {
$buffer .= "<pref name=\"{$prefName}\" value=\"" . $prefData["value"] . "\" {$atts}/>";
} else {
if ($prefData["type"] == "json") {
$buffer .= "<pref name=\"{$prefName}\" {$atts}><![CDATA[" . $prefData["value"] . "]]></pref>";
}
}
}
$buffer .= "</preferences>";
$buffer .= "<special_rights is_admin=\"" . ($loggedUser->isAdmin() ? "1" : "0") . "\" " . ($lock !== false ? "lock=\"{$lock}\"" : "") . "/>";
/*
$bMarks = $loggedUser->getBookmarks();
if (count($bMarks)) {
$buffer.= "<bookmarks>".AJXP_XMLWriter::writeBookmarks($bMarks, false)."</bookmarks>";
}
*/
$buffer .= "</user>";
}
}
return $buffer;
}
示例15: findActionAndApply
/**
* Main method for querying the XML registry, find an action and all its associated processors,
* and apply all the callbacks.
* @static
* @param String $actionName
* @param array $httpVars
* @param array $fileVars
* @param DOMNode $action
* @return mixed
*/
public static function findActionAndApply($actionName, $httpVars, $fileVars, &$action = null)
{
$actionName = AJXP_Utils::sanitize($actionName, AJXP_SANITIZE_EMAILCHARS);
if ($actionName == "cross_copy") {
$pService = AJXP_PluginsService::getInstance();
$actives = $pService->getActivePlugins();
$accessPlug = $pService->getPluginsByType("access");
if (count($accessPlug)) {
foreach ($accessPlug as $key => $objbect) {
if ($actives[$objbect->getId()] === true) {
call_user_func(array($pService->getPluginById($objbect->getId()), "crossRepositoryCopy"), $httpVars);
break;
}
}
}
self::$lastActionNeedsAuth = true;
return null;
}
$xPath = self::initXPath();
if ($action == null) {
$actions = $xPath->query("actions/action[@name='{$actionName}']");
if (!$actions->length) {
self::$lastActionNeedsAuth = true;
return false;
}
$action = $actions->item(0);
}
//Check Rights
if (AuthService::usersEnabled()) {
$loggedUser = AuthService::getLoggedUser();
if (AJXP_Controller::actionNeedsRight($action, $xPath, "adminOnly") && ($loggedUser == null || !$loggedUser->isAdmin())) {
$mess = ConfService::getMessages();
AJXP_XMLWriter::header();
AJXP_XMLWriter::sendMessage(null, $mess[207]);
AJXP_XMLWriter::requireAuth();
AJXP_XMLWriter::close();
exit(1);
}
if (AJXP_Controller::actionNeedsRight($action, $xPath, "read") && ($loggedUser == null || !$loggedUser->canRead(ConfService::getCurrentRepositoryId() . ""))) {
AJXP_XMLWriter::header();
if ($actionName == "ls" & $loggedUser != null && $loggedUser->canWrite(ConfService::getCurrentRepositoryId() . "")) {
// Special case of "write only" right : return empty listing, no auth error.
AJXP_XMLWriter::close();
exit(1);
}
$mess = ConfService::getMessages();
AJXP_XMLWriter::sendMessage(null, $mess[208]);
AJXP_XMLWriter::requireAuth();
AJXP_XMLWriter::close();
exit(1);
}
if (AJXP_Controller::actionNeedsRight($action, $xPath, "write") && ($loggedUser == null || !$loggedUser->canWrite(ConfService::getCurrentRepositoryId() . ""))) {
$mess = ConfService::getMessages();
AJXP_XMLWriter::header();
AJXP_XMLWriter::sendMessage(null, $mess[207]);
AJXP_XMLWriter::requireAuth();
AJXP_XMLWriter::close();
exit(1);
}
}
$preCalls = self::getCallbackNode($xPath, $action, 'pre_processing/serverCallback', $actionName, $httpVars, $fileVars, true);
$postCalls = self::getCallbackNode($xPath, $action, 'post_processing/serverCallback[not(@capture="true")]', $actionName, $httpVars, $fileVars, true);
$captureCalls = self::getCallbackNode($xPath, $action, 'post_processing/serverCallback[@capture="true"]', $actionName, $httpVars, $fileVars, true);
$mainCall = self::getCallbackNode($xPath, $action, "processing/serverCallback", $actionName, $httpVars, $fileVars, false);
if ($mainCall != null) {
self::checkParams($httpVars, $mainCall, $xPath);
}
if ($captureCalls !== false) {
// Make sure the ShutdownScheduler has its own OB started BEFORE, as it will presumabily be
// executed AFTER the end of this one.
AJXP_ShutdownScheduler::getInstance();
ob_start();
$params = array("pre_processor_results" => array(), "post_processor_results" => array());
}
if ($preCalls !== false) {
foreach ($preCalls as $preCall) {
// A Preprocessing callback can modify its input arguments (passed by ref)
$preResult = self::applyCallback($preCall, $actionName, $httpVars, $fileVars);
if (isset($params)) {
$params["pre_processor_results"][$preCall->getAttribute("pluginId")] = $preResult;
}
}
}
if ($mainCall) {
$result = self::applyCallback($mainCall, $actionName, $httpVars, $fileVars);
if (isset($params)) {
$params["processor_result"] = $result;
}
}
if ($postCalls !== false) {
//.........这里部分代码省略.........