本文整理汇总了PHP中ConfService::getRepositoriesList方法的典型用法代码示例。如果您正苦于以下问题:PHP ConfService::getRepositoriesList方法的具体用法?PHP ConfService::getRepositoriesList怎么用?PHP ConfService::getRepositoriesList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConfService
的用法示例。
在下文中一共展示了ConfService::getRepositoriesList方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parseSpecificContributions
public function parseSpecificContributions(&$contribNode)
{
parent::parseSpecificContributions($contribNode);
if ($contribNode->nodeName != "actions") {
return;
}
$actionXpath = new DOMXPath($contribNode->ownerDocument);
$paramList = $actionXpath->query('action[@name="scheduler_addTask"]/processing/standardFormDefinition/param[@name="repository_id"]', $contribNode);
if (!$paramList->length) {
return;
}
$paramNode = $paramList->item(0);
$sVals = array();
$repos = ConfService::getRepositoriesList("all");
foreach ($repos as $repoId => $repoObject) {
$sVals[] = $repoId . "|" . AJXP_Utils::xmlEntities($repoObject->getDisplay());
}
$sVals[] = "*|All Repositories";
$paramNode->attributes->getNamedItem("choices")->nodeValue = implode(",", $sVals);
if (!AuthService::usersEnabled() || AuthService::getLoggedUser() == null) {
return;
}
$paramList = $actionXpath->query('action[@name="scheduler_addTask"]/processing/standardFormDefinition/param[@name="user_id"]', $contribNode);
if (!$paramList->length) {
return;
}
$paramNode = $paramList->item(0);
$paramNode->attributes->getNamedItem("default")->nodeValue = AuthService::getLoggedUser()->getId();
}
示例2: getRolesList
/**
* Get all defined roles
* @static
* @param array $roleIds
* @param boolean $excludeReserved,
* @return AJXP_Role[]
*/
public static function getRolesList($roleIds = array(), $excludeReserved = false)
{
//if(isSet(self::$roles)) return self::$roles;
$confDriver = ConfService::getConfStorageImpl();
self::$roles = $confDriver->listRoles($roleIds, $excludeReserved);
$repoList = null;
foreach (self::$roles as $roleId => $roleObject) {
if (is_a($roleObject, "AjxpRole")) {
if ($repoList == null) {
$repoList = ConfService::getRepositoriesList("all");
}
$newRole = new AJXP_Role($roleId);
$newRole->migrateDeprectated($repoList, $roleObject);
self::$roles[$roleId] = $newRole;
self::updateRole($newRole);
}
}
return self::$roles;
}
示例3: repositoryExists
public function repositoryExists($name)
{
$repos = ConfService::getRepositoriesList();
foreach ($repos as $obj) {
if ($obj->getDisplay() == $name) {
return true;
}
}
return false;
}
示例4: listRepositories
function listRepositories()
{
$repos = ConfService::getRepositoriesList();
AJXP_XMLWriter::sendFilesListComponentConfig('<columns switchGridMode="filelist"><column messageId="ajxp_conf.8" attributeName="ajxp_label" sortType="String"/><column messageId="ajxp_conf.9" attributeName="accessType" sortType="String"/></columns>');
$repoArray = array();
foreach ($repos as $repoIndex => $repoObject) {
if ($repoObject->getAccessType() == "ajxp_conf") {
continue;
}
$name = 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];
$metaData = array("repository_id" => $repoIndex, "accessType" => $repoObject->getAccessType(), "icon" => "folder_red.png", "openicon" => "folder_red.png", "parentname" => "/repositories", "ajxp_mime" => "repository" . ($repoObject->isWriteable() ? "_editable" : ""));
AJXP_XMLWriter::renderNode("/repositories/{$repoIndex}", $name, true, $metaData);
}
}
示例5: updateDefaultRights
/**
* Update a user object with the default repositories rights
*
* @param AbstractAjxpUser $userObject
*/
function updateDefaultRights(&$userObject)
{
foreach (ConfService::getRepositoriesList() as $repositoryId => $repoObject) {
if ($repoObject->getDefaultRight() != "") {
$userObject->setRight($repositoryId, $repoObject->getDefaultRight());
}
}
}
示例6: listRepositories
function listRepositories()
{
$repos = ConfService::getRepositoriesList();
AJXP_XMLWriter::sendFilesListComponentConfig('<columns switchGridMode="filelist"><column messageId="ajxp_conf.8" attributeName="ajxp_label" sortType="String"/><column messageId="ajxp_conf.9" attributeName="accessType" sortType="String"/><column messageId="ajxp_shared.9" attributeName="repo_accesses" sortType="String"/></columns>');
$repoArray = array();
$childRepos = array();
$loggedUser = AuthService::getLoggedUser();
$users = AuthService::listUsers();
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 = AJXP_Utils::xmlEntities(SystemTextEncoding::toUTF8($repoObject->getDisplay()));
$repoArray[$name] = $repoIndex;
}
// Sort the list now by name
ksort($repoArray);
// Append child repositories
$sortedArray = array();
foreach ($repoArray as $name => $repoIndex) {
$sortedArray[$name] = $repoIndex;
if (isset($childRepos[$repoIndex]) && is_array($childRepos[$repoIndex])) {
foreach ($childRepos[$repoIndex] as $childData) {
$sortedArray[$childData["name"]] = $childData["index"];
}
}
}
foreach ($sortedArray as $name => $repoIndex) {
$repoObject =& $repos[$repoIndex];
$repoAccesses = array();
foreach ($users as $userId => $userObject) {
if (!$userObject->hasParent()) {
continue;
}
if ($userObject->canWrite($repoIndex)) {
$repoAccesses[] = $userId . " (rw)";
} else {
if ($userObject->canRead($repoIndex)) {
$repoAccesses[] = $userId . " (r)";
}
}
}
$metaData = array("repository_id" => $repoIndex, "accessType" => $repoObject->getAccessType(), "icon" => "document_open_remote.png", "openicon" => "document_open_remote.png", "parentname" => "/repositories", "repo_accesses" => implode(", ", $repoAccesses), "ajxp_mime" => "shared_repository");
AJXP_XMLWriter::renderNode("/repositories/{$repoIndex}", $name, true, $metaData);
}
}
示例7: createUsers
/**
* Create the users based on the installer form results.
* @param array $data Parsed form results
* @param bool $loginIsEmail Whether to use the login as primary email.
* @throws Exception
*/
public function createUsers($data, $loginIsEmail = false)
{
$newConfigPlugin = ConfService::getConfStorageImpl();
require_once $newConfigPlugin->getUserClassFileName();
$adminLogin = AJXP_Utils::sanitize($data["ADMIN_USER_LOGIN"], AJXP_SANITIZE_EMAILCHARS);
$adminName = $data["ADMIN_USER_NAME"];
$adminPass = $data["ADMIN_USER_PASS"];
AuthService::createUser($adminLogin, $adminPass, true);
$uObj = $newConfigPlugin->createUserObject($adminLogin);
if ($loginIsEmail) {
$uObj->personalRole->setParameterValue("core.conf", "email", $data["ADMIN_USER_LOGIN"]);
} else {
if (isset($data["MAILER_ADMIN"])) {
$uObj->personalRole->setParameterValue("core.conf", "email", $data["MAILER_ADMIN"]);
}
}
$uObj->personalRole->setParameterValue("core.conf", "USER_DISPLAY_NAME", $adminName);
$repos = ConfService::getRepositoriesList("all", false);
foreach ($repos as $repo) {
$uObj->personalRole->setAcl($repo->getId(), "rw");
}
AuthService::updateRole($uObj->personalRole);
$loginP = "USER_LOGIN";
$i = 0;
while (isset($data[$loginP]) && !empty($data[$loginP])) {
$pass = $data[str_replace("_LOGIN", "_PASS", $loginP)];
$name = $data[str_replace("_LOGIN", "_NAME", $loginP)];
$mail = $data[str_replace("_LOGIN", "_MAIL", $loginP)];
$saniLogin = AJXP_Utils::sanitize($data[$loginP], AJXP_SANITIZE_EMAILCHARS);
AuthService::createUser($saniLogin, $pass);
$uObj = $newConfigPlugin->createUserObject($saniLogin);
$uObj->personalRole->setParameterValue("core.conf", "email", $mail);
$uObj->personalRole->setParameterValue("core.conf", "USER_DISPLAY_NAME", $name);
AuthService::updateRole($uObj->personalRole);
$i++;
$loginP = "USER_LOGIN_" . $i;
}
}
示例8: writeRepositoriesData
function writeRepositoriesData($loggedUser, $details = false)
{
$st = "";
$st .= "<repositories>";
$streams = ConfService::detectRepositoryStreams(false);
foreach (ConfService::getRepositoriesList() as $rootDirIndex => $rootDirObject) {
$toLast = false;
if ($rootDirObject->getAccessType() == "ajxp_conf") {
if (AuthService::usersEnabled() && !$loggedUser->isAdmin()) {
continue;
} else {
$toLast = true;
}
}
if ($loggedUser == null || $loggedUser->canRead($rootDirIndex) || $details) {
$rightString = "";
if ($details) {
$rightString = " r=\"" . ($loggedUser->canRead($rootDirIndex) ? "1" : "0") . "\" w=\"" . ($loggedUser->canWrite($rootDirIndex) ? "1" : "0") . "\"";
}
$streamString = "";
if (in_array($rootDirObject->accessType, $streams)) {
$streamString = "allowCrossRepositoryCopy=\"true\"";
}
if ($toLast) {
$lastString = "<repo access_type=\"" . $rootDirObject->accessType . "\" id=\"" . $rootDirIndex . "\"{$rightString} {$streamString}><label>" . SystemTextEncoding::toUTF8(AJXP_Utils::xmlEntities($rootDirObject->getDisplay())) . "</label>" . $rootDirObject->getClientSettings() . "</repo>";
} else {
$st .= "<repo access_type=\"" . $rootDirObject->accessType . "\" id=\"" . $rootDirIndex . "\"{$rightString} {$streamString}><label>" . SystemTextEncoding::toUTF8(AJXP_Utils::xmlEntities($rootDirObject->getDisplay())) . "</label>" . $rootDirObject->getClientSettings() . "</repo>";
}
}
}
if (isset($lastString)) {
$st .= $lastString;
}
$st .= "</repositories>";
return $st;
}
示例9: switchAction
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::getCurrentRootDirIndex();
$user->setArrayPref("history", "last_repository", $activeRepId);
$user->save("user");
}
//$logMessage = "Successfully Switched!";
AJXP_Logger::logAction("Switch Repository", array("rep. id" => $repository_id));
break;
//------------------------------------
// BOOKMARK BAR
//------------------------------------
//------------------------------------
// BOOKMARK BAR
//------------------------------------
case "get_bookmarks":
$bmUser = null;
if (AuthService::usersEnabled() && AuthService::getLoggedUser() != null) {
$bmUser = AuthService::getLoggedUser();
} else {
if (!AuthService::usersEnabled()) {
$confStorage = ConfService::getConfStorageImpl();
$bmUser = $confStorage->createUserObject("shared");
}
}
if ($bmUser == null) {
exit(1);
}
if (isset($httpVars["bm_action"]) && isset($httpVars["bm_path"])) {
if ($httpVars["bm_action"] == "add_bookmark") {
$title = "";
if (isset($httpVars["bm_title"])) {
$title = $httpVars["bm_title"];
}
if ($title == "" && $httpVars["bm_path"] == "/") {
$title = ConfService::getCurrentRootDirDisplay();
}
$bmUser->addBookMark(SystemTextEncoding::magicDequote($httpVars["bm_path"]), SystemTextEncoding::magicDequote($title));
} else {
if ($httpVars["bm_action"] == "delete_bookmark") {
$bmUser->removeBookmark($httpVars["bm_path"]);
} else {
if ($httpVars["bm_action"] == "rename_bookmark" && isset($httpVars["bm_title"])) {
$bmUser->renameBookmark($httpVars["bm_path"], $httpVars["bm_title"]);
}
}
}
}
if (AuthService::usersEnabled() && AuthService::getLoggedUser() != null) {
$bmUser->save("user");
AuthService::updateUser($bmUser);
} else {
if (!AuthService::usersEnabled()) {
$bmUser->save("user");
}
}
AJXP_XMLWriter::header();
AJXP_XMLWriter::writeBookmarks($bmUser->getBookmarks());
AJXP_XMLWriter::close();
exit(1);
break;
//------------------------------------
// SAVE USER PREFERENCE
//------------------------------------
//------------------------------------
// SAVE USER PREFERENCE
//------------------------------------
case "save_user_pref":
$userObject = AuthService::getLoggedUser();
//.........这里部分代码省略.........
示例10: runTask
public function runTask($taskId, $status = null, &$currentlyRunning = -1, $forceStart = false)
{
$data = $this->getTaskById($taskId);
$mess = ConfService::getMessages();
$timeArray = $this->getTimeArray($data["schedule"]);
// TODO : Set MasterInterval as config, or detect last execution?
$masterInterval = 1;
$maximumProcesses = 2;
$now = time();
$lastExec = time() - 60 * $masterInterval;
$res = $this->getNextExecutionTimeForScript($lastExec, $timeArray);
$test = date("Y-m-d H:i", $lastExec) . " -- " . date("Y-m-d H:i", $res) . " -- " . date("Y-m-d H:i", $now);
$alreadyRunning = false;
$queued = false;
if ($status == null) {
$status = $this->getTaskStatus($taskId);
}
if ($status !== false) {
if ($status[0] == "RUNNING") {
$alreadyRunning = true;
} else {
if (in_array("QUEUED", $status)) {
$queued = true;
// Run now !
}
}
}
if ($res >= $lastExec && $res < $now && !$alreadyRunning && $currentlyRunning >= $maximumProcesses) {
$this->setTaskStatus($taskId, "QUEUED", true);
$alreadyRunning = true;
$queued = false;
}
if ($res >= $lastExec && $res < $now && !$alreadyRunning || $queued || $forceStart) {
if ($data["user_id"] == "*/*" || $data["user_id"] == "*") {
// Recurse all groups and put them into a queue file
$allUsers = array();
if ($data["user_id"] == "*") {
$allUsers = $this->listUsersIds();
} else {
$this->gatherUsers($allUsers, "/");
}
$tmpQueue = AJXP_CACHE_DIR . "/cmd_outputs/queue_" . $taskId . "";
echo "Queuing " . count($allUsers) . " users in file " . $tmpQueue . "\n";
file_put_contents($tmpQueue, implode(",", $allUsers));
$data["user_id"] = "queue:" . $tmpQueue;
}
if ($data["repository_id"] == "*") {
$data["repository_id"] = implode(",", array_keys(ConfService::getRepositoriesList("all")));
}
$process = AJXP_Controller::applyActionInBackground($data["repository_id"], $data["action_name"], $data["PARAMS"], $data["user_id"], AJXP_CACHE_DIR . "/cmd_outputs/task_" . $taskId . ".status");
if ($process != null && is_a($process, "UnixProcess")) {
$this->setTaskStatus($taskId, "RUNNING:" . $process->getPid());
} else {
$this->setTaskStatus($taskId, "RUNNING");
}
$currentlyRunning++;
return true;
}
return false;
}
示例11: writeRoleRepositoriesData
/**
* Send repositories access for given role as XML
*
* @param AjxpRole $role
* @return string
*/
static function writeRoleRepositoriesData($role)
{
$st = "<repositories>";
foreach (ConfService::getRepositoriesList() as $repoId => $repoObject) {
$toLast = false;
if ($repoObject->getAccessType() == "ajxp_conf") {
continue;
}
if ($repoObject->getAccessType() == "ajxp_shared" && !AuthService::usersEnabled()) {
continue;
}
$rightString = " r=\"" . ($role->canRead($repoId) ? "1" : "0") . "\" w=\"" . ($role->canWrite($repoId) ? "1" : "0") . "\"";
$string = "<repo access_type=\"" . $repoObject->accessType . "\" id=\"" . $repoId . "\"{$rightString}><label>" . SystemTextEncoding::toUTF8(AJXP_Utils::xmlEntities($repoObject->getDisplay())) . "</label></repo>";
if ($toLast) {
$lastString = $string;
} else {
$st .= $string;
}
}
if (isset($lastString)) {
$st .= $lastString;
}
$st .= "</repositories>";
$st .= "<actions_rights>";
foreach ($role->getSpecificActionsRights("ajxp.all") as $actionId => $actionValue) {
$st .= "<action name=\"{$actionId}\" value=\"" . ($actionValue ? "true" : "false") . "\"/>";
}
$st .= "</actions_rights>";
return $st;
}
示例12: listRepositories
public function listRepositories()
{
$repos = ConfService::getRepositoriesList("all");
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();
$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);
}
}
示例13: 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));
}
示例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: updateDefaultRights
/**
* Update a user object with the default repositories rights
*
* @param AbstractAjxpUser $userObject
*/
static function updateDefaultRights(&$userObject)
{
if (!$userObject->hasParent()) {
foreach (ConfService::getRepositoriesList() as $repositoryId => $repoObject) {
if ($repoObject->isTemplate) {
continue;
}
if ($repoObject->getDefaultRight() != "") {
$userObject->setRight($repositoryId, $repoObject->getDefaultRight());
}
}
foreach (AuthService::getRolesList() as $roleId => $roleObject) {
if ($roleObject->isDefault()) {
$userObject->addRole($roleId);
}
}
}
}