/** * @param string $repoId * @param Repository $repoObject * @param array $exposed * @param array $streams * @param AbstractAjxpUser $loggedUser * @param string $accessStatus * @return string * @throws Exception */ public static function repositoryToXML($repoId, $repoObject, $exposed, $streams, $loggedUser, $accessStatus = "") { $statusString = " repository_type=\"" . $repoObject->getRepositoryType() . "\""; if (empty($accessStatus)) { $accessStatus = $repoObject->getAccessStatus(); } if (!empty($accessStatus)) { $statusString .= " access_status=\"{$accessStatus}\" "; } else { if ($loggedUser != null) { $lastConnected = $loggedUser->getArrayPref("repository_last_connected", $repoId); if (!empty($lastConnected)) { $statusString .= " last_connection=\"{$lastConnected}\" "; } } } $streamString = ""; if (in_array($repoObject->accessType, $streams)) { $streamString = "allowCrossRepositoryCopy=\"true\""; } if ($repoObject->getUniqueUser()) { $streamString .= " user_editable_repository=\"true\" "; } if ($repoObject->hasContentFilter()) { $streamString .= " hasContentFilter=\"true\""; } $slugString = ""; $slug = $repoObject->getSlug(); if (!empty($slug)) { $slugString = "repositorySlug=\"{$slug}\""; } $isSharedString = ""; $currentUserIsOwner = false; $ownerLabel = null; if ($repoObject->hasOwner()) { $uId = $repoObject->getOwner(); if (AuthService::usersEnabled() && AuthService::getLoggedUser()->getId() == $uId) { $currentUserIsOwner = true; } $label = ConfService::getUserPersonalParameter("USER_DISPLAY_NAME", $uId, "core.conf", $uId); $ownerLabel = $label; $isSharedString = 'owner="' . AJXP_Utils::xmlEntities($label) . '"'; } if ($repoObject->securityScope() == "USER" || $currentUserIsOwner) { $streamString .= " userScope=\"true\""; } $descTag = ""; $public = false; if (!empty($_SESSION["CURRENT_MINISITE"])) { $public = true; } $description = $repoObject->getDescription($public, $ownerLabel); if (!empty($description)) { $descTag = '<description>' . AJXP_Utils::xmlEntities($description, true) . '</description>'; } $roleString = ""; if ($loggedUser != null) { $merged = $loggedUser->mergedRole; $params = array(); foreach ($exposed as $exposed_prop) { $metaOptions = $repoObject->getOption("META_SOURCES"); if (!isset($metaOptions[$exposed_prop["PLUGIN_ID"]])) { continue; } $value = $exposed_prop["DEFAULT"]; if (isset($metaOptions[$exposed_prop["PLUGIN_ID"]][$exposed_prop["NAME"]])) { $value = $metaOptions[$exposed_prop["PLUGIN_ID"]][$exposed_prop["NAME"]]; } $value = $merged->filterParameterValue($exposed_prop["PLUGIN_ID"], $exposed_prop["NAME"], $repoId, $value); if ($value !== null) { if ($value === true || $value === false) { $value = $value === true ? "true" : "false"; } $params[] = '<repository_plugin_param plugin_id="' . $exposed_prop["PLUGIN_ID"] . '" name="' . $exposed_prop["NAME"] . '" value="' . AJXP_Utils::xmlEntities($value) . '"/>'; $roleString .= str_replace(".", "_", $exposed_prop["PLUGIN_ID"]) . "_" . $exposed_prop["NAME"] . '="' . AJXP_Utils::xmlEntities($value) . '" '; } } $roleString .= 'acl="' . $merged->getAcl($repoId) . '"'; if ($merged->hasMask($repoId)) { $roleString .= ' hasMask="true" '; } } return "<repo access_type=\"" . $repoObject->accessType . "\" id=\"" . $repoId . "\"{$statusString} {$streamString} {$slugString} {$isSharedString} {$roleString}><label>" . SystemTextEncoding::toUTF8(AJXP_Utils::xmlEntities($repoObject->getDisplay())) . "</label>" . $descTag . $repoObject->getClientSettings() . "</repo>"; }
/** * @param AbstractAjxpUser $userObject * @return array() */ public function getExposedPreferences($userObject) { $stringPrefs = array("lang", "history/last_repository", "pending_folder", "plugins_preferences"); $jsonPrefs = array("ls_history", "gui_preferences"); $prefs = array(); if ($userObject->getId() == "guest" && ConfService::getCoreConf("SAVE_GUEST_PREFERENCES", "conf") === false) { return array(); } if (ConfService::getCoreConf("SKIP_USER_HISTORY", "conf") === true) { $stringPrefs = array("lang", "pending_folder", "plugins_preferences"); $jsonPrefs = array("gui_preferences"); $prefs["SKIP_USER_HISTORY"] = array("value" => "true", "type" => "string"); } foreach ($stringPrefs as $pref) { if (strstr($pref, "/") !== false) { $parts = explode("/", $pref); $value = $userObject->getArrayPref($parts[0], $parts[1]); $pref = str_replace("/", "_", $pref); } else { $value = $userObject->getPref($pref); } $prefs[$pref] = array("value" => $value, "type" => "string"); } foreach ($jsonPrefs as $pref) { $prefs[$pref] = array("value" => $userObject->getPref($pref), "type" => "json"); } $exposed = array(); $cacheHasExposed = AJXP_PluginsService::getInstance()->loadFromPluginQueriesCache("//server_settings/param[contains(@scope,'user') and @expose='true']"); if ($cacheHasExposed !== null && is_array($cacheHasExposed)) { $exposed = $cacheHasExposed; } else { $exposed_props = AJXP_PluginsService::searchAllManifests("//server_settings/param[contains(@scope,'user') and @expose='true']", "node", false, false, true); foreach ($exposed_props as $exposed_prop) { $parentNode = $exposed_prop->parentNode->parentNode; $pluginId = $parentNode->getAttribute("id"); if (empty($pluginId)) { $pluginId = $parentNode->nodeName . "." . $parentNode->getAttribute("name"); } $paramName = $exposed_prop->getAttribute("name"); $exposed[] = array("PLUGIN_ID" => $pluginId, "NAME" => $paramName); } AJXP_PluginsService::getInstance()->storeToPluginQueriesCache("//server_settings/param[contains(@scope,'user') and @expose='true']", $exposed); } foreach ($exposed as $exposedProp) { $value = $userObject->mergedRole->filterParameterValue($exposedProp["PLUGIN_ID"], $exposedProp["NAME"], AJXP_REPO_SCOPE_ALL, ""); $prefs[$exposedProp["NAME"]] = array("value" => $value, "type" => "string", "pluginId" => $exposedProp["PLUGIN_ID"]); } return $prefs; }
/** * @param AbstractAjxpUser $userObject * @return array() */ public function getExposedPreferences($userObject) { $stringPrefs = array("lang", "history/last_repository", "pending_folder", "plugins_preferences"); $jsonPrefs = array("ls_history", "gui_preferences"); $prefs = array(); if ($userObject->getId() == "guest" && ConfService::getCoreConf("SAVE_GUEST_PREFERENCES", "conf") === false) { return array(); } if (ConfService::getCoreConf("SKIP_USER_HISTORY", "conf") === true) { $stringPrefs = array("lang", "pending_folder", "plugins_preferences"); $jsonPrefs = array("gui_preferences"); $prefs["SKIP_USER_HISTORY"] = array("value" => "true", "type" => "string"); } foreach ($stringPrefs as $pref) { if (strstr($pref, "/") !== false) { $parts = explode("/", $pref); $value = $userObject->getArrayPref($parts[0], $parts[1]); $pref = str_replace("/", "_", $pref); } else { $value = $userObject->getPref($pref); } $prefs[$pref] = array("value" => $value, "type" => "string"); } foreach ($jsonPrefs as $pref) { $prefs[$pref] = array("value" => $userObject->getPref($pref), "type" => "json"); } $paramNodes = AJXP_PluginsService::searchAllManifests("//server_settings/param[contains(@scope,'user') and @expose='true']", "node", false, false, true); if (is_array($paramNodes) && count($paramNodes)) { foreach ($paramNodes as $xmlNode) { if ($xmlNode->getAttribute("expose") == "true") { $parentNode = $xmlNode->parentNode->parentNode; $pluginId = $parentNode->getAttribute("id"); if (empty($pluginId)) { $pluginId = $parentNode->nodeName . "." . $parentNode->getAttribute("name"); } $name = $xmlNode->getAttribute("name"); $value = $userObject->mergedRole->filterParameterValue($pluginId, $name, AJXP_REPO_SCOPE_ALL, ""); $prefs[$name] = array("value" => $value, "type" => "string", "pluginId" => $pluginId); } } } return $prefs; }
/** * @param AbstractAjxpUser $userObject * @return array() */ function getExposedPreferences($userObject) { $stringPrefs = array("display", "lang", "diapo_autofit", "sidebar_splitter_size", "vertical_splitter_size", "history/last_repository", "pending_folder", "thumb_size", "plugins_preferences", "upload_auto_send", "upload_auto_close", "upload_existing", "action_bar_style", "force_default_repository"); $jsonPrefs = array("ls_history", "columns_size", "columns_visibility", "gui_preferences"); $prefs = array(); if ($userObject->getId() == "guest" && ConfService::getCoreConf("SAVE_GUEST_PREFERENCES", "conf") === false) { return array(); } if (ConfService::getCoreConf("SKIP_USER_HISTORY", "conf") === true) { $stringPrefs = array_diff($stringPrefs, array("history/last_repository")); $jsonPrefs = array("columns_size", "columns_visibility", "gui_preferences"); } foreach ($stringPrefs as $pref) { if (strstr($pref, "/") !== false) { $parts = explode("/", $pref); $value = $userObject->getArrayPref($parts[0], $parts[1]); $pref = str_replace("/", "_", $pref); } else { $value = $userObject->getPref($pref); } $prefs[$pref] = array("value" => $value, "type" => "string"); } foreach ($jsonPrefs as $pref) { $prefs[$pref] = array("value" => $userObject->getPref($pref), "type" => "json"); } return $prefs; }