本文整理汇总了PHP中ConfService::addRepository方法的典型用法代码示例。如果您正苦于以下问题:PHP ConfService::addRepository方法的具体用法?PHP ConfService::addRepository怎么用?PHP ConfService::addRepository使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConfService
的用法示例。
在下文中一共展示了ConfService::addRepository方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: switchAction
//.........这里部分代码省略.........
}
AJXP_XMLWriter::close();
exit(1);
break;
case "get_drivers_definition":
AJXP_XMLWriter::header("drivers");
print ConfService::availableDriversToXML("param");
AJXP_XMLWriter::close("drivers");
exit(1);
break;
case "create_repository":
$options = array();
$repDef = $_GET;
unset($repDef["get_action"]);
$this->parseParameters($repDef, $options);
if (count($options)) {
$repDef["DRIVER_OPTIONS"] = $options;
}
// NOW SAVE THIS REPOSITORY!
$newRep = ConfService::createRepositoryFromArray(0, $repDef);
if (is_file(INSTALL_PATH . "/server/tests/plugins/test.ajxp_" . $newRep->getAccessType() . ".php")) {
chdir(INSTALL_PATH . "/server/tests/plugins");
include INSTALL_PATH . "/server/tests/plugins/test.ajxp_" . $newRep->getAccessType() . ".php";
$className = "ajxp_" . $newRep->getAccessType();
$class = new $className();
$result = $class->doRepositoryTest($newRep);
if (!$result) {
AJXP_XMLWriter::header();
AJXP_XMLWriter::sendMessage(null, $class->failedInfo);
AJXP_XMLWriter::close();
exit(1);
}
}
$res = ConfService::addRepository($newRep);
AJXP_XMLWriter::header();
if ($res == -1) {
AJXP_XMLWriter::sendMessage(null, "The conf directory is not writeable");
} else {
AJXP_XMLWriter::sendMessage("Successfully created repository", null);
AJXP_XMLWriter::reloadFileList($newRep->getDisplay());
AJXP_XMLWriter::reloadRepositoryList();
}
AJXP_XMLWriter::close();
exit(1);
break;
case "edit_repository":
$repId = $httpVars["repository_id"];
$repList = ConfService::getRootDirsList();
//print_r($repList);
AJXP_XMLWriter::header("admin_data");
if (!isset($repList[$repId])) {
AJXP_XMLWriter::close("admin_data");
exit(1);
}
$repository = $repList[$repId];
$nested = array();
print "<repository index=\"{$repId}\"";
foreach ($repository as $name => $option) {
if (!is_array($option)) {
if (is_bool($option)) {
$option = $option ? "true" : "false";
}
print " {$name}=\"" . SystemTextEncoding::toUTF8(Utils::xmlEntities($option)) . "\" ";
} else {
if (is_array($option)) {
$nested[] = $option;
示例2: migrateLegacyMeta
//.........这里部分代码省略.........
}
$shareLink = new ShareLink($shareStore, $publiclet);
$user = $shareLink->getUniqueUser();
if (AuthService::userExists($user)) {
$userObject = ConfService::getConfStorageImpl()->createUserObject($user);
$userObject->setHidden(true);
print "\n--Should set existing user {$user} as hidden";
if (!$dryRun) {
$userObject->save();
}
}
$shareLink->parseHttpVars(["custom_handle" => $element]);
$shareLink->setParentRepositoryId($sharedRepo->getParentId());
print "\n--Creating the following share object";
print_r($shareLink->getJsonData($shareCenter->getPublicAccessManager(), ConfService::getMessages()));
if (!$dryRun) {
$shareLink->save();
}
$meta["ajxp_shared"] = ["shares" => [$element => ["type" => "minisite"], $sharedRepoId => ["type" => "repository"]]];
} catch (Exception $e) {
print "\n-- Error " . $e->getMessage();
}
} else {
print "\n--Should migrate legacy link to new minisite with ContentFilter";
try {
$link = new ShareLink($shareStore);
$link->setOwnerId($userName);
$parameters = array("custom_handle" => $element, "simple_right_download" => true);
if (isset($publiclet["EXPIRE_TIME"])) {
$parameters["expiration"] = $publiclet["EXPIRE_TIME"];
}
if (isset($publiclet["DOWNLOAD_LIMIT"])) {
$parameters["downloadlimit"] = $publiclet["DOWNLOAD_LIMIT"];
}
$link->parseHttpVars($parameters);
$parentRepositoryObject = $publiclet["REPOSITORY"];
$driverInstance = AJXP_PluginsService::findPlugin("access", $parentRepositoryObject->getAccessType());
if (empty($driverInstance)) {
print "\n-- ERROR: Cannot find driver instance!";
continue;
}
$options = $driverInstance->makeSharedRepositoryOptions(["file" => "/"], $parentRepositoryObject);
$options["SHARE_ACCESS"] = "private";
$newRepo = $parentRepositoryObject->createSharedChild(basename($filePath), $options, $parentRepositoryObject->getId(), $userObject->getId(), null);
$gPath = $userObject->getGroupPath();
if (!empty($gPath) && !ConfService::getCoreConf("CROSSUSERS_ALLGROUPS", "conf")) {
$newRepo->setGroupPath($gPath);
}
$newRepo->setDescription("");
// Smells like dirty hack!
$newRepo->options["PATH"] = SystemTextEncoding::fromStorageEncoding($newRepo->options["PATH"]);
$newRepo->setContentFilter(new ContentFilter([new AJXP_Node("pydio://" . $parentRepositoryObject->getId() . $filePath)]));
if (!$dryRun) {
ConfService::addRepository($newRepo);
}
$hiddenUserEntry = $shareRightManager->prepareSharedUserEntry(["simple_right_read" => true, "simple_right_download" => true], $link, false, null);
$selection = new UserSelection($parentRepositoryObject, []);
$selection->addFile($filePath);
if (!$dryRun) {
$shareRightManager->assignSharedRepositoryPermissions($parentRepositoryObject, $newRepo, false, [$hiddenUserEntry["ID"] => $hiddenUserEntry], [], $selection);
}
$link->setParentRepositoryId($parentRepositoryObject->getId());
$link->attachToRepository($newRepo->getId());
print "\n-- Should save following LINK: ";
print_r($link->getJsonData($shareCenter->getPublicAccessManager(), ConfService::getMessages()));
if (!$dryRun) {
$hash = $link->save();
}
// UPDATE METADATA
$meta["ajxp_shared"] = ["shares" => [$element => array("type" => "minisite")]];
} catch (Exception $e) {
print "\n-- ERROR: " . $e->getMessage();
}
}
if ($dryRun) {
rename($legacyLinkFile . ".migrated", $legacyLinkFile);
}
continue;
} else {
//
// File does not exists, remove meta
//
unset($meta["ajxp_shared"]);
}
$repo = ConfService::getRepositoryById($element);
if ($repo !== null) {
print "\n--Shared repository: just metadata";
// Shared repo, migrating the meta should be enough
$meta["ajxp_shared"] = array("shares" => [$element => array("type" => "repository")]);
}
}
}
}
print "\n\n SHOULD NOW UPDATE METADATA WITH FOLLOWING :";
print_r($data);
if (!$dryRun) {
file_put_contents($store, serialize($data));
}
}
}
示例3: switchAction
//.........这里部分代码省略.........
foreach ($params as $paramNode) {
$name = $paramNode->getAttribute("name");
if (strpos($name, "TPL_") === 0) {
if ($name == "TPL_DEFAULT_LABEL") {
$defaultLabel = str_replace("AJXP_USER", AuthService::getLoggedUser()->getId(), $repo->getOption($name));
}
continue;
}
if (in_array($paramNode->getAttribute("name"), $tplDefined)) {
continue;
}
if ($paramNode->getAttribute('no_templates') == 'true') {
continue;
}
print AJXP_XMLWriter::replaceAjxpXmlKeywords($paramNode->ownerDocument->saveXML($paramNode));
}
// ADD LABEL
echo '<param name="DISPLAY" type="string" label="' . $mess[359] . '" description="' . $mess[429] . '" mandatory="true" default="' . $defaultLabel . '"/>';
print "</template>";
}
AJXP_XMLWriter::close("repository_templates");
break;
case "user_create_repository":
$tplId = $httpVars["template_id"];
$tplRepo = ConfService::getRepositoryById($tplId);
$options = array();
AJXP_Utils::parseStandardFormParameters($httpVars, $options);
$loggedUser = AuthService::getLoggedUser();
$newRep = $tplRepo->createTemplateChild(AJXP_Utils::sanitize($httpVars["DISPLAY"]), $options, null, $loggedUser->getId());
$gPath = $loggedUser->getGroupPath();
if (!empty($gPath)) {
$newRep->setGroupPath($gPath);
}
$res = ConfService::addRepository($newRep);
AJXP_XMLWriter::header();
if ($res == -1) {
AJXP_XMLWriter::sendMessage(null, $mess[426]);
} else {
// Make sure we do not overwrite otherwise loaded rights.
$loggedUser->load();
$loggedUser->personalRole->setAcl($newRep->getUniqueId(), "rw");
$loggedUser->save("superuser");
$loggedUser->recomputeMergedRole();
AuthService::updateUser($loggedUser);
AJXP_XMLWriter::sendMessage($mess[425], null);
AJXP_XMLWriter::reloadDataNode("", $newRep->getUniqueId());
AJXP_XMLWriter::reloadRepositoryList();
}
AJXP_XMLWriter::close();
break;
case "user_delete_repository":
$repoId = $httpVars["repository_id"];
$repository = ConfService::getRepositoryById($repoId);
if (!$repository->getUniqueUser() || $repository->getUniqueUser() != AuthService::getLoggedUser()->getId()) {
throw new Exception("You are not allowed to perform this operation!");
}
$res = ConfService::deleteRepository($repoId);
AJXP_XMLWriter::header();
if ($res == -1) {
AJXP_XMLWriter::sendMessage(null, $mess[427]);
} else {
$loggedUser = AuthService::getLoggedUser();
// Make sure we do not override remotely set rights
$loggedUser->load();
$loggedUser->personalRole->setAcl($repoId, "");
$loggedUser->save("superuser");
示例4: createOrLoadSharedRepository
/**
* @param array $httpVars
* @param bool $update
* @return Repository
* @throws Exception
*/
protected function createOrLoadSharedRepository($httpVars, &$update)
{
if (!isset($httpVars["repo_label"]) || $httpVars["repo_label"] == "") {
$mess = ConfService::getMessages();
throw new Exception($mess["349"]);
}
if (isset($httpVars["repository_id"])) {
$editingRepo = ConfService::getRepositoryById($httpVars["repository_id"]);
$update = true;
}
// CHECK REPO DOES NOT ALREADY EXISTS WITH SAME LABEL
$label = AJXP_Utils::sanitize(AJXP_Utils::securePath($httpVars["repo_label"]), AJXP_SANITIZE_HTML);
$description = AJXP_Utils::sanitize(AJXP_Utils::securePath($httpVars["repo_description"]), AJXP_SANITIZE_HTML);
$exists = $this->checkRepoWithSameLabel($label, isset($editingRepo) ? $editingRepo : null);
if ($exists) {
$mess = ConfService::getMessages();
throw new Exception($mess["share_center.352"]);
}
$loggedUser = AuthService::getLoggedUser();
if (isset($editingRepo)) {
$this->getShareStore()->testUserCanEditShare($editingRepo->getOwner(), $editingRepo->options);
$newRepo = $editingRepo;
$replace = false;
if ($editingRepo->getDisplay() != $label) {
$newRepo->setDisplay($label);
$replace = true;
}
if ($editingRepo->getDescription() != $description) {
$newRepo->setDescription($description);
$replace = true;
}
$newScope = isset($httpVars["share_scope"]) && $httpVars["share_scope"] == "public" ? "public" : "private";
$oldScope = $editingRepo->getOption("SHARE_ACCESS");
$currentOwner = $editingRepo->getOwner();
if ($newScope != $oldScope && $currentOwner != AuthService::getLoggedUser()->getId()) {
$mess = ConfService::getMessages();
throw new Exception($mess["share_center.224"]);
}
if ($newScope !== $oldScope) {
$editingRepo->addOption("SHARE_ACCESS", $newScope);
$replace = true;
}
if (isset($httpVars["transfer_owner"])) {
$newOwner = $httpVars["transfer_owner"];
if ($newOwner != $currentOwner && $currentOwner != AuthService::getLoggedUser()->getId()) {
$mess = ConfService::getMessages();
throw new Exception($mess["share_center.224"]);
}
$editingRepo->setOwnerData($editingRepo->getParentId(), $newOwner, $editingRepo->getUniqueUser());
$replace = true;
}
if ($replace) {
ConfService::replaceRepository($newRepo->getId(), $newRepo);
}
} else {
$options = $this->accessDriver->makeSharedRepositoryOptions($httpVars, $this->repository);
// TMP TESTS
$options["SHARE_ACCESS"] = $httpVars["share_scope"];
$newRepo = $this->repository->createSharedChild($label, $options, $this->repository->getId(), $loggedUser->getId(), null);
$gPath = $loggedUser->getGroupPath();
if (!empty($gPath) && !ConfService::getCoreConf("CROSSUSERS_ALLGROUPS", "conf")) {
$newRepo->setGroupPath($gPath);
}
$newRepo->setDescription($description);
// Smells like dirty hack!
$newRepo->options["PATH"] = SystemTextEncoding::fromStorageEncoding($newRepo->options["PATH"]);
if (isset($httpVars["filter_nodes"])) {
$newRepo->setContentFilter(new ContentFilter($httpVars["filter_nodes"]));
}
ConfService::addRepository($newRepo);
}
return $newRepo;
}
示例5: switchAction
//.........这里部分代码省略.........
}
$pNodes = $metaPlug->getManifestRawContent("//param[@default]", "nodes");
$defaultParams = array();
foreach ($pNodes as $domNode) {
$defaultParams[$domNode->getAttribute("name")] = $domNode->getAttribute("default");
}
$metaSourceOptions[$metaID] = $defaultParams;
}
$newRep->addOption("META_SOURCES", $metaSourceOptions);
}
}
}
if ($this->repositoryExists($newRep->getDisplay())) {
AJXP_XMLWriter::header();
AJXP_XMLWriter::sendMessage(null, $mess["ajxp_conf.50"]);
AJXP_XMLWriter::close();
return;
}
if ($isTemplate) {
$newRep->isTemplate = true;
}
if ($currentUserIsGroupAdmin) {
$newRep->setGroupPath(AuthService::getLoggedUser()->getGroupPath());
} else {
if (!empty($options["AJXP_GROUP_PATH_PARAMETER"])) {
$basePath = "/";
if (AuthService::getLoggedUser() != null && AuthService::getLoggedUser()->getGroupPath() != null) {
$basePath = AuthService::getLoggedUser()->getGroupPath();
}
$value = AJXP_Utils::securePath(rtrim($basePath, "/") . "/" . ltrim($options["AJXP_GROUP_PATH_PARAMETER"], "/"));
$newRep->setGroupPath($value);
}
}
$res = ConfService::addRepository($newRep);
AJXP_XMLWriter::header();
if ($res == -1) {
AJXP_XMLWriter::sendMessage(null, $mess["ajxp_conf.51"]);
} else {
$loggedUser = AuthService::getLoggedUser();
$loggedUser->personalRole->setAcl($newRep->getUniqueId(), "rw");
$loggedUser->recomputeMergedRole();
$loggedUser->save("superuser");
AuthService::updateUser($loggedUser);
AJXP_XMLWriter::sendMessage($mess["ajxp_conf.52"], null);
AJXP_XMLWriter::reloadDataNode("", $newRep->getUniqueId());
AJXP_XMLWriter::reloadRepositoryList();
}
AJXP_XMLWriter::close();
break;
case "edit_repository":
$repId = $httpVars["repository_id"];
$repository = ConfService::getRepositoryById($repId);
if ($repository == null) {
throw new Exception("Cannot find workspace with id {$repId}");
}
if (!AuthService::canAdministrate($repository)) {
throw new Exception("You are not allowed to edit this workspace!");
}
$pServ = AJXP_PluginsService::getInstance();
$plug = $pServ->getPluginById("access." . $repository->accessType);
if ($plug == null) {
throw new Exception("Cannot find access driver (" . $repository->accessType . ") for workspace!");
}
AJXP_XMLWriter::header("admin_data");
$slug = $repository->getSlug();
if ($slug == "" && $repository->isWriteable()) {
示例6: switchAction
//.........这里部分代码省略.........
}
}
// Apply default metasource if any
if ($driver != null && $driver->getConfigs() != null) {
$confs = $driver->getConfigs();
if (!empty($confs["DEFAULT_METASOURCES"])) {
$metaIds = AJXP_Utils::parseCSL($confs["DEFAULT_METASOURCES"]);
$metaSourceOptions = array();
foreach ($metaIds as $metaID) {
$metaPlug = $pServ->getPluginById($metaID);
if ($metaPlug == null) {
continue;
}
$pNodes = $metaPlug->getManifestRawContent("//param[@default]", "nodes");
$defaultParams = array();
foreach ($pNodes as $domNode) {
$defaultParams[$domNode->getAttribute("name")] = $domNode->getAttribute("default");
}
$metaSourceOptions[$metaID] = $defaultParams;
}
$newRep->addOption("META_SOURCES", $metaSourceOptions);
}
}
}
if ($this->repositoryExists($newRep->getDisplay())) {
AJXP_XMLWriter::header();
AJXP_XMLWriter::sendMessage(null, $mess["ajxp_conf.50"]);
AJXP_XMLWriter::close();
return;
}
if ($isTemplate) {
$newRep->isTemplate = true;
}
$res = ConfService::addRepository($newRep);
AJXP_XMLWriter::header();
if ($res == -1) {
AJXP_XMLWriter::sendMessage(null, $mess["ajxp_conf.51"]);
} else {
$loggedUser = AuthService::getLoggedUser();
$loggedUser->setRight($newRep->getUniqueId(), "rw");
$loggedUser->save("superuser");
AuthService::updateUser($loggedUser);
AJXP_XMLWriter::sendMessage($mess["ajxp_conf.52"], null);
AJXP_XMLWriter::reloadDataNode("", $newRep->getUniqueId());
AJXP_XMLWriter::reloadRepositoryList();
}
AJXP_XMLWriter::close();
break;
case "edit_repository":
$repId = $httpVars["repository_id"];
$repList = ConfService::getRootDirsList();
//print_r($repList);
if (!isset($repList[$repId])) {
throw new Exception("Cannot find repository with id {$repId}");
}
$repository = $repList[$repId];
$pServ = AJXP_PluginsService::getInstance();
$plug = $pServ->getPluginById("access." . $repository->accessType);
if ($plug == null) {
throw new Exception("Cannot find access driver (" . $repository->accessType . ") for repository!");
}
AJXP_XMLWriter::header("admin_data");
$slug = $repository->getSlug();
if ($slug == "" && $repository->isWriteable()) {
$repository->setSlug();
ConfService::replaceRepository($repId, $repository);
示例7: createSharedRepository
//.........这里部分代码省略.........
// 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();
}
}
}
$newRepo = $repository->createSharedChild($label, $options, $repository->id, $loggedUser->id, null);
$gPath = $loggedUser->getGroupPath();
if (!empty($gPath) && !ConfService::getCoreConf("CROSSUSERS_ALLGROUPS", "conf")) {
$newRepo->setGroupPath($gPath);
}
$newRepo->setDescription($description);
ConfService::addRepository($newRepo);
}
$file = AJXP_Utils::decodeSecureMagic($httpVars["file"]);
if (isset($editingRepo)) {
$currentRights = $this->computeSharedRepositoryAccessRights($httpVars["repository_id"], false, $this->urlBase . $file);
$originalUsers = array_keys($currentRights["USERS"]);
$removeUsers = array_diff($originalUsers, $users);
if (count($removeUsers)) {
foreach ($removeUsers as $user) {
if (AuthService::userExists($user)) {
$userObject = $confDriver->createUserObject($user);
$userObject->personalRole->setAcl($newRepo->getUniqueId(), "");
$userObject->save("superuser");
}
}
}
$originalGroups = array_keys($currentRights["GROUPS"]);
$removeGroups = array_diff($originalGroups, $groups);
if (count($removeGroups)) {
foreach ($removeGroups as $groupId) {
$role = AuthService::getRole("AJXP_GRP_" . AuthService::filterBaseGroup($groupId));
if ($role !== false) {
$role->setAcl($newRepo->getUniqueId(), "");
AuthService::updateRole($role);
}
}
}
}
foreach ($users as $userName) {
if (AuthService::userExists($userName, "r")) {
// check that it's a child user
$userObject = $confDriver->createUserObject($userName);
} else {
示例8: createSharedRepository
function createSharedRepository($httpVars)
{
// 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"]) || !isset($httpVars["repo_rights"]) || !isset($httpVars["shared_user"])) {
return 100;
}
$loggedUser = AuthService::getLoggedUser();
$actRights = $loggedUser->getSpecificActionsRights($this->repository->id);
if (isset($actRights["public_url"]) && $actRights["public_url"] === false) {
return 103;
}
$dir = AJXP_Utils::decodeSecureMagic($httpVars["dir"]);
$userName = $httpVars["shared_user"];
$label = SystemTextEncoding::fromUTF8($httpVars["repo_label"]);
$rights = $httpVars["repo_rights"];
if ($rights != "r" && $rights != "rw") {
return 100;
}
// CHECK USER & REPO DOES NOT ALREADY EXISTS
$repos = ConfService::getRepositoriesList();
foreach ($repos as $obj) {
if ($obj->getDisplay() == $label) {
return 101;
}
}
$confDriver = ConfService::getConfStorageImpl();
if (AuthService::userExists($userName)) {
// check that it's a child user
$userObject = $confDriver->createUserObject($userName);
if (!$userObject->hasParent() || $userObject->getParent() != $loggedUser->id) {
return 102;
}
} else {
if (!isset($httpVars["shared_pass"]) || $httpVars["shared_pass"] == "") {
return 100;
}
AuthService::createUser($userName, md5($httpVars["shared_pass"]));
$userObject = $confDriver->createUserObject($userName);
$userObject->clearRights();
$userObject->setParent($loggedUser->id);
}
// CREATE SHARED OPTIONS
$newRepo = $this->repository->createSharedChild($label, $this->makeSharedRepositoryOptions($httpVars), $this->repository->id, $loggedUser->id, $userName);
ConfService::addRepository($newRepo);
// CREATE USER WITH NEW REPO RIGHTS
$userObject->setRight($newRepo->getUniqueId(), $rights);
$userObject->setSpecificActionRight($newRepo->getUniqueId(), "public_url", false);
$userObject->save();
return 200;
}
示例9: switchAction
//.........这里部分代码省略.........
readfile(AJXP_INSTALL_PATH . "/" . AJXP_PLUGINS_FOLDER . "/core.conf/" . $logo);
}
break;
case "get_user_templates_definition":
AJXP_XMLWriter::header("repository_templates");
$repositories = ConfService::getRepositoriesList();
$pServ = AJXP_PluginsService::getInstance();
foreach ($repositories as $repo) {
if (!$repo->isTemplate) {
continue;
}
if (!$repo->getOption("TPL_USER_CAN_CREATE")) {
continue;
}
$repoId = $repo->getUniqueId();
$repoLabel = $repo->getDisplay();
$repoType = $repo->getAccessType();
print "<template repository_id=\"{$repoId}\" repository_label=\"{$repoLabel}\" repository_type=\"{$repoType}\">";
$driverPlug = $pServ->getPluginByTypeName("access", $repoType);
$params = $driverPlug->getManifestRawContent("//param", "node");
$tplDefined = $repo->getOptionsDefined();
$defaultLabel = '';
foreach ($params as $paramNode) {
$name = $paramNode->getAttribute("name");
if (strpos($name, "TPL_") === 0) {
if ($name == "TPL_DEFAULT_LABEL") {
$defaultLabel = str_replace("AJXP_USER", AuthService::getLoggedUser()->getId(), $repo->getOption($name));
}
continue;
}
if (in_array($paramNode->getAttribute("name"), $tplDefined)) {
continue;
}
if ($paramNode->getAttribute('no_templates') == 'true') {
continue;
}
print AJXP_XMLWriter::replaceAjxpXmlKeywords($paramNode->ownerDocument->saveXML($paramNode));
}
// ADD LABEL
echo '<param name="DISPLAY" type="string" label="' . $mess[359] . '" description="' . $mess[429] . '" mandatory="true" default="' . $defaultLabel . '"/>';
print "</template>";
}
AJXP_XMLWriter::close("repository_templates");
break;
case "user_create_repository":
$tplId = $httpVars["template_id"];
$tplRepo = ConfService::getRepositoryById($tplId);
$options = array();
self::parseParameters($httpVars, $options);
$newRep = $tplRepo->createTemplateChild(AJXP_Utils::sanitize($httpVars["DISPLAY"]), $options, null, AuthService::getLoggedUser()->getId());
$res = ConfService::addRepository($newRep);
AJXP_XMLWriter::header();
if ($res == -1) {
AJXP_XMLWriter::sendMessage(null, $mess[426]);
} else {
$loggedUser = AuthService::getLoggedUser();
// Make sure we do not overwrite otherwise loaded rights.
$loggedUser->load();
$loggedUser->setRight($newRep->getUniqueId(), "rw");
$loggedUser->save("superuser");
AuthService::updateUser($loggedUser);
AJXP_XMLWriter::sendMessage($mess[425], null);
AJXP_XMLWriter::reloadDataNode("", $newRep->getUniqueId());
AJXP_XMLWriter::reloadRepositoryList();
}
AJXP_XMLWriter::close();
break;
case "user_delete_repository":
$repoId = $httpVars["repository_id"];
$repository = ConfService::getRepositoryById($repoId);
if (!$repository->getUniqueUser() || $repository->getUniqueUser() != AuthService::getLoggedUser()->getId()) {
throw new Exception("You are not allowed to perform this operation!");
}
$res = ConfService::deleteRepository($repoId);
AJXP_XMLWriter::header();
if ($res == -1) {
AJXP_XMLWriter::sendMessage(null, $mess[427]);
} else {
$loggedUser = AuthService::getLoggedUser();
// Make sure we do not override remotely set rights
$loggedUser->load();
$loggedUser->removeRights($repoId);
$loggedUser->save("superuser");
AuthService::updateUser($loggedUser);
AJXP_XMLWriter::sendMessage($mess[428], null);
AJXP_XMLWriter::reloadRepositoryList();
}
AJXP_XMLWriter::close();
break;
default:
break;
}
if (isset($logMessage) || isset($errorMessage)) {
$xmlBuffer .= AJXP_XMLWriter::sendMessage(isset($logMessage) ? $logMessage : null, isset($errorMessage) ? $errorMessage : null, false);
}
if (isset($requireAuth)) {
$xmlBuffer .= AJXP_XMLWriter::requireAuth(false);
}
return $xmlBuffer;
}
示例10: switchAction
//.........这里部分代码省略.........
print ConfService::availableDriversToXML("param");
AJXP_XMLWriter::close("drivers");
exit(1);
break;
case "create_repository":
$options = array();
$repDef = $httpVars;
unset($repDef["get_action"]);
$this->parseParameters($repDef, $options);
if (count($options)) {
$repDef["DRIVER_OPTIONS"] = $options;
}
// NOW SAVE THIS REPOSITORY!
$newRep = ConfService::createRepositoryFromArray(0, $repDef);
if (is_file(INSTALL_PATH . "/server/tests/plugins/test.ajxp_" . $newRep->getAccessType() . ".php")) {
chdir(INSTALL_PATH . "/server/tests/plugins");
include INSTALL_PATH . "/server/tests/plugins/test.ajxp_" . $newRep->getAccessType() . ".php";
$className = "ajxp_" . $newRep->getAccessType();
$class = new $className();
$result = $class->doRepositoryTest($newRep);
if (!$result) {
AJXP_XMLWriter::header();
AJXP_XMLWriter::sendMessage(null, $class->failedInfo);
AJXP_XMLWriter::close();
exit(1);
}
}
if ($this->repositoryExists($newRep->getDisplay())) {
AJXP_XMLWriter::header();
AJXP_XMLWriter::sendMessage(null, $mess["ajxp_conf.50"]);
AJXP_XMLWriter::close();
exit(1);
}
$res = ConfService::addRepository($newRep);
AJXP_XMLWriter::header();
if ($res == -1) {
AJXP_XMLWriter::sendMessage(null, $mess["ajxp_conf.51"]);
} else {
$confStorage = ConfService::getConfStorageImpl();
$loggedUser = AuthService::getLoggedUser();
$loggedUser->setRight($newRep->getUniqueId(), "rw");
$loggedUser->save();
AuthService::updateUser($loggedUser);
AJXP_XMLWriter::sendMessage($mess["ajxp_conf.52"], null);
AJXP_XMLWriter::reloadFileList($newRep->getDisplay());
AJXP_XMLWriter::reloadRepositoryList();
}
AJXP_XMLWriter::close();
exit(1);
break;
case "edit_repository":
$repId = $httpVars["repository_id"];
$repList = ConfService::getRootDirsList();
//print_r($repList);
AJXP_XMLWriter::header("admin_data");
if (!isset($repList[$repId])) {
AJXP_XMLWriter::close("admin_data");
exit(1);
}
$repository = $repList[$repId];
$nested = array();
print "<repository index=\"{$repId}\"";
foreach ($repository as $name => $option) {
if (!is_array($option)) {
if (is_bool($option)) {
$option = $option ? "true" : "false";
示例11: 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);
//.........这里部分代码省略.........
示例12: createSharedRepository
//.........这里部分代码省略.........
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);
}
} 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();
}
if ($index == "meta.syncable" && (!isset($data["REPO_SYNCABLE"]) || $data["REPO_SYNCABLE"] === true)) {
$data["REQUIRES_INDEXATION"] = true;
}
}
}
$newRepo = $repository->createSharedChild($label, $options, $repository->id, $loggedUser->id, null);
$gPath = $loggedUser->getGroupPath();
if (!empty($gPath) && !ConfService::getCoreConf("CROSSUSERS_ALLGROUPS", "conf")) {
$newRepo->setGroupPath($gPath);
}
$newRepo->setDescription($description);
$newRepo->options["PATH"] = SystemTextEncoding::fromStorageEncoding($newRepo->options["PATH"]);
if (isset($httpVars["filter_nodes"])) {
$newRepo->setContentFilter(new ContentFilter($httpVars["filter_nodes"]));
}
ConfService::addRepository($newRepo);
if (!isset($httpVars["minisite"])) {
$this->getShareStore()->storeShare($repository->getId(), array("REPOSITORY" => $newRepo->getUniqueId(), "OWNER_ID" => $loggedUser->getId()), "repository");
}
}
$sel = new UserSelection($this->repository, $httpVars);
$file = $sel->getUniqueFile();
$newRepoUniqueId = $newRepo->getUniqueId();
if (isset($editingRepo)) {
$currentRights = $this->computeSharedRepositoryAccessRights($httpVars["repository_id"], false, $this->urlBase . $file);
$originalUsers = array_keys($currentRights["USERS"]);
$removeUsers = array_diff($originalUsers, $users);
if (count($removeUsers)) {
foreach ($removeUsers as $user) {
if (AuthService::userExists($user)) {
$userObject = $confDriver->createUserObject($user);
$userObject->personalRole->setAcl($newRepoUniqueId, "");
$userObject->save("superuser");
}
if ($this->watcher !== false) {
$this->watcher->removeWatchFromFolder(new AJXP_Node($this->urlBase . $file), $user, true);
}
}
}
$originalGroups = array_keys($currentRights["GROUPS"]);
$removeGroups = array_diff($originalGroups, $groups);
if (count($removeGroups)) {
foreach ($removeGroups as $groupId) {
$role = AuthService::getRole($groupId);
if ($role !== false) {
$role->setAcl($newRepoUniqueId, "");
AuthService::updateRole($role);
}