本文整理汇总了PHP中ConfService::createRepositoryFromArray方法的典型用法代码示例。如果您正苦于以下问题:PHP ConfService::createRepositoryFromArray方法的具体用法?PHP ConfService::createRepositoryFromArray怎么用?PHP ConfService::createRepositoryFromArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConfService
的用法示例。
在下文中一共展示了ConfService::createRepositoryFromArray方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: switchAction
//.........这里部分代码省略.........
break;
case "update_user_pwd":
if (!isset($_GET["user_id"]) || !isset($_GET["user_pwd"]) || !AuthService::userExists($_GET["user_id"]) || trim($_GET["user_pwd"]) == "") {
AJXP_XMLWriter::header();
AJXP_XMLWriter::sendMessage(null, "Wrong Arguments!");
AJXP_XMLWriter::close();
exit(1);
}
$res = AuthService::updatePassword($_GET["user_id"], $_GET["user_pwd"]);
AJXP_XMLWriter::header();
if ($res === true) {
AJXP_XMLWriter::sendMessage("Password changed successfully for user " . $_GET["user_id"], null);
} else {
AJXP_XMLWriter::sendMessage(null, "Cannot update password : {$res}");
}
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");
示例2: runTests
/**
* @static
* @param $outputArray
* @param $testedParams
* @return bool
*/
public static function runTests(&$outputArray, &$testedParams)
{
// At first, list folder in the tests subfolder
chdir(AJXP_TESTS_FOLDER);
$files = glob('*.php');
$outputArray = array();
$testedParams = array();
$passed = true;
foreach ($files as $file) {
require_once $file;
// Then create the test class
$testName = str_replace(".php", "", substr($file, 5));
if (!class_exists($testName)) {
continue;
}
$class = new $testName();
$result = $class->doTest();
if (!$result && $class->failedLevel != "info") {
$passed = false;
}
$outputArray[] = array("name" => $class->name, "result" => $result, "level" => $class->failedLevel, "info" => $class->failedInfo);
if (count($class->testedParams)) {
$testedParams = array_merge($testedParams, $class->testedParams);
}
}
// PREPARE REPOSITORY LISTS
$repoList = array();
$REPOSITORIES = array();
require_once "../classes/class.ConfService.php";
require_once "../classes/class.Repository.php";
include AJXP_CONF_PATH . "/bootstrap_repositories.php";
foreach ($REPOSITORIES as $index => $repo) {
$repoList[] = ConfService::createRepositoryFromArray($index, $repo);
}
// Try with the serialized repositories
if (is_file(AJXP_DATA_PATH . "/plugins/conf.serial/repo.ser")) {
$fileLines = file(AJXP_DATA_PATH . "/plugins/conf.serial/repo.ser");
$repos = unserialize($fileLines[0]);
$repoList = array_merge($repoList, $repos);
}
// NOW TRY THE PLUGIN TESTS
chdir(AJXP_INSTALL_PATH . "/" . AJXP_PLUGINS_FOLDER);
$files = glob('access.*/test.*.php');
foreach ($files as $file) {
require_once $file;
// Then create the test class
list($accessFolder, $testFileName) = explode("/", $file);
$testName = str_replace(".php", "", substr($testFileName, 5) . "Test");
$class = new $testName();
foreach ($repoList as $repository) {
if ($repository->isTemplate || $repository->getParentId() != null) {
continue;
}
$result = $class->doRepositoryTest($repository);
if ($result === false || $result === true) {
if (!$result && $class->failedLevel != "info") {
$passed = false;
}
$outputArray[] = array("name" => $class->name . "\n Testing repository : " . $repository->getDisplay(), "result" => $result, "level" => $class->failedLevel, "info" => $class->failedInfo);
if (count($class->testedParams)) {
$testedParams = array_merge($testedParams, $class->testedParams);
}
}
}
}
return $passed;
}
示例3: runTests
function runTests(&$outputArray, &$testedParams)
{
// At first, list folder in the tests subfolder
chdir(INSTALL_PATH . '/server/tests');
$files = glob('*.php');
$outputArray = array();
$testedParams = array();
$passed = true;
foreach ($files as $file) {
require_once $file;
// Then create the test class
$testName = str_replace(".php", "", substr($file, 5));
$class = new $testName();
$result = $class->doTest();
if (!$result && $class->failedLevel != "info") {
$passed = false;
}
$outputArray[] = array("name" => $class->name, "result" => $result, "level" => $class->failedLevel, "info" => $class->failedInfo);
if (count($class->testedParams)) {
$testedParams = array_merge($testedParams, $class->testedParams);
}
}
// PREPARE REPOSITORY LISTS
$repoList = array();
require_once "../classes/class.ConfService.php";
require_once "../classes/class.Repository.php";
include "../conf/conf.php";
foreach ($REPOSITORIES as $index => $repo) {
$repoList[] = ConfService::createRepositoryFromArray($index, $repo);
}
// Try with the serialized repositories
if (is_file("../conf/repo.ser")) {
$fileLines = file("../conf/repo.ser");
$repos = unserialize($fileLines[0]);
$repoList = array_merge($repoList, $repos);
}
// NOW TRY THE PLUGIN TESTS
chdir(INSTALL_PATH . '/server/tests/plugins');
$files = glob('*.php');
foreach ($files as $file) {
require_once $file;
// Then create the test class
$testName = str_replace(".php", "", substr($file, 5)) . "Test";
$class = new $testName();
foreach ($repoList as $repository) {
$result = $class->doRepositoryTest($repository);
if ($result === false || $result === true) {
if (!$result && $class->failedLevel != "info") {
$passed = false;
}
$outputArray[] = array("name" => $class->name . "\n Testing repository : " . $repository->getDisplay(), "result" => $result, "level" => $class->failedLevel, "info" => $class->failedInfo);
if (count($class->testedParams)) {
$testedParams = array_merge($testedParams, $class->testedParams);
}
}
}
}
return $passed;
}
示例4: switchAction
//.........这里部分代码省略.........
print "</template>";
}
AJXP_XMLWriter::close("repository_templates");
break;
case "create_repository":
$repDef = $httpVars;
$isTemplate = isset($httpVars["sf_checkboxes_active"]);
unset($repDef["get_action"]);
unset($repDef["sf_checkboxes_active"]);
if (isset($httpVars["json_data"])) {
$repDef = json_decode(SystemTextEncoding::magicDequote($httpVars["json_data"]), true);
$options = $repDef["DRIVER_OPTIONS"];
} else {
$options = array();
$this->parseParameters($repDef, $options, null, true);
}
if (count($options)) {
$repDef["DRIVER_OPTIONS"] = $options;
unset($repDef["DRIVER_OPTIONS"]["AJXP_GROUP_PATH_PARAMETER"]);
}
if (strstr($repDef["DRIVER"], "ajxp_template_") !== false) {
$templateId = substr($repDef["DRIVER"], 14);
$templateRepo = ConfService::getRepositoryById($templateId);
$newRep = $templateRepo->createTemplateChild($repDef["DISPLAY"], $repDef["DRIVER_OPTIONS"]);
if (isset($repDef["AJXP_SLUG"])) {
$newRep->setSlug($repDef["AJXP_SLUG"]);
}
} else {
if ($currentUserIsGroupAdmin) {
throw new Exception("You are not allowed to create a workspace from a driver. Use a template instead.");
}
$pServ = AJXP_PluginsService::getInstance();
$driver = $pServ->getPluginByTypeName("access", $repDef["DRIVER"]);
$newRep = ConfService::createRepositoryFromArray(0, $repDef);
$testFile = $driver->getBaseDir() . "/test." . $newRep->getAccessType() . "Access.php";
if (!$isTemplate && is_file($testFile)) {
//chdir(AJXP_TESTS_FOLDER."/plugins");
$className = $newRep->getAccessType() . "AccessTest";
if (!class_exists($className)) {
include $testFile;
}
$class = new $className();
$result = $class->doRepositoryTest($newRep);
if (!$result) {
AJXP_XMLWriter::header();
AJXP_XMLWriter::sendMessage(null, $class->failedInfo);
AJXP_XMLWriter::close();
return;
}
}
// 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");
}
示例5: switchAction
//.........这里部分代码省略.........
$repositories = ConfService::getRepositoriesList();
foreach ($repositories as $repo) {
if (!$repo->isTemplate) {
continue;
}
$repoId = $repo->getUniqueId();
$repoLabel = $repo->getDisplay();
$repoType = $repo->getAccessType();
print "<template repository_id=\"{$repoId}\" repository_label=\"{$repoLabel}\" repository_type=\"{$repoType}\">";
foreach ($repo->getOptionsDefined() as $optionName) {
print "<option name=\"{$optionName}\"/>";
}
print "</template>";
}
AJXP_XMLWriter::close("repository_templates");
break;
case "create_repository":
$options = array();
$repDef = $httpVars;
$isTemplate = isset($httpVars["sf_checkboxes_active"]);
unset($repDef["get_action"]);
unset($repDef["sf_checkboxes_active"]);
$this->parseParameters($repDef, $options);
if (count($options)) {
$repDef["DRIVER_OPTIONS"] = $options;
}
if (strstr($repDef["DRIVER"], "ajxp_template_") !== false) {
$templateId = substr($repDef["DRIVER"], 14);
$templateRepo = ConfService::getRepositoryById($templateId);
$newRep = $templateRepo->createTemplateChild($repDef["DISPLAY"], $repDef["DRIVER_OPTIONS"]);
} else {
$pServ = AJXP_PluginsService::getInstance();
$driver = $pServ->getPluginByTypeName("access", $repDef["DRIVER"]);
$newRep = ConfService::createRepositoryFromArray(0, $repDef);
$testFile = $driver->getBaseDir() . "/test." . $newRep->getAccessType() . "Access.php";
if (!$isTemplate && is_file($testFile)) {
//chdir(AJXP_TESTS_FOLDER."/plugins");
include $testFile;
$className = $newRep->getAccessType() . "AccessTest";
$class = new $className();
$result = $class->doRepositoryTest($newRep);
if (!$result) {
AJXP_XMLWriter::header();
AJXP_XMLWriter::sendMessage(null, $class->failedInfo);
AJXP_XMLWriter::close();
return;
}
}
// 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;
}
示例6: initRepositoriesList
/**
* @param array $repositories
* @return array
*/
function initRepositoriesList($defaultRepositories)
{
// APPEND CONF FILE REPOSITORIES
$objList = array();
foreach ($defaultRepositories as $index => $repository) {
$repo = ConfService::createRepositoryFromArray($index, $repository);
$repo->setWriteable(false);
$objList[$repo->getId()] = $repo;
}
// LOAD FROM DRIVER
$confDriver = ConfService::getConfStorageImpl();
$drvList = $confDriver->listRepositories();
if (is_array($drvList)) {
foreach ($drvList as $repoId => $repoObject) {
$repoObject->setId($repoId);
$drvList[$repoId] = $repoObject;
}
$objList = array_merge($objList, $drvList);
}
return $objList;
}
示例7: buildVirtualRepository
/**
* @return \Repository
*/
public function buildVirtualRepository()
{
$repositoryId = "ocs_remote_share_" . $this->getOcsToken();
// Create REPO
$parts = parse_url($this->getOcsDavUrl());
$data = array("DISPLAY" => $this->getDocumentName(), "DESCRIPTION" => "Shared by " . $this->getSender(), "AJXP_SLUG" => "remote-" . $this->getOcsToken(), "DRIVER" => "webdav", "DRIVER_OPTIONS" => array("HOST" => $parts["scheme"] . "://" . $parts["host"], "PATH" => $parts["path"], "USER" => $this->getOcsToken(), "PASS" => $this->hasPassword() ? $this->getPassword() : "", "DEFAULT_RIGHTS" => "", "META_SOURCES" => array()));
$remoteHost = $this->getHost();
$remoteHost = !empty($remoteHost) ? '@' . $remoteHost : ' [remote]';
$repo = \ConfService::createRepositoryFromArray($repositoryId, $data);
$repo->setRepositoryType("remote");
$repo->setAccessStatus($this->getStatus() == OCS_INVITATION_STATUS_ACCEPTED ? "accepted" : "");
$repo->setWriteable(false);
$repo->setOwnerData(null, $this->getSender() . $remoteHost);
if ($this->isDocumentIsLeaf()) {
$contentFilter = new \ContentFilter(array());
$contentFilter->filters["/" . $this->getDocumentName()] = "/";
// . $this->getDocumentName();
$repo->setContentFilter($contentFilter);
}
return $repo;
}
示例8: switchAction
//.........这里部分代码省略.........
break;
case "update_user_pwd":
if (!isset($httpVars["user_id"]) || !isset($httpVars["user_pwd"]) || !AuthService::userExists($httpVars["user_id"]) || trim($httpVars["user_pwd"]) == "") {
AJXP_XMLWriter::header();
AJXP_XMLWriter::sendMessage(null, $mess["ajxp_conf.61"]);
AJXP_XMLWriter::close();
exit(1);
}
$res = AuthService::updatePassword($httpVars["user_id"], $httpVars["user_pwd"]);
AJXP_XMLWriter::header();
if ($res === true) {
AJXP_XMLWriter::sendMessage($mess["ajxp_conf.48"] . $httpVars["user_id"], null);
} else {
AJXP_XMLWriter::sendMessage(null, $mess["ajxp_conf.49"] . " : {$res}");
}
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 = $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();