本文整理汇总了PHP中ConfService::getRepositoryById方法的典型用法代码示例。如果您正苦于以下问题:PHP ConfService::getRepositoryById方法的具体用法?PHP ConfService::getRepositoryById怎么用?PHP ConfService::getRepositoryById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConfService
的用法示例。
在下文中一共展示了ConfService::getRepositoryById方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkPassword
public function checkPassword($login, $pass, $seed)
{
require_once AJXP_INSTALL_PATH . "/" . AJXP_PLUGINS_FOLDER . "/access.smb/smb.php";
$_SESSION["AJXP_SESSION_REMOTE_PASS"] = $pass;
$repoId = $this->options["REPOSITORY_ID"];
$repoObject = ConfService::getRepositoryById($repoId);
if (!isset($repoObject)) {
throw new Exception("Cannot find repository with id " . $repoId);
}
$path = "";
$basePath = $repoObject->getOption("PATH", true);
$basePath = str_replace("AJXP_USER", $login, $basePath);
$host = $repoObject->getOption("HOST");
$url = "smb://{$login}:{$pass}@" . $host . "/" . $basePath . "/";
try {
if (!is_dir($url)) {
$this->logDebug("SMB Login failure");
$_SESSION["AJXP_SESSION_REMOTE_PASS"] = '';
unset($_SESSION["COUNT"]);
unset($_SESSION["disk"]);
return false;
}
AJXP_Safe::storeCredentials($login, $pass);
} catch (Exception $e) {
return false;
}
return true;
}
示例2: initPath
/**
* Initialize the stream from the given path.
* Concretely, transform ajxp.smb:// into smb://
*
* @param string $path
* @return mixed Real path or -1 if currentListing contains the listing : original path converted to real path
*/
protected static function initPath($path, $streamType, $storeOpenContext = false, $skipZip = false)
{
$url = parse_url($path);
$repoId = $url["host"];
$repoObject = ConfService::getRepositoryById($repoId);
if (!isset($repoObject)) {
throw new Exception("Cannot find repository with id " . $repoId);
}
$path = $url["path"];
// Fix if the host is defined as //MY_HOST/path/to/folder
$host = str_replace("//", "", $repoObject->getOption("HOST"));
$credentials = "";
$safeCreds = AJXP_Safe::tryLoadingCredentialsFromSources($url, $repoObject);
if ($safeCreds["user"] != "" && $safeCreds["password"] != "") {
$login = $safeCreds["user"];
$pass = $safeCreds["password"];
$_SESSION["AJXP_SESSION_REMOTE_PASS"] = $pass;
$credentials = "{$login}:{$pass}@";
$domain = $repoObject->getOption("DOMAIN");
if ($domain != "") {
$credentials = $domain . "/" . $credentials;
}
}
$basePath = $repoObject->getOption("PATH");
$fullPath = "smb://" . $credentials . $host . "/";
//.$basePath."/".$path;
if ($basePath != "") {
$fullPath .= trim($basePath, "/\\");
}
if ($path != "") {
$fullPath .= ($path[0] == "/" ? "" : "/") . $path;
}
return $fullPath;
}
示例3: getWorkingRepositoryOptions
/**
* @return array
*/
protected function getWorkingRepositoryOptions()
{
$p = array();
$repo = $this->accessDriver->repository;
$clearParent = null;
// SPECIAL : QUOTA MUST BE COMPUTED ON PARENT REPOSITORY FOLDER
if ($repo->hasParent()) {
$parentOwner = $repo->getOwner();
if ($parentOwner !== null) {
$repo = ConfService::getRepositoryById($repo->getParentId());
$originalUser = AuthService::getLoggedUser();
$loggedUser = AuthService::getLoggedUser();
if (!$loggedUser->hasParent()) {
$loggedUser->setParent($parentOwner);
$clearParent = null;
} else {
$clearParent = $loggedUser->getParent();
}
$loggedUser->setResolveAsParent(true);
AuthService::updateUser($loggedUser);
}
}
$path = $repo->getOption("PATH");
$p["PATH"] = $path;
if (isset($originalUser)) {
$originalUser->setParent($clearParent);
$originalUser->setResolveAsParent(false);
AuthService::updateUser($originalUser);
}
return $p;
}
示例4: applyAction
public function applyAction($actionName, $httpVars, $fileVars)
{
$messages = ConfService::getMessages();
if ($actionName == "index") {
$repository = ConfService::getRepository();
$repositoryId = $repository->getId();
$userSelection = new UserSelection($repository, $httpVars);
if ($userSelection->isEmpty()) {
$userSelection->addFile("/");
}
$nodes = $userSelection->buildNodes($repository->driverInstance);
if (isset($httpVars["verbose"]) && $httpVars["verbose"] == "true") {
$this->verboseIndexation = true;
}
if (ConfService::backgroundActionsSupported() && !ConfService::currentContextIsCommandLine()) {
AJXP_Controller::applyActionInBackground($repositoryId, "index", $httpVars);
AJXP_XMLWriter::header();
AJXP_XMLWriter::triggerBgAction("check_index_status", array("repository_id" => $repositoryId), sprintf($messages["core.index.8"], $nodes[0]->getPath()), true, 2);
if (!isset($httpVars["inner_apply"])) {
AJXP_XMLWriter::close();
}
return null;
}
// GIVE BACK THE HAND TO USER
session_write_close();
foreach ($nodes as $node) {
$dir = $node->getPath() == "/" || is_dir($node->getUrl());
// SIMPLE FILE
if (!$dir) {
try {
$this->logDebug("Indexing - node.index " . $node->getUrl());
AJXP_Controller::applyHook("node.index", array($node));
} catch (Exception $e) {
$this->logDebug("Error Indexing Node " . $node->getUrl() . " (" . $e->getMessage() . ")");
}
} else {
try {
$this->recursiveIndexation($node);
} catch (Exception $e) {
$this->logDebug("Indexation of " . $node->getUrl() . " interrupted by error: (" . $e->getMessage() . ")");
}
}
}
} else {
if ($actionName == "check_index_status") {
$repoId = $httpVars["repository_id"];
list($status, $message) = $this->getIndexStatus(ConfService::getRepositoryById($repoId), AuthService::getLoggedUser());
if (!empty($status)) {
AJXP_XMLWriter::header();
AJXP_XMLWriter::triggerBgAction("check_index_status", array("repository_id" => $repoId), $message, true, 3);
AJXP_XMLWriter::close();
} else {
AJXP_XMLWriter::header();
AJXP_XMLWriter::triggerBgAction("info_message", array(), $messages["core.index.5"], true, 5);
AJXP_XMLWriter::close();
}
}
}
return null;
}
示例5: initPath
/**
* Initialize the stream from the given path.
* Concretely, transform ajxp.webdav:// into webdav://
*
* @param string $path
* @return mixed Real path or -1 if currentListing contains the listing : original path converted to real path
*/
protected static function initPath($path, $streamType, $storeOpenContext = false, $skipZip = false)
{
$url = parse_url($path);
$repoId = $url["host"];
$repoObject = ConfService::getRepositoryById($repoId);
if (!isset($repoObject)) {
throw new Exception("Cannot find repository with id " . $repoId);
}
$path = $url["path"];
$host = $repoObject->getOption("HOST");
$host = str_replace(array("http", "https"), array("webdav", "webdavs"), $host);
// MAKE SURE THERE ARE NO // OR PROBLEMS LIKE THAT...
$basePath = $repoObject->getOption("PATH");
if ($basePath[strlen($basePath) - 1] == "/") {
$basePath = substr($basePath, 0, -1);
}
if ($basePath[0] != "/") {
$basePath = "/{$basePath}";
}
$path = AJXP_Utils::securePath($path);
if ($path[0] == "/") {
$path = substr($path, 1);
}
// SHOULD RETURN webdav://host_server/uri/to/webdav/folder
return $host . $basePath . "/" . $path;
}
示例6: getRepository
/**
* @return Repository
*/
public function getRepository()
{
if (!isset($this->repository)) {
$this->repository = ConfService::getRepositoryById($this->repositoryId);
}
return $this->repository;
}
示例7: getWorkingPath
protected function getWorkingPath()
{
$repo = ConfService::getRepository();
if ($repo->hasParent()) {
$repo = ConfService::getRepositoryById($repo->getParentId());
}
$path = $repo->getOption("PATH");
return $path;
}
示例8: initPath
/**
* Initialize the stream from the given path.
* Concretely, transform ajxp.webdav:// into webdav://
*
* @param string $path
* @return mixed Real path or -1 if currentListing contains the listing : original path converted to real path
*/
protected static function initPath($path, $streamType, $storeOpenContext = false, $skipZip = false)
{
$url = parse_url($path);
$repoId = $url["host"];
$repoObject = ConfService::getRepositoryById($repoId);
if (!isset($repoObject)) {
$e = new Exception("Cannot find repository with id " . $repoId);
self::$lastException = $e;
throw $e;
}
$baseContainer = $repoObject->getOption("CONTAINER");
$p = "s3://" . $baseContainer . str_replace("//", "/", $url["path"]);
return $p;
}
示例9: replaceVars
protected function replaceVars($tplString, $mess, $rich = true)
{
$tplString = SystemTextEncoding::fromUTF8($tplString);
$repoId = $this->getNode()->getRepositoryId();
if (ConfService::getRepositoryById($repoId) != null) {
$repoLabel = ConfService::getRepositoryById($repoId)->getDisplay();
} else {
$repoLabel = "Repository";
}
$uLabel = "";
if (array_key_exists($this->getAuthor(), self::$usersCaches)) {
if (self::$usersCaches[$this->getAuthor()] != 'AJXP_USER_DONT_EXISTS') {
$uLabel = self::$usersCaches[$this->getAuthor()];
}
} else {
if (strstr($tplString, "AJXP_USER") !== false) {
if (AuthService::userExists($this->getAuthor())) {
$obj = ConfService::getConfStorageImpl()->createUserObject($this->getAuthor());
$uLabel = $obj->personalRole->filterParameterValue("core.conf", "USER_DISPLAY_NAME", AJXP_REPO_SCOPE_ALL, "");
self::$usersCaches[$this->getAuthor()] = $uLabel;
} else {
self::$usersCaches[$this->getAuthor()] = 'AJXP_USER_DONT_EXISTS';
}
}
}
if (empty($uLabel)) {
$uLabel = $this->getAuthor();
}
$em = $rich ? "<em>" : "";
$me = $rich ? "</em>" : "";
$replaces = array("AJXP_NODE_PATH" => $em . $this->getRoot($this->getNode()->getPath()) . $me, "AJXP_NODE_LABEL" => $em . $this->getNode()->getLabel() . $me, "AJXP_PARENT_PATH" => $em . $this->getRoot(dirname($this->getNode()->getPath())) . $me, "AJXP_PARENT_LABEL" => $em . $this->getRoot(basename(dirname($this->getNode()->getPath()))) . $me, "AJXP_REPOSITORY_ID" => $em . $repoId . $me, "AJXP_REPOSITORY_LABEL" => $em . $repoLabel . $me, "AJXP_LINK" => $this->getMainLink(), "AJXP_USER" => $uLabel, "AJXP_DATE" => SystemTextEncoding::fromUTF8(AJXP_Utils::relativeDate($this->getDate(), $mess)));
if ($replaces["AJXP_NODE_LABEL"] == $em . $me) {
$replaces["AJXP_NODE_LABEL"] = $em . "[" . $replaces["AJXP_REPOSITORY_LABEL"] . "]" . $me;
}
if ($replaces["AJXP_PARENT_LABEL"] == $em . $me) {
$replaces["AJXP_PARENT_LABEL"] = $em . "[" . $replaces["AJXP_REPOSITORY_LABEL"] . "]" . $me;
}
if ((strstr($tplString, "AJXP_TARGET_FOLDER") !== false || strstr($tplString, "AJXP_SOURCE_FOLDER")) && isset($this->secondaryNode)) {
$p = $this->secondaryNode->getPath();
if ($this->secondaryNode->isLeaf()) {
$p = $this->getRoot(dirname($p));
}
$replaces["AJXP_TARGET_FOLDER"] = $replaces["AJXP_SOURCE_FOLDER"] = $em . $p . $me;
}
if ((strstr($tplString, "AJXP_TARGET_LABEL") !== false || strstr($tplString, "AJXP_SOURCE_LABEL") !== false) && isset($this->secondaryNode)) {
$replaces["AJXP_TARGET_LABEL"] = $replaces["AJXP_SOURCE_LABEL"] = $em . $this->secondaryNode->getLabel() . $me;
}
return str_replace(array_keys($replaces), array_values($replaces), $tplString);
}
示例10: persistChangeHookToFeed
public function persistChangeHookToFeed(AJXP_Node $oldNode = null, AJXP_Node $newNode = null, $copy = false, $targetNotif = "new")
{
if (!$this->eventStore) {
return;
}
$n = $oldNode == null ? $newNode : $oldNode;
$repoId = $n->getRepositoryId();
$userId = AuthService::getLoggedUser()->getId();
$userGroup = AuthService::getLoggedUser()->getGroupPath();
$repository = ConfService::getRepositoryById($repoId);
$repositoryScope = $repository->securityScope();
$repositoryScope = $repositoryScope !== false ? $repositoryScope : "ALL";
$repositoryOwner = $repository->hasOwner() ? $repository->getOwner() : null;
$this->eventStore->persistEvent("node.change", func_get_args(), $repoId, $repositoryScope, $repositoryOwner, $userId, $userGroup);
}
示例11: stream_open
/**
* Opens the strem
*
* @param String $path Maybe in the form "ajxp.fs://repositoryId/pathToFile"
* @param String $mode
* @param unknown_type $options
* @param unknown_type $opened_path
* @return unknown
*/
function stream_open($path, $mode, $options, &$opened_path)
{
$url = parse_url($path);
$repoId = $url["host"];
$repoObject = ConfService::getRepositoryById($repoId);
if (!isset($repoObject)) {
throw new Exception("Cannot find repository with id " . $repoId);
}
$filePath = $repoObject->getOption("PATH") . "/" . $url["path"];
try {
$this->fp = @fopen($filePath, $mode, $options);
return $this->fp !== false;
} catch (Exception $e) {
return false;
}
}
示例12: initMeta
/**
*
* @param AbstractAccessDriver $accessDriver
*/
public function initMeta($accessDriver)
{
$this->accessDriver = $accessDriver;
// Override options with parent META SOURCE options
// Could be refined ?
if ($this->accessDriver->repository->hasParent()) {
$parentRepo = ConfService::getRepositoryById($this->accessDriver->repository->getParentId());
if ($parentRepo != null) {
$sources = $parentRepo->getOption("META_SOURCES");
$qParent = $sources["meta.quota"];
if (is_array($qParent)) {
$this->options = array_merge($this->options, $qParent);
}
}
}
}
示例13: initPath
/**
* Initialize the stream from the given path.
* Concretely, transform ajxp.webdav:// into webdav://
*
* @param string $path
* @return mixed Real path or -1 if currentListing contains the listing : original path converted to real path
*/
protected static function initPath($path, $streamType, $storeOpenContext = false, $skipZip = false)
{
$url = parse_url($path);
$repoId = $url["host"];
$repoObject = ConfService::getRepositoryById($repoId);
if (!isset($repoObject)) {
$e = new Exception("Cannot find repository with id " . $repoId);
self::$lastException = $e;
throw $e;
}
if (self::$cloudContext == null) {
self::$cloudContext = stream_context_create(array("swiftfs" => array('username' => $repoObject->getOption("USERNAME"), 'password' => $repoObject->getOption("PASSWORD"), 'tenantid' => $repoObject->getOption("TENANT_ID"), 'endpoint' => $repoObject->getOption("ENDPOINT"))));
}
$baseContainer = $repoObject->getOption("CONTAINER");
$p = "swiftfs://" . $baseContainer . str_replace("//", "/", $url["path"]);
return $p;
}
示例14: initPath
/**
* Initialize the stream from the given path.
* Concretely, transform ajxp.webdav:// into webdav://
*
* @param string $path
* @return mixed Real path or -1 if currentListing contains the listing : original path converted to real path
*/
protected static function initPath($path, $streamType, $storeOpenContext = false, $skipZip = false)
{
$url = AJXP_Utils::safeParseUrl($path);
$repoId = $url["host"];
$repoObject = ConfService::getRepositoryById($repoId);
if (!isset($repoObject)) {
$e = new Exception("Cannot find repository with id " . $repoId);
self::$lastException = $e;
throw $e;
}
$path = $url["path"];
$host = $repoObject->getOption("HOST");
$hostParts = parse_url($host);
if ($hostParts["scheme"] == "https" && !extension_loaded("openssl")) {
$e = new Exception("Warning you must have the openssl PHP extension loaded to connect an https server!");
self::$lastException = $e;
throw $e;
}
$credentials = AJXP_Safe::tryLoadingCredentialsFromSources($hostParts, $repoObject);
$user = $credentials["user"];
$password = $credentials["password"];
if ($user != null && $password != null) {
$host = ($hostParts["scheme"] == "https" ? "webdavs" : "webdav") . "://{$user}:{$password}@" . $hostParts["host"];
if (isset($hostParts["port"])) {
$host .= ":" . $hostParts["port"];
}
} else {
$host = str_replace(array("http", "https"), array("webdav", "webdavs"), $host);
}
// MAKE SURE THERE ARE NO // OR PROBLEMS LIKE THAT...
$basePath = $repoObject->getOption("PATH");
if ($basePath[strlen($basePath) - 1] == "/") {
$basePath = substr($basePath, 0, -1);
}
if ($basePath[0] != "/") {
$basePath = "/{$basePath}";
}
$path = AJXP_Utils::securePath($path);
if ($path[0] == "/") {
$path = substr($path, 1);
}
// SHOULD RETURN webdav://host_server/uri/to/webdav/folder
AJXP_Logger::debug(__CLASS__, __FUNCTION__, $host . $basePath . "/" . $path);
return $host . $basePath . "/" . $path;
}
示例15: checkPassword
public function checkPassword($login, $pass, $seed)
{
if (!defined('SMB4PHP_SMBCLIENT')) {
define('SMB4PHP_SMBCLIENT', $this->options["SMBCLIENT"]);
}
require_once AJXP_INSTALL_PATH . "/" . AJXP_PLUGINS_FOLDER . "/access.smb/smb.php";
$_SESSION["AJXP_SESSION_REMOTE_PASS"] = $pass;
$repoId = $this->options["REPOSITORY_ID"];
$repoObject = ConfService::getRepositoryById($repoId);
if (!isset($repoObject)) {
throw new Exception("Cannot find repository with id " . $repoId);
}
$path = "";
$basePath = $repoObject->getOption("PATH", true);
$basePath = str_replace("AJXP_USER", $login, $basePath);
$host = $repoObject->getOption("HOST");
$domain = $repoObject->getOption("DOMAIN", true);
$smbPath = $repoObject->getOption("PATH", true);
if (!empty($domain)) {
$login = $domain . $login;
}
$strTmp = "{$login}:{$pass}@" . $host . "/" . $basePath . "/";
$strTmp = str_replace("//", "/", $strTmp);
$url = "smbclient://" . $strTmp;
try {
if (!is_dir($url)) {
$this->logDebug("SMB Login failure");
$_SESSION["AJXP_SESSION_REMOTE_PASS"] = '';
foreach ($_SESSION as $key => $val) {
if (substr($key, -4) === "disk" && substr($key, 0, 4) == "smb_") {
unset($_SESSION[$key]);
}
}
return false;
}
AJXP_Safe::storeCredentials($login, $pass);
} catch (Exception $e) {
return false;
}
return true;
}