diff --git a/core/src/cmd.php b/core/src/cmd.php index a85194850b..edf611452c 100644 --- a/core/src/cmd.php +++ b/core/src/cmd.php @@ -189,7 +189,7 @@ // DRIVERS BELOW NEED IDENTIFICATION CHECK if (!AuthService::usersEnabled() || ConfService::getCoreConf("ALLOW_GUEST_BROWSING", "auth") || AuthService::getLoggedUser()!=null) { $confDriver = ConfService::getConfStorageImpl(); - $Driver = ConfService::loadRepositoryDriver(); + $Driver = ConfService::loadDriverForRepository(ConfService::getRepository()); } AJXP_PluginsService::getInstance()->initActivePlugins(); require_once(AJXP_BIN_FOLDER."/class.AJXP_Controller.php"); diff --git a/core/src/core/classes/class.ConfService.php b/core/src/core/classes/class.ConfService.php index c7182332bd..d7574265fe 100644 --- a/core/src/core/classes/class.ConfService.php +++ b/core/src/core/classes/class.ConfService.php @@ -262,8 +262,8 @@ public static function switchRootDir($rootDirIndex = -1, $temporary = false) */ public function switchRootDirInst($rootDirIndex=-1, $temporary=false) { - $currentRepos = $this->getLoadedRepositories(); if ($rootDirIndex == -1) { + $currentRepos = $this->getLoadedRepositories(); if (isSet($_SESSION['REPO_ID']) && array_key_exists($_SESSION['REPO_ID'], $currentRepos)) { $this->configs["REPOSITORY"] = $currentRepos[$_SESSION['REPO_ID']]; } else { @@ -272,6 +272,11 @@ public function switchRootDirInst($rootDirIndex=-1, $temporary=false) $_SESSION['REPO_ID'] = $keys[0]; } } else { + /* + if (isSet($this->configs["REPOSITORY"]) && $this->configs["REPOSITORY"] == $rootDirIndex) { + return; + } + */ if ($temporary && isSet($_SESSION['REPO_ID'])) { $crtId = $_SESSION['REPO_ID']; if ($crtId != $rootDirIndex && !isSet($_SESSION['SWITCH_BACK_REPO_ID'])) { @@ -283,7 +288,11 @@ public function switchRootDirInst($rootDirIndex=-1, $temporary=false) $_SESSION['PREVIOUS_REPO_ID'] = $crtId; //AJXP_Logger::debug("switching back to $rootDirIndex"); } - $this->configs["REPOSITORY"] = $currentRepos[$rootDirIndex]; + if (isSet($this->configs["REPOSITORIES"]) && isSet($this->configs["REPOSITORIES"][$rootDirIndex])) { + $this->configs["REPOSITORY"] = $this->configs["REPOSITORIES"][$rootDirIndex]; + } else { + $this->configs["REPOSITORY"] = ConfService::getRepositoryById($rootDirIndex); + } $_SESSION['REPO_ID'] = $rootDirIndex; if(isSet($this->configs["ACCESS_DRIVER"])) unset($this->configs["ACCESS_DRIVER"]); } @@ -632,10 +641,15 @@ public static function getRepositoryById($repoId) */ public function getRepositoryByIdInst($repoId) { + /* $currentRepos = $this->getLoadedRepositories(); if (isSet($currentRepos[$repoId])) { return $currentRepos[$repoId]; } + */ + if (isSet($this->configs["REPOSITORIES"]) && isSet($this->configs["REPOSITORIES"][$repoId])) { + return $this->configs["REPOSITORIES"][$repoId]; + } return $this->getConfStorageImpl()->getRepositoryById($repoId); } @@ -662,7 +676,9 @@ public function getRepositoryByAliasInstDefaults($repoAlias) $conf = $this->configs["DEFAULT_REPOSITORIES"]; foreach ($conf as $repoId => $repoDef) { if ($repoDef["AJXP_SLUG"] == $repoAlias) { - return $this->getRepositoryByIdInst($repoId); + $repo = self::createRepositoryFromArray($repoId, $repoDef); + $repo->setWriteable(false); + return $repo; } } return null; diff --git a/core/src/core/classes/sabredav/ajaxplorer/class.AJXP_Sabre_AuthBackendDigest.php b/core/src/core/classes/sabredav/ajaxplorer/class.AJXP_Sabre_AuthBackendDigest.php index 71bfe54662..b2bb1dac81 100644 --- a/core/src/core/classes/sabredav/ajaxplorer/class.AJXP_Sabre_AuthBackendDigest.php +++ b/core/src/core/classes/sabredav/ajaxplorer/class.AJXP_Sabre_AuthBackendDigest.php @@ -79,7 +79,7 @@ public function authenticate(Sabre\DAV\Server $server, $realm) if ($success === false) { throw new Sabre\DAV\Exception\NotAuthenticated(); } - ConfService::loadRepositoryDriver(); + ConfService::switchRootDir($this->repositoryId); return true; } diff --git a/core/src/core/classes/sabredav/ajaxplorer/class.AJXP_Sabre_Node.php b/core/src/core/classes/sabredav/ajaxplorer/class.AJXP_Sabre_Node.php index 9d57c412bd..3d8632df59 100755 --- a/core/src/core/classes/sabredav/ajaxplorer/class.AJXP_Sabre_Node.php +++ b/core/src/core/classes/sabredav/ajaxplorer/class.AJXP_Sabre_Node.php @@ -58,12 +58,12 @@ public function __construct($path, $repository, $accessDriver = null) public function getAccessDriver() { if (!isset($this->accessDriver)) { - $RID = $this->repository->getId(); - ConfService::switchRootDir($RID); + //$RID = $this->repository->getId(); + //ConfService::switchRootDir($RID); ConfService::getConfStorageImpl(); - $this->accessDriver = ConfService::loadRepositoryDriver(); + $this->accessDriver = ConfService::loadDriverForRepository($this->repository); if (!$this->accessDriver instanceof AjxpWrapperProvider) { - throw new Sabre\DAV\Exception\FileNotFound( $RID ); + throw new Sabre\DAV\Exception\NotFound( $this->repository->getId() ); } $this->accessDriver->detectStreamWrapper(true); }