本文整理汇总了PHP中ConfService::replaceRepository方法的典型用法代码示例。如果您正苦于以下问题:PHP ConfService::replaceRepository方法的具体用法?PHP ConfService::replaceRepository怎么用?PHP ConfService::replaceRepository使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConfService
的用法示例。
在下文中一共展示了ConfService::replaceRepository方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: switchActions
public function switchActions($actionName, $httpVars, $fileVars)
{
if ($actionName != "changes" || !isset($httpVars["seq_id"])) {
return false;
}
if (!dibi::isConnected()) {
dibi::connect($this->sqlDriver);
}
$filter = null;
$masks = array();
$currentRepo = $this->accessDriver->repository;
AJXP_Controller::applyHook("role.masks", array($currentRepo->getId(), &$masks, AJXP_Permission::READ));
$recycle = $currentRepo->getOption("RECYCLE_BIN");
$recycle = !empty($recycle) ? $recycle : false;
if ($this->options["OBSERVE_STORAGE_CHANGES"] === true) {
// Do it every XX minutes
$minutes = 5;
if (isset($this->options["OBSERVE_STORAGE_EVERY"])) {
$minutes = intval($this->options["OBSERVE_STORAGE_EVERY"]);
}
$file = $this->getResyncTimestampFile();
$last = 0;
if (is_file($file)) {
$last = intval(file_get_contents($file));
}
if (time() - $last > $minutes * 60) {
$this->resyncAction("resync_storage", array(), array());
}
}
if ($this->options["REQUIRES_INDEXATION"]) {
if (ConfService::backgroundActionsSupported()) {
AJXP_Controller::applyActionInBackground(ConfService::getRepository()->getId(), "index", array());
} else {
AJXP_Controller::findActionAndApply("index", array(), array());
}
// Unset the REQUIRES_INDEXATION FLAG
$meta = $currentRepo->getOption("META_SOURCES");
unset($meta["meta.syncable"]["REQUIRES_INDEXATION"]);
$currentRepo->addOption("META_SOURCES", $meta);
ConfService::replaceRepository($currentRepo->getId(), $currentRepo);
}
HTMLWriter::charsetHeader('application/json', 'UTF-8');
$stream = isset($httpVars["stream"]);
$separator = $stream ? "\n" : ",";
$veryLastSeq = intval(dibi::query("SELECT MAX([seq]) FROM [ajxp_changes]")->fetchSingle());
$seqId = intval(AJXP_Utils::sanitize($httpVars["seq_id"], AJXP_SANITIZE_ALPHANUM));
if ($veryLastSeq > 0 && $seqId > $veryLastSeq) {
// This is not normal! Send a signal reload all changes from start.
if (!$stream) {
echo json_encode(array('changes' => array(), 'last_seq' => 1));
} else {
echo 'LAST_SEQ:1';
}
return null;
}
$ands = array();
$ands[] = array("[ajxp_changes].[repository_identifier] = %s", $this->computeIdentifier($currentRepo));
$ands[] = array("[seq] > %i", $seqId);
if (isset($httpVars["filter"])) {
$filter = AJXP_Utils::decodeSecureMagic($httpVars["filter"]);
$filterLike = rtrim($filter, "/") . "/";
$ands[] = array("[source] LIKE %like~ OR [target] LIKE %like~", $filterLike, $filterLike);
}
if (count($masks)) {
$ors = array();
foreach ($masks as $mask) {
$filterLike = rtrim($mask, "/") . "/";
$ors[] = array("[source] LIKE %like~ OR [target] LIKE %like~", $filterLike, $filterLike);
}
if (count($ors)) {
$ands[] = array("%or", $ors);
}
}
$res = dibi::query("SELECT\n [seq] , [ajxp_changes].[repository_identifier] , [ajxp_changes].[node_id] , [type] , [source] , [target] , [ajxp_index].[bytesize], [ajxp_index].[md5], [ajxp_index].[mtime], [ajxp_index].[node_path]\n FROM [ajxp_changes]\n LEFT JOIN [ajxp_index]\n ON [ajxp_changes].[node_id] = [ajxp_index].[node_id]\n WHERE %and\n ORDER BY [ajxp_changes].[node_id], [seq] ASC", $ands);
if (!$stream) {
echo '{"changes":[';
}
$previousNodeId = -1;
$previousRow = null;
$order = array("path" => 0, "content" => 1, "create" => 2, "delete" => 3);
$relocateAttrs = array("bytesize", "md5", "mtime", "node_path", "repository_identifier");
$valuesSent = false;
foreach ($res as $row) {
$row->node = array();
foreach ($relocateAttrs as $att) {
$row->node[$att] = $row->{$att};
unset($row->{$att});
}
if (!empty($recycle)) {
$this->cancelRecycleNodes($row, $recycle);
}
if (!isset($httpVars["flatten"]) || $httpVars["flatten"] == "false") {
if (!$this->filterMasks($row, $masks) && !$this->filterRow($row, $filter)) {
if ($valuesSent) {
echo $separator;
}
echo json_encode($row);
$valuesSent = true;
}
} else {
//.........这里部分代码省略.........
示例2: switchAction
//.........这里部分代码省略.........
}
print " {$name}=\"" . SystemTextEncoding::toUTF8(Utils::xmlEntities($option)) . "\" ";
} else {
if (is_array($option)) {
$nested[] = $option;
}
}
}
if (count($nested)) {
print ">";
foreach ($nested as $option) {
foreach ($option as $key => $optValue) {
if (is_bool($optValue)) {
$optValue = $optValue ? "true" : "false";
}
print "<param name=\"{$key}\" value=\"{$optValue}\"/>";
}
}
print "</repository>";
} else {
print "/>";
}
print ConfService::availableDriversToXML("param", $repository->accessType);
AJXP_XMLWriter::close("admin_data");
exit(1);
break;
case "edit_repository_label":
case "edit_repository_data":
$repId = $_GET["repository_id"];
$repo = ConfService::getRepositoryById($repId);
$res = 0;
if (isset($_GET["newLabel"])) {
$repo->setDisplay(SystemTextEncoding::fromPostedFileName($_GET["newLabel"]));
$res = ConfService::replaceRepository($repId, $repo);
} else {
$options = array();
$this->parseParameters($_GET, $options);
if (count($options)) {
foreach ($options as $key => $value) {
$repo->addOption($key, $value);
}
}
if (is_file(INSTALL_PATH . "/server/tests/plugins/test.ajxp_" . $repo->getAccessType() . ".php")) {
chdir(INSTALL_PATH . "/server/tests/plugins");
include INSTALL_PATH . "/server/tests/plugins/test.ajxp_" . $repo->getAccessType() . ".php";
$className = "ajxp_" . $repo->getAccessType();
$class = new $className();
$result = $class->doRepositoryTest($repo);
if (!$result) {
AJXP_XMLWriter::header();
AJXP_XMLWriter::sendMessage(null, $class->failedInfo);
AJXP_XMLWriter::close();
exit(1);
}
}
ConfService::replaceRepository($repId, $repo);
}
AJXP_XMLWriter::header();
if ($res == -1) {
AJXP_XMLWriter::sendMessage(null, "Error while trying to edit repository");
} else {
AJXP_XMLWriter::sendMessage("Successfully edited repository", null);
AJXP_XMLWriter::reloadFileList(isset($_GET["newLabel"]) ? SystemTextEncoding::fromPostedFileName($_GET["newLabel"]) : false);
AJXP_XMLWriter::reloadRepositoryList();
}
AJXP_XMLWriter::close();
示例3: moveSharesFromMeta
/**
* @param array $shares
* @param String $operation
* @param AJXP_Node $oldNode
* @param AJXP_Node $newNode
* @param array $collectRepositories
* @param string|null $parentRepositoryPath
* @return array
* @throws Exception
*/
public function moveSharesFromMeta($shares, $operation = "move", $oldNode, $newNode = null, &$collectRepositories = array(), $parentRepositoryPath = null)
{
$privateShares = array();
$publicShares = array();
foreach ($shares as $id => $data) {
$type = $data["type"];
if ($operation == "delete") {
$this->deleteShare($type, $id, false, true);
continue;
}
if ($type == "minisite") {
$share = $this->loadShare($id);
$repo = ConfService::getRepositoryById($share["REPOSITORY"]);
} else {
if ($type == "repository") {
$repo = ConfService::getRepositoryById($id);
} else {
if ($type == "file") {
$publicLink = $this->loadShare($id);
}
}
}
if (isset($repo)) {
$oldNodeLabel = SystemTextEncoding::toUTF8($oldNode->getLabel());
$newNodeLabel = SystemTextEncoding::toUTF8($newNode->getLabel());
if ($newNode != null && $newNodeLabel != $oldNodeLabel && $repo->getDisplay() == $oldNodeLabel) {
$repo->setDisplay($newNodeLabel);
}
$cFilter = $repo->getContentFilter();
$path = $repo->getOption("PATH", true);
$save = false;
if (isset($cFilter)) {
if ($parentRepositoryPath !== null) {
$repo->addOption("PATH", $parentRepositoryPath);
} else {
$cFilter->movePath($oldNode->getPath(), $newNode->getPath());
$repo->setContentFilter($cFilter);
}
$save = true;
} else {
if (!empty($path)) {
$oldNodePath = SystemTextEncoding::toUTF8($oldNode->getPath());
$newNodePath = SystemTextEncoding::toUTF8($newNode->getPath());
$path = preg_replace("#" . preg_quote($oldNodePath, "#") . "\$#", $newNodePath, $path);
$repo->addOption("PATH", $path);
$save = true;
$collectRepositories[$repo->getId()] = $path;
}
}
if ($save) {
//ConfService::getConfStorageImpl()->saveRepository($repo, true);
ConfService::replaceRepository($repo->getId(), $repo);
}
$access = $repo->getOption("SHARE_ACCESS");
if (!empty($access) && $access == "PUBLIC") {
$publicShares[$id] = $data;
} else {
$privateShares[$id] = $data;
}
} else {
if (isset($publicLink) && is_array($publicLink) && isset($publicLink["FILE_PATH"])) {
$oldNodePath = SystemTextEncoding::toUTF8($oldNode->getPath());
$newNodePath = SystemTextEncoding::toUTF8($newNode->getPath());
$publicLink["FILE_PATH"] = str_replace($oldNodePath, $newNodePath, $publicLink["FILE_PATH"]);
$this->deleteShare("file", $id);
$this->storeShare($newNode->getRepositoryId(), $publicLink, "file", $id);
$privateShares[$id] = $data;
}
}
}
return array($privateShares, $publicShares);
}
示例4: migrateMetaSerialPlugin
public static function migrateMetaSerialPlugin($repositoryId, $dryRun)
{
$repo = ConfService::getRepositoryById($repositoryId);
if ($repo == null) {
throw new Exception("Cannot find repository!");
}
$sources = $repo->getOption("META_SOURCES");
if (!isset($sources["meta.serial"])) {
//throw new Exception("This repository does not have the meta.serial plugin!");
$sources["meta.serial"] = array("meta_file_name" => ".ajxp_meta", "meta_fields" => "comment_field,css_label", "meta_labels" => "Comment,Label");
}
if ($repo->hasParent()) {
throw new Exception("This repository is defined by a template or is shared, you should upgrade the parent instead!");
}
$oldMetaFileName = $sources["meta.serial"]["meta_file_name"];
$sources["metastore.serial"] = array("METADATA_FILE" => $oldMetaFileName, "UPGRADE_FROM_METASERIAL" => true);
$sources["meta.user"] = array("meta_fields" => $sources["meta.serial"]["meta_fields"], "meta_labels" => $sources["meta.serial"]["meta_labels"], "meta_visibility" => $sources["meta.serial"]["meta_visibility"]);
unset($sources["meta.serial"]);
$oldId = $repo->getId();
$repo->addOption("META_SOURCES", $sources);
$log = print_r($sources, true);
if (!$dryRun) {
ConfService::replaceRepository($oldId, $repo);
}
print "Will replace the META_SOURCES options with the following : <br><pre>" . $log . "</pre>";
}
示例5: 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;
}
示例6: switchAction
//.........这里部分代码省略.........
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()) {
$repository->setSlug();
ConfService::replaceRepository($repId, $repository);
}
if (AuthService::getLoggedUser() != null && AuthService::getLoggedUser()->getGroupPath() != null) {
$rgp = $repository->getGroupPath();
if ($rgp == null) {
$rgp = "/";
}
if (strlen($rgp) < strlen(AuthService::getLoggedUser()->getGroupPath())) {
$repository->setWriteable(false);
}
}
$nested = array();
$definitions = $plug->getConfigsDefinitions();
print "<repository index=\"{$repId}\"";
foreach ($repository as $name => $option) {
if (strstr($name, " ") > -1) {
continue;
}
if (!is_array($option)) {
if (is_bool($option)) {
$option = $option ? "true" : "false";
}
print " {$name}=\"" . SystemTextEncoding::toUTF8(AJXP_Utils::xmlEntities($option)) . "\" ";
} else {
if (is_array($option)) {
$nested[] = $option;
}
}
}
if (count($nested)) {
print ">";
foreach ($nested as $option) {
foreach ($option as $key => $optValue) {
示例7: createSharedRepository
//.........这里部分代码省略.........
}
$confDriver = ConfService::getConfStorageImpl();
foreach ($users as $userName) {
if (AuthService::userExists($userName)) {
// check that it's a child user
$userObject = $confDriver->createUserObject($userName);
if (ConfService::getCoreConf("ALLOW_CROSSUSERS_SHARING", "conf") != true && (!$userObject->hasParent() || $userObject->getParent() != $loggedUser->id)) {
return 102;
}
} else {
if ($httpVars["create_guest_user"] != "true" && !ConfService::getCoreConf("USER_CREATE_USERS", "conf") || AuthService::isReservedUserId($userName)) {
return 102;
}
if (!isset($httpVars["shared_pass"]) || $httpVars["shared_pass"] == "") {
return 100;
}
}
}
// CREATE SHARED OPTIONS
$options = $accessDriver->makeSharedRepositoryOptions($httpVars, $repository);
$customData = array();
foreach ($httpVars as $key => $value) {
if (substr($key, 0, strlen("PLUGINS_DATA_")) == "PLUGINS_DATA_") {
$customData[substr($key, strlen("PLUGINS_DATA_"))] = $value;
}
}
if (count($customData)) {
$options["PLUGINS_DATA"] = $customData;
}
if (isset($editingRepo)) {
$newRepo = $editingRepo;
if ($editingRepo->getDisplay() != $label) {
$newRepo->setDisplay($label);
ConfService::replaceRepository($httpVars["repository_id"], $newRepo);
}
$editingRepo->setDescription($description);
} else {
if ($repository->getOption("META_SOURCES")) {
$options["META_SOURCES"] = $repository->getOption("META_SOURCES");
foreach ($options["META_SOURCES"] as $index => $data) {
if (isset($data["USE_SESSION_CREDENTIALS"]) && $data["USE_SESSION_CREDENTIALS"] === true) {
$options["META_SOURCES"][$index]["ENCODED_CREDENTIALS"] = AJXP_Safe::getEncodedCredentialString();
}
}
}
$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");
}
}
示例8: switchAction
//.........这里部分代码省略.........
}
$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);
}
$nested = array();
print "<repository index=\"{$repId}\"";
foreach ($repository as $name => $option) {
if (strstr($name, " ") > -1) {
continue;
}
if (!is_array($option)) {
if (is_bool($option)) {
$option = $option ? "true" : "false";
}
print " {$name}=\"" . SystemTextEncoding::toUTF8(AJXP_Utils::xmlEntities($option)) . "\" ";
} else {
if (is_array($option)) {
$nested[] = $option;
}
}
}
if (count($nested)) {
print ">";
foreach ($nested as $option) {
foreach ($option as $key => $optValue) {
if (is_array($optValue) && count($optValue)) {
print "<param name=\"{$key}\"><![CDATA[" . json_encode($optValue) . "]]></param>";
} else {
if (is_bool($optValue)) {
$optValue = $optValue ? "true" : "false";
}
print "<param name=\"{$key}\" value=\"{$optValue}\"/>";
}
}
}
示例9: switchAction
//.........这里部分代码省略.........
} else {
print "/>";
}
$pServ = AJXP_PluginsService::getInstance();
$plug = $pServ->getPluginById("access." . $repository->accessType);
$manifest = $plug->getManifestRawContent("server_settings/param");
print "<ajxpdriver name=\"" . $repository->accessType . "\">{$manifest}</ajxpdriver>";
print "<metasources>";
$metas = $pServ->getPluginsByType("meta");
foreach ($metas as $metaPlug) {
print "<meta id=\"" . $metaPlug->getId() . "\">";
$manifest = $metaPlug->getManifestRawContent("server_settings/param");
print $manifest;
print "</meta>";
}
print "</metasources>";
AJXP_XMLWriter::close("admin_data");
exit(1);
break;
case "edit_repository_label":
case "edit_repository_data":
$repId = $httpVars["repository_id"];
$repo = ConfService::getRepositoryById($repId);
$res = 0;
if (isset($httpVars["newLabel"])) {
$newLabel = SystemTextEncoding::fromPostedFileName($httpVars["newLabel"]);
if ($this->repositoryExists($newLabel)) {
AJXP_XMLWriter::header();
AJXP_XMLWriter::sendMessage(null, $mess["ajxp_conf.50"]);
AJXP_XMLWriter::close();
exit(1);
}
$repo->setDisplay($newLabel);
$res = ConfService::replaceRepository($repId, $repo);
} else {
$options = array();
$this->parseParameters($httpVars, $options);
if (count($options)) {
foreach ($options as $key => $value) {
$repo->addOption($key, $value);
}
}
if (is_file(INSTALL_PATH . "/server/tests/plugins/test.ajxp_" . $repo->getAccessType() . ".php")) {
chdir(INSTALL_PATH . "/server/tests/plugins");
include INSTALL_PATH . "/server/tests/plugins/test.ajxp_" . $repo->getAccessType() . ".php";
$className = "ajxp_" . $repo->getAccessType();
$class = new $className();
$result = $class->doRepositoryTest($repo);
if (!$result) {
AJXP_XMLWriter::header();
AJXP_XMLWriter::sendMessage(null, $class->failedInfo);
AJXP_XMLWriter::close();
exit(1);
}
}
ConfService::replaceRepository($repId, $repo);
}
AJXP_XMLWriter::header();
if ($res == -1) {
AJXP_XMLWriter::sendMessage(null, $mess["ajxp_conf.53"]);
} else {
AJXP_XMLWriter::sendMessage($mess["ajxp_conf.54"], null);
AJXP_XMLWriter::reloadDataNode("", isset($httpVars["newLabel"]) ? SystemTextEncoding::fromPostedFileName($httpVars["newLabel"]) : false);
AJXP_XMLWriter::reloadRepositoryList();
}
AJXP_XMLWriter::close();
示例10: 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);
//.........这里部分代码省略.........
示例11: createSharedRepository
//.........这里部分代码省略.........
} else {
if ($httpVars["create_guest_user"] != "true" && !ConfService::getCoreConf("USER_CREATE_USERS", "conf") || AuthService::isReservedUserId($userName)) {
return 102;
}
if (!isset($httpVars["shared_pass"]) || $httpVars["shared_pass"] == "") {
return 100;
}
}
}
// CREATE SHARED OPTIONS
$options = $accessDriver->makeSharedRepositoryOptions($httpVars, $repository);
$customData = array();
foreach ($httpVars as $key => $value) {
if (substr($key, 0, strlen("PLUGINS_DATA_")) == "PLUGINS_DATA_") {
$customData[substr($key, strlen("PLUGINS_DATA_"))] = $value;
}
}
if (count($customData)) {
$options["PLUGINS_DATA"] = $customData;
}
if (isset($editingRepo)) {
$this->getShareStore()->testUserCanEditShare($editingRepo->getOwner());
$newRepo = $editingRepo;
$replace = false;
if ($editingRepo->getDisplay() != $label) {
$newRepo->setDisplay($label);
$replace = true;
}
if ($editingRepo->getDescription() != $description) {
$newRepo->setDescription($description);
$replace = true;
}
if ($replace) {
ConfService::replaceRepository($httpVars["repository_id"], $newRepo);
}
} 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)) {