/** * Filter the very basic keywords from the XML : AJXP_USER, AJXP_INSTALL_PATH, AJXP_DATA_PATH * Calls the vars.filter hooks. * @static * @param $value * @return mixed|string */ public static function filter($value) { if (is_string($value) && strpos($value, "AJXP_USER") !== false) { if (AuthService::usersEnabled()) { $loggedUser = AuthService::getLoggedUser(); if ($loggedUser != null) { $loggedUser = $loggedUser->getId(); $value = str_replace("AJXP_USER", $loggedUser, $value); } else { return ""; } } else { $value = str_replace("AJXP_USER", "shared", $value); } } if (is_string($value) && strpos($value, "AJXP_INSTALL_PATH") !== false) { $value = str_replace("AJXP_INSTALL_PATH", AJXP_INSTALL_PATH, $value); } if (is_string($value) && strpos($value, "AJXP_DATA_PATH") !== false) { $value = str_replace("AJXP_DATA_PATH", AJXP_DATA_PATH, $value); } $tab = array(&$value); AJXP_Controller::applyIncludeHook("vars.filter", $tab); return $value; }
/** * Filter the very basic keywords from the XML : AJXP_USER, AJXP_INSTALL_PATH, AJXP_DATA_PATH * Calls the vars.filter hooks. * @static * @param $value * @return mixed|string */ public static function filter($value) { if (is_string($value) && strpos($value, "AJXP_USER") !== false) { if (AuthService::usersEnabled()) { $loggedUser = AuthService::getLoggedUser(); if ($loggedUser != null) { if ($loggedUser->hasParent() && $loggedUser->getResolveAsParent()) { $loggedUserId = $loggedUser->getParent(); } else { $loggedUserId = $loggedUser->getId(); } $value = str_replace("AJXP_USER", $loggedUserId, $value); } else { return ""; } } else { $value = str_replace("AJXP_USER", "shared", $value); } } if (is_string($value) && strpos($value, "AJXP_GROUP_PATH") !== false) { if (AuthService::usersEnabled()) { $loggedUser = AuthService::getLoggedUser(); if ($loggedUser != null) { $gPath = $loggedUser->getGroupPath(); $value = str_replace("AJXP_GROUP_PATH_FLAT", str_replace("/", "_", trim($gPath, "/")), $value); $value = str_replace("AJXP_GROUP_PATH", $gPath, $value); } else { return ""; } } else { $value = str_replace(array("AJXP_GROUP_PATH", "AJXP_GROUP_PATH_FLAT"), "shared", $value); } } if (is_string($value) && strpos($value, "AJXP_INSTALL_PATH") !== false) { $value = str_replace("AJXP_INSTALL_PATH", AJXP_INSTALL_PATH, $value); } if (is_string($value) && strpos($value, "AJXP_DATA_PATH") !== false) { $value = str_replace("AJXP_DATA_PATH", AJXP_DATA_PATH, $value); } $tab = array(&$value); AJXP_Controller::applyIncludeHook("vars.filter", $tab); return $value; }
/** * Dynamically replace XML keywords with their live values. * AJXP_SERVER_ACCESS, AJXP_MIMES_*,AJXP_ALL_MESSAGES, etc. * @static * @param string $xml * @param bool $stripSpaces * @return mixed */ public static function replaceAjxpXmlKeywords($xml, $stripSpaces = false) { $messages = ConfService::getMessages(); $confMessages = ConfService::getMessagesConf(); $matches = array(); if (isset($_SESSION["AJXP_SERVER_PREFIX_URI"])) { //$xml = str_replace("AJXP_THEME_FOLDER", $_SESSION["AJXP_SERVER_PREFIX_URI"].AJXP_THEME_FOLDER, $xml); $xml = str_replace("AJXP_SERVER_ACCESS", $_SESSION["AJXP_SERVER_PREFIX_URI"] . AJXP_SERVER_ACCESS, $xml); } else { //$xml = str_replace("AJXP_THEME_FOLDER", AJXP_THEME_FOLDER, $xml); $xml = str_replace("AJXP_SERVER_ACCESS", AJXP_SERVER_ACCESS, $xml); } $xml = str_replace("AJXP_APPLICATION_TITLE", ConfService::getCoreConf("APPLICATION_TITLE"), $xml); $xml = str_replace("AJXP_MIMES_EDITABLE", AJXP_Utils::getAjxpMimes("editable"), $xml); $xml = str_replace("AJXP_MIMES_IMAGE", AJXP_Utils::getAjxpMimes("image"), $xml); $xml = str_replace("AJXP_MIMES_AUDIO", AJXP_Utils::getAjxpMimes("audio"), $xml); $xml = str_replace("AJXP_MIMES_ZIP", AJXP_Utils::getAjxpMimes("zip"), $xml); $authDriver = ConfService::getAuthDriverImpl(); if ($authDriver != NULL) { $loginRedirect = $authDriver->getLoginRedirect(); $xml = str_replace("AJXP_LOGIN_REDIRECT", $loginRedirect !== false ? "'" . $loginRedirect . "'" : "false", $xml); } $xml = str_replace("AJXP_REMOTE_AUTH", "false", $xml); $xml = str_replace("AJXP_NOT_REMOTE_AUTH", "true", $xml); $xml = str_replace("AJXP_ALL_MESSAGES", "MessageHash=" . json_encode(ConfService::getMessages()) . ";", $xml); if (preg_match_all("/AJXP_MESSAGE(\\[.*?\\])/", $xml, $matches, PREG_SET_ORDER)) { foreach ($matches as $match) { $messId = str_replace("]", "", str_replace("[", "", $match[1])); $xml = str_replace("AJXP_MESSAGE[{$messId}]", $messages[$messId], $xml); } } if (preg_match_all("/CONF_MESSAGE(\\[.*?\\])/", $xml, $matches, PREG_SET_ORDER)) { foreach ($matches as $match) { $messId = str_replace(array("[", "]"), "", $match[1]); $message = $messId; if (array_key_exists($messId, $confMessages)) { $message = $confMessages[$messId]; } $xml = str_replace("CONF_MESSAGE[{$messId}]", AJXP_Utils::xmlEntities($message), $xml); } } if (preg_match_all("/MIXIN_MESSAGE(\\[.*?\\])/", $xml, $matches, PREG_SET_ORDER)) { foreach ($matches as $match) { $messId = str_replace(array("[", "]"), "", $match[1]); $message = $messId; if (array_key_exists($messId, $confMessages)) { $message = $confMessages[$messId]; } $xml = str_replace("MIXIN_MESSAGE[{$messId}]", AJXP_Utils::xmlEntities($message), $xml); } } if ($stripSpaces) { $xml = preg_replace("/[\n\r]?/", "", $xml); $xml = preg_replace("/\t/", " ", $xml); } $xml = str_replace(array('xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"', 'xsi:noNamespaceSchemaLocation="file:../core.ajaxplorer/ajxp_registry.xsd"'), "", $xml); $tab = array(&$xml); AJXP_Controller::applyIncludeHook("xml.filter", $tab); return $xml; }
/** * Instantiate a new AbstractAjxpUser * * @param String $userId * @return AbstractAjxpUser */ public function createUserObject($userId) { $kvCache = ConfService::getInstance()->getKeyValueCache(); $test = $kvCache->fetch("pydio:user:"******"AbstractAjxpUser")) { if ($test->personalRole == null) { $test->personalRole = $test->roles["AJXP_USR_/" . $userId]; } $test->recomputeMergedRole(); return $test; } $userId = AuthService::filterUserSensitivity($userId); $abstractUser = $this->instantiateAbstractUserImpl($userId); if (!$abstractUser->storageExists()) { AuthService::updateDefaultRights($abstractUser); } AuthService::updateAutoApplyRole($abstractUser); AuthService::updateAuthProvidedData($abstractUser); $args = array(&$abstractUser); AJXP_Controller::applyIncludeHook("include.user.updateUserObject", $args); $kvCache->save("pydio:user:" . $userId, $abstractUser); return $abstractUser; }
/** * @param $scope String "user", "all" * @param bool $includeShared * @return array */ protected function initRepositoriesListInst($scope = "user", $includeShared = true) { // APPEND CONF FILE REPOSITORIES $loggedUser = AuthService::getLoggedUser(); $objList = array(); if ($loggedUser != null) { $l = $loggedUser->getLock(); if (!empty($l)) { return $objList; } } foreach ($this->configs["DEFAULT_REPOSITORIES"] as $index => $repository) { $repo = self::createRepositoryFromArray($index, $repository); if ($scope == "user" && $loggedUser != null && !self::repositoryIsAccessible($index, $repo, $loggedUser)) { continue; } $repo->setWriteable(false); $objList["" . $repo->getId()] = $repo; } // LOAD FROM DRIVER $confDriver = self::getConfStorageImpl(); if ($scope == "user") { $acls = array(); if (AuthService::getLoggedUser() != null) { $acls = AuthService::getLoggedUser()->mergedRole->listAcls(true); } if (!count($acls)) { $drvList = array(); } else { $criteria = array("uuid" => array_keys($acls)); $drvList = $confDriver->listRepositoriesWithCriteria($criteria); } } else { if ($includeShared) { $drvList = $confDriver->listRepositories(); } else { $drvList = $confDriver->listRepositoriesWithCriteria(array("owner_user_id" => AJXP_FILTER_EMPTY)); } } if (is_array($drvList)) { /** * @var $drvList Repository[] */ foreach ($drvList as $repoId => $repoObject) { $driver = AJXP_PluginsService::getInstance()->getPluginByTypeName("access", $repoObject->getAccessType()); if (!is_object($driver) || !$driver->isEnabled()) { unset($drvList[$repoId]); } else { $repoObject->setId($repoId); $drvList[$repoId] = $repoObject; } if ($repoObject->hasParent() && !ConfService::findRepositoryByIdOrAlias($repoObject->getParentId())) { AJXP_Logger::error(__CLASS__, __FUNCTION__, "Disabling repository " . $repoObject->getSlug() . " as parent cannot be correctly loaded."); unset($drvList[$repoId]); } } foreach ($drvList as $key => $value) { $objList[$key] = $value; } } $args = array(&$objList); AJXP_Controller::applyIncludeHook("sec.access_ws", $args); return $objList; }
/** * See static method * @param $repoId * @return Repository|null */ public function getRepositoryByIdInst($repoId) { if (isset($this->configs["REPOSITORIES"]) && isset($this->configs["REPOSITORIES"][$repoId])) { return $this->configs["REPOSITORIES"][$repoId]; } if (isset($this->configs["REPOSITORY"]) && $this->configs["REPOSITORY"]->getId() . "" == $repoId) { return $this->configs["REPOSITORY"]; } $test = CacheService::fetch(AJXP_CACHE_SERVICE_NS_SHARED, "repository:" . $repoId); if ($test !== false) { return $test; } $test = $this->getConfStorageImpl()->getRepositoryById($repoId); if ($test != null) { CacheService::save(AJXP_CACHE_SERVICE_NS_SHARED, "repository:" . $repoId, $test); return $test; } // Finally try to search in default repositories if (isset($this->configs["DEFAULT_REPOSITORIES"]) && isset($this->configs["DEFAULT_REPOSITORIES"][$repoId])) { $repo = self::createRepositoryFromArray($repoId, $this->configs["DEFAULT_REPOSITORIES"][$repoId]); $repo->setWriteable(false); CacheService::save(AJXP_CACHE_SERVICE_NS_SHARED, "repository:" . $repoId, $repo); return $repo; } $hookedRepo = null; $args = array($repoId, &$hookedRepo); AJXP_Controller::applyIncludeHook("repository.search", $args); if ($hookedRepo !== null) { return $hookedRepo; } return null; }