public function getChildren()
 {
     $this->children = array();
     $u = AuthService::getLoggedUser();
     if ($u != null) {
         $repos = ConfService::getAccessibleRepositories($u);
         // Refilter to make sure the driver is an AjxpWebdavProvider
         foreach ($repos as $repository) {
             $accessType = $repository->getAccessType();
             $driver = AJXP_PluginsService::getInstance()->getPluginByTypeName("access", $accessType);
             if (is_a($driver, "AjxpWrapperProvider") && $repository->getOption("AJXP_WEBDAV_DISABLED") !== true) {
                 $this->children[$repository->getSlug()] = new Sabre\DAV\SimpleCollection($repository->getSlug());
             }
         }
     }
     return $this->children;
 }
 /**
  * Write the repositories access rights in XML format
  * @static
  * @param AbstractAjxpUser|null $loggedUser * @internal param bool $details
  * @return string
  */
 public static function writeRepositoriesData($loggedUser)
 {
     $st = "<repositories>";
     $streams = ConfService::detectRepositoryStreams(false);
     $exposed = array();
     $cacheHasExposed = AJXP_PluginsService::getInstance()->loadFromPluginQueriesCache("//server_settings/param[contains(@scope,'repository') and @expose='true']");
     if ($cacheHasExposed !== null && is_array($cacheHasExposed)) {
         $exposed = $cacheHasExposed;
     } else {
         $exposed_props = AJXP_PluginsService::searchAllManifests("//server_settings/param[contains(@scope,'repository') and @expose='true']", "node", false, false, true);
         foreach ($exposed_props as $exposed_prop) {
             $pluginId = $exposed_prop->parentNode->parentNode->getAttribute("id");
             $paramName = $exposed_prop->getAttribute("name");
             $paramDefault = $exposed_prop->getAttribute("default");
             $exposed[] = array("PLUGIN_ID" => $pluginId, "NAME" => $paramName, "DEFAULT" => $paramDefault);
         }
         AJXP_PluginsService::getInstance()->storeToPluginQueriesCache("//server_settings/param[contains(@scope,'repository') and @expose='true']", $exposed);
     }
     $accessible = ConfService::getAccessibleRepositories($loggedUser, false, false);
     $inboxStatus = 0;
     foreach ($accessible as $repoId => $repoObject) {
         if (!$repoObject->hasContentFilter()) {
             continue;
         }
         $accessStatus = $repoObject->getAccessStatus();
         if (empty($accessStatus) && $loggedUser != null) {
             $lastConnected = $loggedUser->getArrayPref("repository_last_connected", $repoId);
             if (empty($lastConnected)) {
                 $accessStatus = 1;
             }
         }
         if (!empty($accessStatus)) {
             $inboxStatus++;
         }
     }
     foreach ($accessible as $repoId => $repoObject) {
         if (!isset($_SESSION["CURRENT_MINISITE"]) && $repoObject->hasContentFilter()) {
             continue;
         }
         $accessStatus = '';
         if ($repoObject->getAccessType() == "inbox") {
             $accessStatus = $inboxStatus;
         }
         $xmlString = self::repositoryToXML($repoId, $repoObject, $exposed, $streams, $loggedUser, $accessStatus);
         $st .= $xmlString;
     }
     $st .= "</repositories>";
     return $st;
 }
 /**
  * Write the repositories access rights in XML format
  * @static
  * @param AbstractAjxpUser|null $loggedUser * @internal param bool $details
  * @return string
  */
 public static function writeRepositoriesData($loggedUser)
 {
     $st = "<repositories>";
     $streams = ConfService::detectRepositoryStreams(false);
     $exposed = array();
     $cacheHasExposed = AJXP_PluginsService::getInstance()->loadFromPluginQueriesCache("//server_settings/param[contains(@scope,'repository') and @expose='true']");
     if ($cacheHasExposed !== null && is_array($cacheHasExposed)) {
         $exposed = $cacheHasExposed;
     } else {
         $exposed_props = AJXP_PluginsService::searchAllManifests("//server_settings/param[contains(@scope,'repository') and @expose='true']", "node", false, false, true);
         foreach ($exposed_props as $exposed_prop) {
             $pluginId = $exposed_prop->parentNode->parentNode->getAttribute("id");
             $paramName = $exposed_prop->getAttribute("name");
             $paramDefault = $exposed_prop->getAttribute("default");
             $exposed[] = array("PLUGIN_ID" => $pluginId, "NAME" => $paramName, "DEFAULT" => $paramDefault);
         }
         AJXP_PluginsService::getInstance()->storeToPluginQueriesCache("//server_settings/param[contains(@scope,'repository') and @expose='true']", $exposed);
     }
     $accessible = ConfService::getAccessibleRepositories($loggedUser, false, false);
     foreach ($accessible as $repoId => $repoObject) {
         $rightString = "";
         $streamString = "";
         if (in_array($repoObject->accessType, $streams)) {
             $streamString = "allowCrossRepositoryCopy=\"true\"";
         }
         if ($repoObject->getUniqueUser()) {
             $streamString .= " user_editable_repository=\"true\" ";
         }
         $slugString = "";
         $slug = $repoObject->getSlug();
         if (!empty($slug)) {
             $slugString = "repositorySlug=\"{$slug}\"";
         }
         $isSharedString = "";
         if ($repoObject->hasOwner()) {
             $uId = $repoObject->getOwner();
             $uObject = ConfService::getConfStorageImpl()->createUserObject($uId);
             $label = $uObject->personalRole->filterParameterValue("core.conf", "USER_DISPLAY_NAME", AJXP_REPO_SCOPE_ALL, $uId);
             if (empty($label)) {
                 $label = $uId;
             }
             $isSharedString = 'owner="' . AJXP_Utils::xmlEntities($label) . '"';
         }
         $descTag = "";
         $public = false;
         if (!empty($_SESSION["CURRENT_MINISITE"])) {
             $public = true;
         }
         $description = $repoObject->getDescription($public);
         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" ';
             }
         }
         $st .= "<repo access_type=\"" . $repoObject->accessType . "\" id=\"" . $repoId . "\"{$rightString} {$streamString} {$slugString} {$isSharedString} {$roleString}><label>" . SystemTextEncoding::toUTF8(AJXP_Utils::xmlEntities($repoObject->getDisplay())) . "</label>" . $descTag . $repoObject->getClientSettings() . "</repo>";
     }
     $st .= "</repositories>";
     return $st;
 }
 public static function getNodes($checkStats = false, $touch = true)
 {
     if (isset(self::$output)) {
         return self::$output;
     }
     $mess = ConfService::getMessages();
     $repos = ConfService::getAccessibleRepositories();
     $output = array();
     $touchReposIds = array();
     foreach ($repos as $repo) {
         if (!$repo->hasOwner() || !$repo->hasContentFilter()) {
             continue;
         }
         $repoId = $repo->getId();
         if (strpos("ocs_remote_share_", $repoId) !== 0) {
             $touchReposIds[] = $repoId;
         }
         $url = "pydio://" . $repoId . "/";
         $meta = array("shared_repository_id" => $repoId, "ajxp_description" => "File shared by " . $repo->getOwner() . " " . AJXP_Utils::relativeDate($repo->getOption("CREATION_TIME"), $mess), "share_meta_type" => 1);
         $cFilter = $repo->getContentFilter();
         $filter = $cFilter instanceof ContentFilter ? array_keys($cFilter->filters)[0] : $cFilter;
         if (!is_array($filter)) {
             $label = basename($filter);
         } else {
             $label = $repo->getDisplay();
         }
         if (strpos($repoId, "ocs_remote_share") !== 0) {
             // FOR REMOTE SHARES, DO NOT APPEND THE DOCUMENTNAME, WE STAT THE ROOT DIRECTLY
             $url .= $label;
         }
         $status = null;
         $remoteShare = null;
         $name = pathinfo($label, PATHINFO_FILENAME);
         $ext = pathinfo($label, PATHINFO_EXTENSION);
         $node = new AJXP_Node($url);
         $node->setLabel($label);
         if ($checkStats) {
             $node->getRepository()->driverInstance = null;
             try {
                 ConfService::loadDriverForRepository($node->getRepository());
             } catch (Exception $e) {
                 $ext = "error";
                 $meta["ajxp_mime"] = "error";
             }
             $node->getRepository()->detectStreamWrapper(true);
             $stat = @stat($url);
             if ($stat === false) {
                 $ext = "error";
                 $meta["ajxp_mime"] = "error";
                 $meta["share_meta_type"] = 2;
             } else {
                 if (strpos($repoId, "ocs_remote_share_") === 0) {
                     // Check Status
                     $linkId = str_replace("ocs_remote_share_", "", $repoId);
                     $ocsStore = new \Pydio\OCS\Model\SQLStore();
                     $remoteShare = $ocsStore->remoteShareById($linkId);
                     $status = $remoteShare->getStatus();
                     if ($status == OCS_INVITATION_STATUS_PENDING) {
                         $stat = stat(AJXP_Utils::getAjxpTmpDir());
                         $ext = "invitation";
                         $meta["ajxp_mime"] = "invitation";
                         $meta["share_meta_type"] = 0;
                     } else {
                         $meta["remote_share_accepted"] = "true";
                     }
                     $meta["remote_share_id"] = $remoteShare->getId();
                 }
             }
             if ($ext == "invitation") {
                 $label .= " (" . $mess["inbox_driver.4"] . ")";
             } else {
                 if ($ext == "error") {
                     $label .= " (" . $mess["inbox_driver.5"] . ")";
                 }
             }
             if (is_array($stat) && AuthService::getLoggedUser() != null) {
                 $acl = AuthService::getLoggedUser()->mergedRole->getAcl($repoId);
                 if ($acl == "r") {
                     self::disableWriteInStat($stat);
                 }
             }
         }
         $index = 0;
         $suffix = "";
         while (isset($output[$name . $suffix . "." . $ext])) {
             $index++;
             $suffix = " ({$index})";
         }
         $output[$name . $suffix . "." . $ext] = ["label" => $label, "url" => $url, "remote_share" => $remoteShare, "meta" => $meta];
         if (isset($stat)) {
             $output[$name . $suffix . "." . $ext]['stat'] = $stat;
         }
     }
     ConfService::loadDriverForRepository(ConfService::getRepository());
     self::$output = $output;
     if ($touch) {
         if (count($touchReposIds) && AuthService::getLoggedUser() != null) {
             $uPref = AuthService::getLoggedUser()->getPref("repository_last_connected");
             if (empty($uPref)) {
                 $uPref = array();
             }
             foreach ($touchReposIds as $rId) {
                 $uPref[$rId] = time();
             }
             AuthService::getLoggedUser()->setPref("repository_last_connected", $uPref);
         }
     }
     return $output;
 }
 public function loadUserFeed($actionName, $httpVars, $fileVars)
 {
     if (!$this->eventStore) {
         return array();
     }
     $u = AuthService::getLoggedUser();
     if ($u == null) {
         if ($httpVars["format"] == "html") {
             return array();
         }
         AJXP_XMLWriter::header();
         AJXP_XMLWriter::close();
         return array();
     }
     $userId = $u->getId();
     $userGroup = $u->getGroupPath();
     $authRepos = array();
     $crtRepId = ConfService::getCurrentRepositoryId();
     if (isset($httpVars["repository_id"]) && $u->mergedRole->canRead($httpVars["repository_id"])) {
         $authRepos[] = $httpVars["repository_id"];
     } else {
         if (isset($httpVars["current_repository"])) {
             $authRepos[] = $crtRepId;
         } else {
             $accessibleRepos = ConfService::getAccessibleRepositories(AuthService::getLoggedUser(), false, true, false);
             $authRepos = array_keys($accessibleRepos);
         }
     }
     $offset = isset($httpVars["offset"]) ? intval($httpVars["offset"]) : 0;
     $limit = isset($httpVars["limit"]) ? intval($httpVars["limit"]) : 15;
     if (!isset($httpVars["feed_type"]) || $httpVars["feed_type"] == "notif" || $httpVars["feed_type"] == "all") {
         $res = $this->eventStore->loadEvents($authRepos, isset($httpVars["path"]) ? $httpVars["path"] : "", $userGroup, $offset, $limit, false, $userId);
     } else {
         $res = array();
     }
     $mess = ConfService::getMessages();
     $format = "html";
     if (isset($httpVars["format"])) {
         $format = $httpVars["format"];
     }
     if ($format == "html") {
         echo "<h2>" . $mess["notification_center.4"] . "</h2>";
         echo "<ul class='notification_list'>";
     } else {
         if ($format == "json") {
             $jsonNodes = array();
         } else {
             if ($format != 'array') {
                 AJXP_XMLWriter::header();
             }
         }
     }
     // APPEND USER ALERT IN THE SAME QUERY FOR NOW
     if (!isset($httpVars["feed_type"]) || $httpVars["feed_type"] == "alert" || $httpVars["feed_type"] == "all") {
         $this->loadUserAlerts("", array_merge($httpVars, array("skip_container_tags" => "true")), $fileVars);
     }
     restore_error_handler();
     $index = 1;
     foreach ($res as $n => $object) {
         $args = $object->arguments;
         $oldNode = isset($args[0]) ? $args[0] : null;
         $newNode = isset($args[1]) ? $args[1] : null;
         $copy = isset($args[2]) && $args[2] === true ? true : null;
         $notif = $this->generateNotificationFromChangeHook($oldNode, $newNode, $copy, "unify");
         if ($notif !== false && $notif->getNode() !== false) {
             $notif->setAuthor($object->author);
             $notif->setDate(intval($object->date));
             if ($format == "html") {
                 $p = $notif->getNode()->getPath();
                 echo "<li data-ajxpNode='{$p}'>";
                 echo $notif->getDescriptionShort(true);
                 echo "</li>";
             } else {
                 $node = $notif->getNode();
                 if ($node == null) {
                     $this->logInfo("Warning", "Empty node stored in notification " . $notif->getAuthor() . "/ " . $notif->getAction());
                     continue;
                 }
                 try {
                     $node->loadNodeInfo();
                 } catch (Exception $e) {
                     continue;
                 }
                 $node->event_description = ucfirst($notif->getDescriptionBlock()) . " " . $mess["notification.tpl.block.user_link"] . " " . $notif->getAuthorLabel();
                 $node->event_description_long = $notif->getDescriptionLong(true);
                 $node->event_date = SystemTextEncoding::fromUTF8(AJXP_Utils::relativeDate($notif->getDate(), $mess));
                 $node->short_date = AJXP_Utils::relativeDate($notif->getDate(), $mess, true);
                 $node->event_time = $notif->getDate();
                 $node->event_type = "notification";
                 $node->event_id = $object->event_id;
                 if ($node->getRepository() != null) {
                     $node->repository_id = '' . $node->getRepository()->getId();
                     if ($node->repository_id != $crtRepId && $node->getRepository()->getDisplay() != null) {
                         $node->event_repository_label = "[" . $node->getRepository()->getDisplay() . "]";
                     }
                 }
                 $node->event_author = $notif->getAuthor();
                 // Replace PATH, to make sure they will be distinct children of the loader node
                 $node->real_path = $node->getPath();
                 $node->setLabel(basename($node->getPath()));
                 if (isset($httpVars["merge_description"]) && $httpVars["merge_description"] == "true") {
                     if (isset($httpVars["description_as_label"]) && $httpVars["description_as_label"] == "true") {
                         $node->setLabel($node->event_description . " " . $node->event_date);
                     } else {
                         $node->setLabel(basename($node->getPath()) . " <small class='notif_desc'>" . $node->event_description . " " . $node->event_date . "</small>");
                     }
                 }
                 $url = parse_url($node->getUrl());
                 $node->setUrl($url["scheme"] . "://" . $url["host"] . "/notification_" . $index);
                 $index++;
                 if ($format == "json" || $format == "array") {
                     $keys = $node->listMetaKeys();
                     $data = array();
                     foreach ($keys as $k) {
                         $data[$k] = $node->{$k};
                     }
                     if ($format == "json") {
                         $jsonNodes[] = json_encode($data);
                     } else {
                         $jsonNodes[] = $data;
                     }
                 } else {
                     AJXP_XMLWriter::renderAjxpNode($node);
                 }
             }
         }
     }
     if ($format == "html") {
         echo "</ul>";
     } else {
         if ($format == "json") {
             HTMLWriter::charsetHeader("application/json");
             echo '[' . implode(",", $jsonNodes) . ']';
         } else {
             if ($format == "array") {
                 return $jsonNodes;
             } else {
                 AJXP_XMLWriter::close();
             }
         }
     }
 }
Beispiel #6
0
 /**
  * Write the repositories access rights in XML format
  * @static
  * @param AbstractAjxpUser|null $loggedUser
  * @param bool $details
  * @return string
  */
 public static function writeRepositoriesData($loggedUser, $details = false)
 {
     $st = "<repositories>";
     $streams = ConfService::detectRepositoryStreams(false);
     foreach (ConfService::getAccessibleRepositories($loggedUser, $details, false) as $repoId => $repoObject) {
         $toLast = false;
         if ($repoObject->getAccessType() == "ajxp_conf") {
             if (AuthService::usersEnabled() && !$loggedUser->isAdmin()) {
                 continue;
             }
             $toLast = true;
         }
         $rightString = "";
         if ($details) {
             $rightString = " r=\"" . ($loggedUser->canRead($repoId) ? "1" : "0") . "\" w=\"" . ($loggedUser->canWrite($repoId) ? "1" : "0") . "\"";
         }
         $streamString = "";
         if (in_array($repoObject->accessType, $streams)) {
             $streamString = "allowCrossRepositoryCopy=\"true\"";
         }
         if ($repoObject->getUniqueUser()) {
             $streamString .= " user_editable_repository=\"true\" ";
         }
         $slugString = "";
         $slug = $repoObject->getSlug();
         if (!empty($slug)) {
             $slugString = "repositorySlug=\"{$slug}\"";
         }
         $isSharedString = "";
         if ($repoObject->hasOwner()) {
             $uId = $repoObject->getOwner();
             $uObject = ConfService::getConfStorageImpl()->createUserObject($uId);
             $label = $uObject->personalRole->filterParameterValue("core.conf", "USER_DISPLAY_NAME", AJXP_REPO_SCOPE_ALL, $uId);
             if (empty($label)) {
                 $label = $uId;
             }
             $isSharedString = 'owner="' . AJXP_Utils::xmlEntities($label) . '"';
         }
         $descTag = "";
         $description = $repoObject->getDescription();
         if (!empty($description)) {
             $descTag = '<description>' . AJXP_Utils::xmlEntities($description, true) . '</description>';
         }
         $xmlString = "<repo access_type=\"" . $repoObject->accessType . "\" id=\"" . $repoId . "\"{$rightString} {$streamString} {$slugString} {$isSharedString}><label>" . SystemTextEncoding::toUTF8(AJXP_Utils::xmlEntities($repoObject->getDisplay())) . "</label>" . $descTag . $repoObject->getClientSettings() . "</repo>";
         if ($toLast) {
             $lastString = $xmlString;
         } else {
             $st .= $xmlString;
         }
     }
     if (isset($lastString)) {
         $st .= $lastString;
     }
     $st .= "</repositories>";
     return $st;
 }
 public function switchAction($action, $httpVars, $fileVars)
 {
     if (!isset($this->actions[$action])) {
         return;
     }
     parent::accessPreprocess($action, $httpVars, $fileVars);
     $loggedUser = AuthService::getLoggedUser();
     if (AuthService::usersEnabled() && !$loggedUser->isAdmin()) {
         return;
     }
     if (AuthService::usersEnabled()) {
         $currentBookmarks = AuthService::getLoggedUser()->getBookmarks();
         // FLATTEN
         foreach ($currentBookmarks as $bm) {
             $this->currentBookmarks[] = $bm["PATH"];
         }
     }
     if ($action == "edit") {
         if (isset($httpVars["sub_action"])) {
             $action = $httpVars["sub_action"];
         }
     }
     $mess = ConfService::getMessages();
     $currentUserIsGroupAdmin = AuthService::getLoggedUser() != null && AuthService::getLoggedUser()->getGroupPath() != "/";
     if ($currentUserIsGroupAdmin && ConfService::getAuthDriverImpl()->isAjxpAdmin(AuthService::getLoggedUser()->getId())) {
         $currentUserIsGroupAdmin = false;
     }
     switch ($action) {
         //------------------------------------
         //	BASIC LISTING
         //------------------------------------
         case "ls":
             $rootNodes = array("data" => array("LABEL" => $mess["ajxp_conf.110"], "ICON" => "user.png", "DESCRIPTION" => "Day-to-day administration of the application : who accesses to what, create roles, etc.", "CHILDREN" => array("repositories" => array("AJXP_MIME" => "workspaces_zone", "LABEL" => $mess["ajxp_conf.3"], "DESCRIPTION" => "Create and delete workspaces, add features to them using meta sources.", "ICON" => "hdd_external_unmount.png", "LIST" => "listRepositories"), "users" => array("AJXP_MIME" => "users_zone", "LABEL" => $mess["ajxp_conf.2"], "DESCRIPTION" => "Manage users and groups", "ICON" => "users-folder.png", "LIST" => "listUsers"), "roles" => array("AJXP_MIME" => "roles_zone", "LABEL" => $mess["ajxp_conf.69"], "DESCRIPTION" => "Define profiles that can be applied at once to whole bunch of users.", "ICON" => "user-acl.png", "LIST" => "listRoles"))), "config" => array("LABEL" => $mess["ajxp_conf.109"], "ICON" => "preferences_desktop.png", "DESCRIPTION" => "Global configurations of the application core and of each plugin. Enable/disable plugins", "CHILDREN" => array("core" => array("LABEL" => $mess["ajxp_conf.98"], "DESCRIPTION" => "Core application parameters", "ICON" => "preferences_desktop.png", "LIST" => "listPlugins"), "plugins" => array("LABEL" => $mess["ajxp_conf.99"], "DESCRIPTION" => "Enable/disable additional feature-oriented plugins, check if they are correctly working, set up global parameters of the plugins.", "ICON" => "folder_development.png", "LIST" => "listPlugins"), "core_plugins" => array("LABEL" => $mess["ajxp_conf.123"], "DESCRIPTION" => "Enable/disable core plugins (auth, conf, mail, etc), check if they are correctly working. Configuration of these plugins are generally done through the Main Options", "ICON" => "folder_development.png", "LIST" => "listPlugins"))), "admin" => array("LABEL" => $mess["ajxp_conf.111"], "ICON" => "toggle_log.png", "DESCRIPTION" => "Administrator tasks to monitor the application state.", "CHILDREN" => array("logs" => array("LABEL" => $mess["ajxp_conf.4"], "DESCRIPTION" => "Monitor all activities happening on the server", "ICON" => "toggle_log.png", "LIST" => "listLogFiles"), "files" => array("LABEL" => $mess["ajxp_shared.3"], "DESCRIPTION" => "Monitor all files shared as public links by every users", "ICON" => "html.png", "LIST" => "listSharedFiles"), "diagnostic" => array("LABEL" => $mess["ajxp_conf.5"], "DESCRIPTION" => "Read the start-up diagnostic generated by Pydio", "ICON" => "susehelpcenter.png", "LIST" => "printDiagnostic"))), "developer" => array("LABEL" => "Developer Resources", "ICON" => "applications_engineering.png", "DESCRIPTION" => "Generated documentations for developers", "CHILDREN" => array("actions" => array("LABEL" => "Actions API", "DESCRIPTION" => "List all actions contributed by all plugins and visualize their input parameters", "ICON" => "book.png", "LIST" => "listActions"), "hooks" => array("LABEL" => "Hooks Definitions", "DESCRIPTION" => "List all hooks triggered in the application, their documentation, where there are triggered and which plugin listen to them.", "ICON" => "book.png", "LIST" => "listHooks"))));
             if ($currentUserIsGroupAdmin) {
                 unset($rootNodes["config"]);
                 unset($rootNodes["admin"]);
                 unset($rootNodes["developer"]);
             }
             AJXP_Controller::applyHook("ajxp_conf.list_config_nodes", array(&$rootNodes));
             $dir = trim(AJXP_Utils::decodeSecureMagic(isset($httpVars["dir"]) ? $httpVars["dir"] : ""), " /");
             if ($dir != "") {
                 $hash = null;
                 if (strstr(urldecode($dir), "#") !== false) {
                     list($dir, $hash) = explode("#", urldecode($dir));
                 }
                 $splits = explode("/", $dir);
                 $root = array_shift($splits);
                 if (count($splits)) {
                     $returnNodes = false;
                     if (isset($httpVars["file"])) {
                         $returnNodes = true;
                     }
                     $child = $splits[0];
                     if (isset($rootNodes[$root]["CHILDREN"][$child])) {
                         $atts = array();
                         if ($child == "users") {
                             $atts["remote_indexation"] = "admin_search";
                         }
                         $callback = $rootNodes[$root]["CHILDREN"][$child]["LIST"];
                         if (is_string($callback) && method_exists($this, $callback)) {
                             if (!$returnNodes) {
                                 AJXP_XMLWriter::header("tree", $atts);
                             }
                             $res = call_user_func(array($this, $callback), implode("/", $splits), $root, $hash, $returnNodes, isset($httpVars["file"]) ? $httpVars["file"] : '');
                             if (!$returnNodes) {
                                 AJXP_XMLWriter::close();
                             }
                         } else {
                             if (is_array($callback)) {
                                 $res = call_user_func($callback, implode("/", $splits), $root, $hash, $returnNodes, isset($httpVars["file"]) ? $httpVars["file"] : '');
                             }
                         }
                         if ($returnNodes) {
                             AJXP_XMLWriter::header("tree", $atts);
                             if (isset($res["/" . $dir . "/" . $httpVars["file"]])) {
                                 print $res["/" . $dir . "/" . $httpVars["file"]];
                             }
                             AJXP_XMLWriter::close();
                         }
                         return;
                     }
                 } else {
                     $parentName = "/" . $root . "/";
                     $nodes = $rootNodes[$root]["CHILDREN"];
                 }
             } else {
                 $parentName = "/";
                 $nodes = $rootNodes;
             }
             if (isset($httpVars["file"])) {
                 $parentName = $httpVars["dir"] . "/";
                 $nodes = array(basename($httpVars["file"]) => array("LABEL" => basename($httpVars["file"])));
             }
             if (isset($nodes)) {
                 AJXP_XMLWriter::header();
                 if (!isset($httpVars["file"])) {
                     AJXP_XMLWriter::sendFilesListComponentConfig('<columns switchDisplayMode="detail"><column messageId="ajxp_conf.1" attributeName="ajxp_label" sortType="String"/><column messageId="ajxp_conf.102" attributeName="description" sortType="String"/></columns>');
                 }
                 foreach ($nodes as $key => $data) {
                     $bmString = '';
                     if (in_array($parentName . $key, $this->currentBookmarks)) {
                         $bmString = ' ajxp_bookmarked="true" overlay_icon="bookmark.png" ';
                     }
                     if ($key == "users") {
                         $bmString .= ' remote_indexation="admin_search"';
                     }
                     if (isset($data["AJXP_MIME"])) {
                         $bmString .= ' ajxp_mime="' . $data["AJXP_MIME"] . '"';
                     }
                     if (empty($data["CHILDREN"])) {
                         print '<tree text="' . AJXP_Utils::xmlEntities($data["LABEL"]) . '" description="' . AJXP_Utils::xmlEntities($data["DESCRIPTION"]) . '" icon="' . $data["ICON"] . '" filename="' . $parentName . $key . '" ' . $bmString . '/>';
                     } else {
                         print '<tree text="' . AJXP_Utils::xmlEntities($data["LABEL"]) . '" description="' . AJXP_Utils::xmlEntities($data["DESCRIPTION"]) . '" icon="' . $data["ICON"] . '" filename="' . $parentName . $key . '" ' . $bmString . '>';
                         foreach ($data["CHILDREN"] as $cKey => $cData) {
                             $bmString = '';
                             if (in_array($parentName . $key . "/" . $cKey, $this->currentBookmarks)) {
                                 $bmString = ' ajxp_bookmarked="true" overlay_icon="bookmark.png" ';
                             }
                             if ($cKey == "users") {
                                 $bmString .= ' remote_indexation="admin_search"';
                             }
                             if (isset($cData["AJXP_MIME"])) {
                                 $bmString .= ' ajxp_mime="' . $cData["AJXP_MIME"] . '"';
                             }
                             print '<tree text="' . AJXP_Utils::xmlEntities($cData["LABEL"]) . '" description="' . AJXP_Utils::xmlEntities($cData["DESCRIPTION"]) . '" icon="' . $cData["ICON"] . '" filename="' . $parentName . $key . '/' . $cKey . '" ' . $bmString . '/>';
                         }
                         print '</tree>';
                     }
                 }
                 AJXP_XMLWriter::close();
             }
             break;
         case "stat":
             header("Content-type:application/json");
             print '{"mode":true}';
             return;
             break;
         case "create_group":
             if (isset($httpVars["group_path"])) {
                 $basePath = AJXP_Utils::forwardSlashDirname($httpVars["group_path"]);
                 if (empty($basePath)) {
                     $basePath = "/";
                 }
                 $gName = AJXP_Utils::sanitize(AJXP_Utils::decodeSecureMagic(basename($httpVars["group_path"])), AJXP_SANITIZE_ALPHANUM);
             } else {
                 $basePath = substr($httpVars["dir"], strlen("/data/users"));
                 $gName = AJXP_Utils::sanitize(SystemTextEncoding::magicDequote($httpVars["group_name"]), AJXP_SANITIZE_ALPHANUM);
             }
             $gLabel = AJXP_Utils::decodeSecureMagic($httpVars["group_label"]);
             AuthService::createGroup($basePath, $gName, $gLabel);
             AJXP_XMLWriter::header();
             AJXP_XMLWriter::sendMessage($mess["ajxp_conf.124"], null);
             AJXP_XMLWriter::reloadDataNode();
             AJXP_XMLWriter::close();
             break;
         case "create_role":
             $roleId = AJXP_Utils::sanitize(SystemTextEncoding::magicDequote($httpVars["role_id"]), AJXP_SANITIZE_HTML_STRICT);
             if (!strlen($roleId)) {
                 throw new Exception($mess[349]);
             }
             if (AuthService::getRole($roleId) !== false) {
                 throw new Exception($mess["ajxp_conf.65"]);
             }
             $r = new AJXP_Role($roleId);
             if (AuthService::getLoggedUser() != null && AuthService::getLoggedUser()->getGroupPath() != null) {
                 $r->setGroupPath(AuthService::getLoggedUser()->getGroupPath());
             }
             AuthService::updateRole($r);
             AJXP_XMLWriter::header();
             AJXP_XMLWriter::sendMessage($mess["ajxp_conf.66"], null);
             AJXP_XMLWriter::reloadDataNode("", $httpVars["role_id"]);
             AJXP_XMLWriter::close();
             break;
         case "edit_role":
             $roleId = SystemTextEncoding::magicDequote($httpVars["role_id"]);
             $roleGroup = false;
             if (strpos($roleId, "AJXP_GRP_") === 0) {
                 $groupPath = substr($roleId, strlen("AJXP_GRP_"));
                 $filteredGroupPath = AuthService::filterBaseGroup($groupPath);
                 $groups = AuthService::listChildrenGroups(AJXP_Utils::forwardSlashDirname($groupPath));
                 $key = "/" . basename($groupPath);
                 if (!array_key_exists($key, $groups)) {
                     throw new Exception("Cannot find group with this id!");
                 }
                 $roleId = "AJXP_GRP_" . $filteredGroupPath;
                 $groupLabel = $groups[$key];
                 $roleGroup = true;
             }
             if (strpos($roleId, "AJXP_USR_") === 0) {
                 $usrId = str_replace("AJXP_USR_/", "", $roleId);
                 $userObject = ConfService::getConfStorageImpl()->createUserObject($usrId);
                 if (!AuthService::canAdministrate($userObject)) {
                     throw new Exception("Cant find user!");
                 }
                 $role = $userObject->personalRole;
             } else {
                 $role = AuthService::getRole($roleId, $roleGroup);
             }
             if ($role === false) {
                 throw new Exception("Cant find role! ");
             }
             if (isset($httpVars["format"]) && $httpVars["format"] == "json") {
                 HTMLWriter::charsetHeader("application/json");
                 $roleData = $role->getDataArray();
                 $repos = ConfService::getAccessibleRepositories($userObject, true, true, $userObject == null ? true : false);
                 $data = array("ROLE" => $roleData, "ALL" => array("REPOSITORIES" => $repos));
                 if (isset($userObject)) {
                     $data["USER"] = array();
                     $data["USER"]["LOCK"] = $userObject->getLock();
                     $data["USER"]["PROFILE"] = $userObject->getProfile();
                     $data["ALL"]["PROFILES"] = array("standard|Standard", "admin|Administrator", "shared|Shared", "guest|Guest");
                     $data["USER"]["ROLES"] = array_keys($userObject->getRoles());
                     $data["ALL"]["ROLES"] = array_keys(AuthService::getRolesList(array(), true));
                     if (isset($userObject->parentRole)) {
                         $data["PARENT_ROLE"] = $userObject->parentRole->getDataArray();
                     }
                 } else {
                     if (isset($groupPath)) {
                         $data["GROUP"] = array("PATH" => $groupPath, "LABEL" => $groupLabel);
                     }
                 }
                 $scope = "role";
                 if ($roleGroup) {
                     $scope = "group";
                 } else {
                     if (isset($userObject)) {
                         $scope = "user";
                     }
                 }
                 $data["SCOPE_PARAMS"] = array();
                 $nodes = AJXP_PluginsService::getInstance()->searchAllManifests("//param[contains(@scope,'" . $scope . "')]|//global_param[contains(@scope,'" . $scope . "')]", "node", false, true, true);
                 foreach ($nodes as $node) {
                     $pId = $node->parentNode->parentNode->attributes->getNamedItem("id")->nodeValue;
                     $origName = $node->attributes->getNamedItem("name")->nodeValue;
                     $node->attributes->getNamedItem("name")->nodeValue = "AJXP_REPO_SCOPE_ALL/" . $pId . "/" . $origName;
                     $nArr = array();
                     foreach ($node->attributes as $attrib) {
                         $nArr[$attrib->nodeName] = AJXP_XMLWriter::replaceAjxpXmlKeywords($attrib->nodeValue);
                     }
                     $data["SCOPE_PARAMS"][] = $nArr;
                 }
                 echo json_encode($data);
             }
             break;
         case "post_json_role":
             $roleId = SystemTextEncoding::magicDequote($httpVars["role_id"]);
             $roleGroup = false;
             if (strpos($roleId, "AJXP_GRP_") === 0) {
                 $groupPath = substr($roleId, strlen("AJXP_GRP_"));
                 $filteredGroupPath = AuthService::filterBaseGroup($groupPath);
                 $roleId = "AJXP_GRP_" . $filteredGroupPath;
                 $groups = AuthService::listChildrenGroups(AJXP_Utils::forwardSlashDirname($groupPath));
                 $key = "/" . basename($groupPath);
                 if (!array_key_exists($key, $groups)) {
                     throw new Exception("Cannot find group with this id!");
                 }
                 $groupLabel = $groups[$key];
                 $roleGroup = true;
             }
             if (strpos($roleId, "AJXP_USR_") === 0) {
                 $usrId = str_replace("AJXP_USR_/", "", $roleId);
                 $userObject = ConfService::getConfStorageImpl()->createUserObject($usrId);
                 if (!AuthService::canAdministrate($userObject)) {
                     throw new Exception("Cannot post role for user " . $usrId);
                 }
                 $originalRole = $userObject->personalRole;
             } else {
                 // second param = create if not exists.
                 $originalRole = AuthService::getRole($roleId, $roleGroup);
             }
             if ($originalRole === false) {
                 throw new Exception("Cant find role! ");
             }
             $jsonData = AJXP_Utils::decodeSecureMagic($httpVars["json_data"]);
             $data = json_decode($jsonData, true);
             $roleData = $data["ROLE"];
             $forms = $data["FORMS"];
             $binariesContext = array();
             if (isset($userObject)) {
                 $binariesContext = array("USER" => $userObject->getId());
             }
             foreach ($forms as $repoScope => $plugData) {
                 foreach ($plugData as $plugId => $formsData) {
                     $parsed = array();
                     AJXP_Utils::parseStandardFormParameters($formsData, $parsed, $userObject != null ? $usrId : null, "ROLE_PARAM_", $binariesContext);
                     $roleData["PARAMETERS"][$repoScope][$plugId] = $parsed;
                 }
             }
             if (isset($userObject) && isset($data["USER"]) && isset($data["USER"]["PROFILE"])) {
                 $userObject->setAdmin($data["USER"]["PROFILE"] == "admin");
                 $userObject->setProfile($data["USER"]["PROFILE"]);
             }
             if (isset($data["GROUP_LABEL"]) && isset($groupLabel) && $groupLabel != $data["GROUP_LABEL"]) {
                 ConfService::getConfStorageImpl()->relabelGroup($filteredGroupPath, $data["GROUP_LABEL"]);
             }
             $output = array();
             try {
                 $originalRole->bunchUpdate($roleData);
                 if (isset($userObject)) {
                     $userObject->personalRole = $originalRole;
                     $userObject->save("superuser");
                     //AuthService::updateRole($originalRole, $userObject);
                 } else {
                     AuthService::updateRole($originalRole);
                 }
                 $output = array("ROLE" => $originalRole->getDataArray(), "SUCCESS" => true);
             } catch (Exception $e) {
                 $output = array("ERROR" => $e->getMessage());
             }
             HTMLWriter::charsetHeader("application/json");
             echo json_encode($output);
             break;
         case "user_set_lock":
             $userId = AJXP_Utils::decodeSecureMagic($httpVars["user_id"]);
             $lock = $httpVars["lock"] == "true" ? true : false;
             $lockType = $httpVars["lock_type"];
             if (AuthService::userExists($userId)) {
                 $userObject = ConfService::getConfStorageImpl()->createUserObject($userId);
                 if (!AuthService::canAdministrate($userObject)) {
                     throw new Exception("Cannot update user data for " . $userId);
                 }
                 if ($lock) {
                     $userObject->setLock($lockType);
                 } else {
                     $userObject->removeLock();
                 }
                 $userObject->save("superuser");
             }
             break;
         case "create_user":
             if (!isset($httpVars["new_user_login"]) || $httpVars["new_user_login"] == "" || !isset($httpVars["new_user_pwd"]) || $httpVars["new_user_pwd"] == "") {
                 AJXP_XMLWriter::header();
                 AJXP_XMLWriter::sendMessage(null, $mess["ajxp_conf.61"]);
                 AJXP_XMLWriter::close();
                 return;
             }
             $new_user_login = AJXP_Utils::sanitize(SystemTextEncoding::magicDequote($httpVars["new_user_login"]), AJXP_SANITIZE_EMAILCHARS);
             if (AuthService::userExists($new_user_login, "w") || AuthService::isReservedUserId($new_user_login)) {
                 AJXP_XMLWriter::header();
                 AJXP_XMLWriter::sendMessage(null, $mess["ajxp_conf.43"]);
                 AJXP_XMLWriter::close();
                 return;
             }
             AuthService::createUser($new_user_login, $httpVars["new_user_pwd"]);
             $confStorage = ConfService::getConfStorageImpl();
             $newUser = $confStorage->createUserObject($new_user_login);
             $basePath = AuthService::getLoggedUser()->getGroupPath();
             if (empty($basePath)) {
                 $basePath = "/";
             }
             if (!empty($httpVars["group_path"])) {
                 $newUser->setGroupPath(rtrim($basePath, "/") . "/" . ltrim($httpVars["group_path"], "/"));
             } else {
                 $newUser->setGroupPath($basePath);
             }
             $newUser->save("superuser");
             AJXP_XMLWriter::header();
             AJXP_XMLWriter::sendMessage($mess["ajxp_conf.44"], null);
             AJXP_XMLWriter::reloadDataNode("", $new_user_login);
             AJXP_XMLWriter::close();
             break;
         case "change_admin_right":
             $userId = $httpVars["user_id"];
             if (!AuthService::userExists($userId)) {
                 throw new Exception("Invalid user id!");
             }
             $confStorage = ConfService::getConfStorageImpl();
             $user = $confStorage->createUserObject($userId);
             if (!AuthService::canAdministrate($user)) {
                 throw new Exception("Cannot update user with id " . $userId);
             }
             $user->setAdmin($httpVars["right_value"] == "1" ? true : false);
             $user->save("superuser");
             AJXP_XMLWriter::header();
             AJXP_XMLWriter::sendMessage($mess["ajxp_conf.45"] . $httpVars["user_id"], null);
             AJXP_XMLWriter::reloadDataNode();
             AJXP_XMLWriter::close();
             break;
         case "role_update_right":
             if (!isset($httpVars["role_id"]) || !isset($httpVars["repository_id"]) || !isset($httpVars["right"])) {
                 AJXP_XMLWriter::header();
                 AJXP_XMLWriter::sendMessage(null, $mess["ajxp_conf.61"]);
                 AJXP_XMLWriter::close();
                 break;
             }
             $rId = AJXP_Utils::sanitize($httpVars["role_id"]);
             $role = AuthService::getRole($rId);
             if ($role === false) {
                 AJXP_XMLWriter::header();
                 AJXP_XMLWriter::sendMessage(null, $mess["ajxp_conf.61"] . "(" . $rId . ")");
                 AJXP_XMLWriter::close();
                 break;
             }
             $role->setAcl(AJXP_Utils::sanitize($httpVars["repository_id"], AJXP_SANITIZE_ALPHANUM), AJXP_Utils::sanitize($httpVars["right"], AJXP_SANITIZE_ALPHANUM));
             AuthService::updateRole($role);
             AJXP_XMLWriter::header();
             AJXP_XMLWriter::sendMessage($mess["ajxp_conf.46"] . $httpVars["role_id"], null);
             AJXP_XMLWriter::close();
             break;
         case "user_update_right":
             if (!isset($httpVars["user_id"]) || !isset($httpVars["repository_id"]) || !isset($httpVars["right"]) || !AuthService::userExists($httpVars["user_id"])) {
                 AJXP_XMLWriter::header();
                 AJXP_XMLWriter::sendMessage(null, $mess["ajxp_conf.61"]);
                 print "<update_checkboxes user_id=\"" . $httpVars["user_id"] . "\" repository_id=\"" . $httpVars["repository_id"] . "\" read=\"old\" write=\"old\"/>";
                 AJXP_XMLWriter::close();
                 return;
             }
             $confStorage = ConfService::getConfStorageImpl();
             $userId = AJXP_Utils::sanitize($httpVars["user_id"], AJXP_SANITIZE_EMAILCHARS);
             $user = $confStorage->createUserObject($userId);
             if (!AuthService::canAdministrate($user)) {
                 throw new Exception("Cannot update user with id " . $userId);
             }
             $user->personalRole->setAcl(AJXP_Utils::sanitize($httpVars["repository_id"], AJXP_SANITIZE_ALPHANUM), AJXP_Utils::sanitize($httpVars["right"], AJXP_SANITIZE_ALPHANUM));
             $user->save();
             $loggedUser = AuthService::getLoggedUser();
             if ($loggedUser->getId() == $user->getId()) {
                 AuthService::updateUser($user);
             }
             AJXP_XMLWriter::header();
             AJXP_XMLWriter::sendMessage($mess["ajxp_conf.46"] . $httpVars["user_id"], null);
             print "<update_checkboxes user_id=\"" . $httpVars["user_id"] . "\" repository_id=\"" . $httpVars["repository_id"] . "\" read=\"" . $user->canRead($httpVars["repository_id"]) . "\" write=\"" . $user->canWrite($httpVars["repository_id"]) . "\"/>";
             AJXP_XMLWriter::reloadRepositoryList();
             AJXP_XMLWriter::close();
             return;
             break;
         case "user_update_group":
             $userSelection = new UserSelection();
             $userSelection->initFromHttpVars($httpVars);
             $dir = $httpVars["dir"];
             $dest = $httpVars["dest"];
             if (isset($httpVars["group_path"])) {
                 // API Case
                 $groupPath = $httpVars["group_path"];
             } else {
                 if (strpos($dir, "/data/users", 0) !== 0 || strpos($dest, "/data/users", 0) !== 0) {
                     break;
                 }
                 $groupPath = substr($dest, strlen("/data/users"));
             }
             $confStorage = ConfService::getConfStorageImpl();
             foreach ($userSelection->getFiles() as $selectedUser) {
                 $userId = basename($selectedUser);
                 if (!AuthService::userExists($userId)) {
                     continue;
                 }
                 $user = $confStorage->createUserObject($userId);
                 if (!AuthService::canAdministrate($user)) {
                     continue;
                 }
                 $basePath = AuthService::getLoggedUser() != null ? AuthService::getLoggedUser()->getGroupPath() : "/";
                 if (empty($basePath)) {
                     $basePath = "/";
                 }
                 if (!empty($groupPath)) {
                     $user->setGroupPath(rtrim($basePath, "/") . "/" . ltrim($groupPath, "/"), true);
                 } else {
                     $user->setGroupPath($basePath, true);
                 }
                 $user->save("superuser");
             }
             AJXP_XMLWriter::header();
             AJXP_XMLWriter::reloadDataNode();
             AJXP_XMLWriter::reloadDataNode($dest, $userId);
             AJXP_XMLWriter::close();
             break;
         case "user_add_role":
         case "user_delete_role":
             if (!isset($httpVars["user_id"]) || !isset($httpVars["role_id"]) || !AuthService::userExists($httpVars["user_id"]) || !AuthService::getRole($httpVars["role_id"])) {
                 throw new Exception($mess["ajxp_conf.61"]);
             }
             if ($action == "user_add_role") {
                 $act = "add";
                 $messId = "73";
             } else {
                 $act = "remove";
                 $messId = "74";
             }
             $this->updateUserRole(AJXP_Utils::sanitize($httpVars["user_id"], AJXP_SANITIZE_EMAILCHARS), $httpVars["role_id"], $act);
             AJXP_XMLWriter::header();
             AJXP_XMLWriter::sendMessage($mess["ajxp_conf." . $messId] . $httpVars["user_id"], null);
             AJXP_XMLWriter::close();
             return;
             break;
         case "user_update_role":
             $confStorage = ConfService::getConfStorageImpl();
             $selection = new UserSelection();
             $selection->initFromHttpVars($httpVars);
             $files = $selection->getFiles();
             $detectedRoles = array();
             if (isset($httpVars["role_id"]) && isset($httpVars["update_role_action"])) {
                 $update = $httpVars["update_role_action"];
                 $roleId = $httpVars["role_id"];
                 if (AuthService::getRole($roleId) === false) {
                     throw new Exception("Invalid role id");
                 }
             }
             foreach ($files as $index => $file) {
                 $userId = basename($file);
                 if (isset($update)) {
                     $userObject = $this->updateUserRole($userId, $roleId, $update);
                 } else {
                     $userObject = $confStorage->createUserObject($userId);
                     if (!AuthService::canAdministrate($userObject)) {
                         continue;
                     }
                 }
                 if ($userObject->hasParent()) {
                     unset($files[$index]);
                     continue;
                 }
                 $userRoles = $userObject->getRoles();
                 foreach ($userRoles as $roleIndex => $bool) {
                     if (!isset($detectedRoles[$roleIndex])) {
                         $detectedRoles[$roleIndex] = 0;
                     }
                     if ($bool === true) {
                         $detectedRoles[$roleIndex]++;
                     }
                 }
             }
             $count = count($files);
             AJXP_XMLWriter::header("admin_data");
             print "<user><ajxp_roles>";
             foreach ($detectedRoles as $roleId => $roleCount) {
                 if ($roleCount < $count) {
                     continue;
                 }
                 print "<role id=\"{$roleId}\"/>";
             }
             print "</ajxp_roles></user>";
             print "<ajxp_roles>";
             foreach (AuthService::getRolesList(array(), !$this->listSpecialRoles) as $roleId => $roleObject) {
                 print "<role id=\"{$roleId}\"/>";
             }
             print "</ajxp_roles>";
             AJXP_XMLWriter::close("admin_data");
             break;
         case "save_custom_user_params":
             $userId = AJXP_Utils::sanitize($httpVars["user_id"], AJXP_SANITIZE_EMAILCHARS);
             if ($userId == $loggedUser->getId()) {
                 $user = $loggedUser;
             } else {
                 $confStorage = ConfService::getConfStorageImpl();
                 $user = $confStorage->createUserObject($userId);
             }
             if (!AuthService::canAdministrate($user)) {
                 throw new Exception("Cannot update user with id " . $userId);
             }
             $custom = $user->getPref("CUSTOM_PARAMS");
             if (!is_array($custom)) {
                 $custom = array();
             }
             $options = $custom;
             $this->parseParameters($httpVars, $options, $userId);
             $custom = $options;
             $user->setPref("CUSTOM_PARAMS", $custom);
             $user->save();
             if ($loggedUser->getId() == $user->getId()) {
                 AuthService::updateUser($user);
             }
             AJXP_XMLWriter::header();
             AJXP_XMLWriter::sendMessage($mess["ajxp_conf.47"] . $httpVars["user_id"], null);
             AJXP_XMLWriter::close();
             break;
         case "save_repository_user_params":
             $userId = AJXP_Utils::sanitize($httpVars["user_id"], AJXP_SANITIZE_EMAILCHARS);
             if ($userId == $loggedUser->getId()) {
                 $user = $loggedUser;
             } else {
                 $confStorage = ConfService::getConfStorageImpl();
                 $user = $confStorage->createUserObject($userId);
             }
             if (!AuthService::canAdministrate($user)) {
                 throw new Exception("Cannot update user with id " . $userId);
             }
             $wallet = $user->getPref("AJXP_WALLET");
             if (!is_array($wallet)) {
                 $wallet = array();
             }
             $repoID = $httpVars["repository_id"];
             if (!array_key_exists($repoID, $wallet)) {
                 $wallet[$repoID] = array();
             }
             $options = $wallet[$repoID];
             $this->parseParameters($httpVars, $options, $userId);
             $wallet[$repoID] = $options;
             $user->setPref("AJXP_WALLET", $wallet);
             $user->save();
             if ($loggedUser->getId() == $user->getId()) {
                 AuthService::updateUser($user);
             }
             AJXP_XMLWriter::header();
             AJXP_XMLWriter::sendMessage($mess["ajxp_conf.47"] . $httpVars["user_id"], null);
             AJXP_XMLWriter::close();
             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();
                 return;
             }
             $userId = AJXP_Utils::sanitize($httpVars["user_id"], AJXP_SANITIZE_EMAILCHARS);
             $user = ConfService::getConfStorageImpl()->createUserObject($userId);
             if (!AuthService::canAdministrate($user)) {
                 throw new Exception("Cannot update user data for " . $userId);
             }
             $res = AuthService::updatePassword($userId, $httpVars["user_pwd"]);
             AJXP_XMLWriter::header();
             if ($res === true) {
                 AJXP_XMLWriter::sendMessage($mess["ajxp_conf.48"] . $userId, null);
             } else {
                 AJXP_XMLWriter::sendMessage(null, $mess["ajxp_conf.49"] . " : {$res}");
             }
             AJXP_XMLWriter::close();
             break;
         case "save_user_preference":
             if (!isset($httpVars["user_id"]) || !AuthService::userExists($httpVars["user_id"])) {
                 throw new Exception($mess["ajxp_conf.61"]);
             }
             $userId = AJXP_Utils::sanitize($httpVars["user_id"], AJXP_SANITIZE_EMAILCHARS);
             if ($userId == $loggedUser->getId()) {
                 $userObject = $loggedUser;
             } else {
                 $confStorage = ConfService::getConfStorageImpl();
                 $userObject = $confStorage->createUserObject($userId);
             }
             if (!AuthService::canAdministrate($userObject)) {
                 throw new Exception("Cannot update user data for " . $userId);
             }
             $i = 0;
             while (isset($httpVars["pref_name_" . $i]) && isset($httpVars["pref_value_" . $i])) {
                 $prefName = AJXP_Utils::sanitize($httpVars["pref_name_" . $i], AJXP_SANITIZE_ALPHANUM);
                 $prefValue = AJXP_Utils::sanitize(SystemTextEncoding::magicDequote($httpVars["pref_value_" . $i]));
                 if ($prefName == "password") {
                     continue;
                 }
                 if ($prefName != "pending_folder" && $userObject == null) {
                     $i++;
                     continue;
                 }
                 $userObject->setPref($prefName, $prefValue);
                 $userObject->save("user");
                 $i++;
             }
             AJXP_XMLWriter::header();
             AJXP_XMLWriter::sendMessage("Succesfully saved user preference", null);
             AJXP_XMLWriter::close();
             break;
         case "get_drivers_definition":
             AJXP_XMLWriter::header("drivers", array("allowed" => $currentUserIsGroupAdmin ? "false" : "true"));
             print AJXP_XMLWriter::replaceAjxpXmlKeywords(ConfService::availableDriversToXML("param", "", true));
             AJXP_XMLWriter::close("drivers");
             break;
         case "get_templates_definition":
             AJXP_XMLWriter::header("repository_templates");
             $repositories = ConfService::getRepositoriesList("all");
             foreach ($repositories as $repo) {
                 if (!$repo->isTemplate) {
                     continue;
                 }
                 $repoId = $repo->getId();
                 $repoLabel = SystemTextEncoding::toUTF8($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":
             $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 repository 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");
                             }
                             $metaSourceOptions[$metaID] = $defaultParams;
                         }
                         $newRep->addOption("META_SOURCES", $metaSourceOptions);
                     }
                 }
             }
             if ($this->repositoryExists($newRep->getDisplay())) {
                 AJXP_XMLWriter::header();
                 AJXP_XMLWriter::sendMessage(null, $mess["ajxp_conf.50"]);
                 AJXP_XMLWriter::close();
                 return;
             }
             if ($isTemplate) {
                 $newRep->isTemplate = true;
             }
             if ($currentUserIsGroupAdmin) {
                 $newRep->setGroupPath(AuthService::getLoggedUser()->getGroupPath());
             } else {
                 if (!empty($options["AJXP_GROUP_PATH_PARAMETER"])) {
                     $basePath = "/";
                     if (AuthService::getLoggedUser() != null && AuthService::getLoggedUser()->getGroupPath() != null) {
                         $basePath = AuthService::getLoggedUser()->getGroupPath();
                     }
                     $value = AJXP_Utils::securePath(rtrim($basePath, "/") . "/" . ltrim($options["AJXP_GROUP_PATH_PARAMETER"], "/"));
                     $newRep->setGroupPath($value);
                 }
             }
             $res = ConfService::addRepository($newRep);
             AJXP_XMLWriter::header();
             if ($res == -1) {
                 AJXP_XMLWriter::sendMessage(null, $mess["ajxp_conf.51"]);
             } else {
                 $loggedUser = AuthService::getLoggedUser();
                 $loggedUser->personalRole->setAcl($newRep->getUniqueId(), "rw");
                 $loggedUser->recomputeMergedRole();
                 $loggedUser->save("superuser");
                 AuthService::updateUser($loggedUser);
                 AJXP_XMLWriter::sendMessage($mess["ajxp_conf.52"], null);
                 AJXP_XMLWriter::reloadDataNode("", $newRep->getUniqueId());
                 AJXP_XMLWriter::reloadRepositoryList();
             }
             AJXP_XMLWriter::close();
             break;
         case "edit_repository":
             $repId = $httpVars["repository_id"];
             $repository = ConfService::getRepositoryById($repId);
             if ($repository == null) {
                 throw new Exception("Cannot find repository with id {$repId}");
             }
             if (!AuthService::canAdministrate($repository)) {
                 throw new Exception("You are not allowed to edit this repository!");
             }
             $pServ = AJXP_PluginsService::getInstance();
             $plug = $pServ->getPluginById("access." . $repository->accessType);
             if ($plug == null) {
                 throw new Exception("Cannot find access driver (" . $repository->accessType . ") for repository!");
             }
             AJXP_XMLWriter::header("admin_data");
             $slug = $repository->getSlug();
             if ($slug == "" && $repository->isWriteable()) {
                 $repository->setSlug();
                 ConfService::replaceRepository($repId, $repository);
             }
             if (AuthService::getLoggedUser() != null && AuthService::getLoggedUser()->getGroupPath() != null) {
                 $rgp = $repository->getGroupPath();
                 if ($rgp == null) {
                     $rgp = "/";
                 }
                 if (strlen($rgp) < strlen(AuthService::getLoggedUser()->getGroupPath())) {
                     $repository->setWriteable(false);
                 }
             }
             $nested = array();
             print "<repository index=\"{$repId}\"";
             foreach ($repository as $name => $option) {
                 if (strstr($name, " ") > -1) {
                     continue;
                 }
                 if (!is_array($option)) {
                     if (is_bool($option)) {
                         $option = $option ? "true" : "false";
                     }
                     print " {$name}=\"" . SystemTextEncoding::toUTF8(AJXP_Utils::xmlEntities($option)) . "\" ";
                 } else {
                     if (is_array($option)) {
                         $nested[] = $option;
                     }
                 }
             }
             if (count($nested)) {
                 print ">";
                 foreach ($nested as $option) {
                     foreach ($option as $key => $optValue) {
                         if (is_array($optValue) && count($optValue)) {
                             print "<param name=\"{$key}\"><![CDATA[" . json_encode($optValue) . "]]></param>";
                         } else {
                             if (is_bool($optValue)) {
                                 $optValue = $optValue ? "true" : "false";
                             }
                             $optValue = AJXP_Utils::xmlEntities($optValue, true);
                             print "<param name=\"{$key}\" value=\"{$optValue}\"/>";
                         }
                     }
                 }
                 // Add SLUG
                 if (!$repository->isTemplate) {
                     print "<param name=\"AJXP_SLUG\" value=\"" . $repository->getSlug() . "\"/>";
                 }
                 if ($repository->getGroupPath() != null) {
                     $basePath = "/";
                     if (AuthService::getLoggedUser() != null && AuthService::getLoggedUser()->getGroupPath() != null) {
                         $basePath = AuthService::getLoggedUser()->getGroupPath();
                     }
                     $groupPath = $repository->getGroupPath();
                     if ($basePath != "/") {
                         $groupPath = substr($repository->getGroupPath(), strlen($basePath));
                     }
                     print "<param name=\"AJXP_GROUP_PATH_PARAMETER\" value=\"" . $groupPath . "\"/>";
                 }
                 print "</repository>";
             } else {
                 print "/>";
             }
             if ($repository->hasParent()) {
                 $parent = ConfService::getRepositoryById($repository->getParentId());
                 if (isset($parent) && $parent->isTemplate) {
                     $parentLabel = $parent->getDisplay();
                     $parentType = $parent->getAccessType();
                     print "<template repository_id=\"" . $repository->getParentId() . "\" repository_label=\"{$parentLabel}\" repository_type=\"{$parentType}\">";
                     foreach ($parent->getOptionsDefined() as $parentOptionName) {
                         print "<option name=\"{$parentOptionName}\"/>";
                     }
                     print "</template>";
                 }
             }
             $manifest = $plug->getManifestRawContent("server_settings/param");
             $manifest = AJXP_XMLWriter::replaceAjxpXmlKeywords($manifest);
             print "<ajxpdriver name=\"" . $repository->accessType . "\">{$manifest}</ajxpdriver>";
             print "<metasources>";
             $metas = $pServ->getPluginsByType("metastore");
             $metas = array_merge($metas, $pServ->getPluginsByType("meta"));
             $metas = array_merge($metas, $pServ->getPluginsByType("index"));
             foreach ($metas as $metaPlug) {
                 print "<meta id=\"" . $metaPlug->getId() . "\" label=\"" . AJXP_Utils::xmlEntities($metaPlug->getManifestLabel()) . "\">";
                 $manifest = $metaPlug->getManifestRawContent("server_settings/param");
                 $manifest = AJXP_XMLWriter::replaceAjxpXmlKeywords($manifest);
                 print $manifest;
                 print "</meta>";
             }
             print "</metasources>";
             AJXP_XMLWriter::close("admin_data");
             return;
             break;
         case "edit_repository_label":
         case "edit_repository_data":
             $repId = $httpVars["repository_id"];
             $repo = ConfService::getRepositoryById($repId);
             $res = 0;
             if (isset($httpVars["newLabel"])) {
                 $newLabel = AJXP_Utils::decodeSecureMagic($httpVars["newLabel"]);
                 if ($this->repositoryExists($newLabel)) {
                     AJXP_XMLWriter::header();
                     AJXP_XMLWriter::sendMessage(null, $mess["ajxp_conf.50"]);
                     AJXP_XMLWriter::close();
                     return;
                 }
                 $repo->setDisplay($newLabel);
                 $res = ConfService::replaceRepository($repId, $repo);
             } else {
                 $options = array();
                 $this->parseParameters($httpVars, $options, null, true);
                 if (count($options)) {
                     foreach ($options as $key => $value) {
                         if ($key == "AJXP_SLUG") {
                             $repo->setSlug($value);
                             continue;
                         } elseif ($key == "AJXP_GROUP_PATH_PARAMETER") {
                             $basePath = "/";
                             if (AuthService::getLoggedUser() != null && AuthService::getLoggedUser()->getGroupPath() != null) {
                                 $basePath = AuthService::getLoggedUser()->getGroupPath();
                             }
                             $value = AJXP_Utils::securePath(rtrim($basePath, "/") . "/" . ltrim($value, "/"));
                             $repo->setGroupPath($value);
                             continue;
                         }
                         $repo->addOption($key, $value);
                     }
                 }
                 if ($repo->getOption("DEFAULT_RIGHTS")) {
                     $gp = $repo->getGroupPath();
                     if (empty($gp) || $gp == "/") {
                         $defRole = AuthService::getRole("ROOT_ROLE");
                     } else {
                         $defRole = AuthService::getRole("AJXP_GRP_" . $gp, true);
                     }
                     if ($defRole !== false) {
                         $defRole->setAcl($repId, $repo->getOption("DEFAULT_RIGHTS"));
                         AuthService::updateRole($defRole);
                     }
                 }
                 if (is_file(AJXP_TESTS_FOLDER . "/plugins/test.ajxp_" . $repo->getAccessType() . ".php")) {
                     chdir(AJXP_TESTS_FOLDER . "/plugins");
                     include AJXP_TESTS_FOLDER . "/plugins/test.ajxp_" . $repo->getAccessType() . ".php";
                     $className = "ajxp_" . $repo->getAccessType();
                     $class = new $className();
                     $result = $class->doRepositoryTest($repo);
                     if (!$result) {
                         AJXP_XMLWriter::header();
                         AJXP_XMLWriter::sendMessage(null, $class->failedInfo);
                         AJXP_XMLWriter::close();
                         return;
                     }
                 }
                 ConfService::replaceRepository($repId, $repo);
             }
             AJXP_XMLWriter::header();
             if ($res == -1) {
                 AJXP_XMLWriter::sendMessage(null, $mess["ajxp_conf.53"]);
             } else {
                 AJXP_XMLWriter::sendMessage($mess["ajxp_conf.54"], null);
                 if (isset($httpVars["newLabel"])) {
                     AJXP_XMLWriter::reloadDataNode("", $repId);
                 }
                 AJXP_XMLWriter::reloadRepositoryList();
             }
             AJXP_XMLWriter::close();
             break;
         case "meta_source_add":
             $repId = $httpVars["repository_id"];
             $repo = ConfService::getRepositoryById($repId);
             if (!is_object($repo)) {
                 throw new Exception("Invalid repository id! {$repId}");
             }
             $metaSourceType = AJXP_Utils::sanitize($httpVars["new_meta_source"], AJXP_SANITIZE_ALPHANUM);
             if (isset($httpVars["json_data"])) {
                 $options = json_decode(SystemTextEncoding::magicDequote($httpVars["json_data"]), true);
             } else {
                 $options = array();
                 $this->parseParameters($httpVars, $options, null, true);
             }
             $repoOptions = $repo->getOption("META_SOURCES");
             if (is_array($repoOptions) && isset($repoOptions[$metaSourceType])) {
                 throw new Exception($mess["ajxp_conf.55"]);
             }
             if (!is_array($repoOptions)) {
                 $repoOptions = array();
             }
             $repoOptions[$metaSourceType] = $options;
             uksort($repoOptions, array($this, "metaSourceOrderingFunction"));
             $repo->addOption("META_SOURCES", $repoOptions);
             ConfService::replaceRepository($repId, $repo);
             AJXP_XMLWriter::header();
             AJXP_XMLWriter::sendMessage($mess["ajxp_conf.56"], null);
             AJXP_XMLWriter::close();
             break;
         case "meta_source_delete":
             $repId = $httpVars["repository_id"];
             $repo = ConfService::getRepositoryById($repId);
             if (!is_object($repo)) {
                 throw new Exception("Invalid repository id! {$repId}");
             }
             $metaSourceId = $httpVars["plugId"];
             $repoOptions = $repo->getOption("META_SOURCES");
             if (is_array($repoOptions) && array_key_exists($metaSourceId, $repoOptions)) {
                 unset($repoOptions[$metaSourceId]);
                 uksort($repoOptions, array($this, "metaSourceOrderingFunction"));
                 $repo->addOption("META_SOURCES", $repoOptions);
                 ConfService::replaceRepository($repId, $repo);
             }
             AJXP_XMLWriter::header();
             AJXP_XMLWriter::sendMessage($mess["ajxp_conf.57"], null);
             AJXP_XMLWriter::close();
             break;
         case "meta_source_edit":
             $repId = $httpVars["repository_id"];
             $repo = ConfService::getRepositoryById($repId);
             if (!is_object($repo)) {
                 throw new Exception("Invalid repository id! {$repId}");
             }
             $metaSourceId = $httpVars["plugId"];
             $repoOptions = $repo->getOption("META_SOURCES");
             if (!is_array($repoOptions)) {
                 $repoOptions = array();
             }
             if (isset($httpVars["json_data"])) {
                 $options = json_decode(SystemTextEncoding::magicDequote($httpVars["json_data"]), true);
             } else {
                 $options = array();
                 $this->parseParameters($httpVars, $options, null, true);
             }
             $repoOptions[$metaSourceId] = $options;
             uksort($repoOptions, array($this, "metaSourceOrderingFunction"));
             $repo->addOption("META_SOURCES", $repoOptions);
             ConfService::replaceRepository($repId, $repo);
             AJXP_XMLWriter::header();
             AJXP_XMLWriter::sendMessage($mess["ajxp_conf.58"], null);
             AJXP_XMLWriter::close();
             break;
         case "delete":
             // REST API mapping
             if (isset($httpVars["data_type"])) {
                 switch ($httpVars["data_type"]) {
                     case "repository":
                         $httpVars["repository_id"] = basename($httpVars["data_id"]);
                         break;
                     case "shared_file":
                         $httpVars["shared_file"] = basename($httpVars["data_id"]);
                         break;
                     case "role":
                         $httpVars["role_id"] = basename($httpVars["data_id"]);
                         break;
                     case "user":
                         $httpVars["user_id"] = basename($httpVars["data_id"]);
                         break;
                     case "group":
                         $httpVars["group"] = "/data/users" . $httpVars["data_id"];
                         break;
                     default:
                         break;
                 }
                 unset($httpVars["data_type"]);
                 unset($httpVars["data_id"]);
             }
             if (isset($httpVars["repository_id"])) {
                 $repId = $httpVars["repository_id"];
                 $res = ConfService::deleteRepository($repId);
                 AJXP_XMLWriter::header();
                 if ($res == -1) {
                     AJXP_XMLWriter::sendMessage(null, $mess["ajxp_conf.51"]);
                 } else {
                     AJXP_XMLWriter::sendMessage($mess["ajxp_conf.59"], null);
                     AJXP_XMLWriter::reloadDataNode();
                     AJXP_XMLWriter::reloadRepositoryList();
                 }
                 AJXP_XMLWriter::close();
                 return;
             } else {
                 if (isset($httpVars["shared_file"])) {
                     AJXP_XMLWriter::header();
                     $element = basename($httpVars["shared_file"]);
                     $dlFolder = ConfService::getCoreConf("PUBLIC_DOWNLOAD_FOLDER");
                     $publicletData = $this->loadPublicletData($dlFolder . "/" . $element . ".php");
                     unlink($dlFolder . "/" . $element . ".php");
                     AJXP_XMLWriter::sendMessage($mess["ajxp_shared.13"], null);
                     AJXP_XMLWriter::reloadDataNode();
                     AJXP_XMLWriter::close();
                 } else {
                     if (isset($httpVars["role_id"])) {
                         $roleId = $httpVars["role_id"];
                         if (AuthService::getRole($roleId) === false) {
                             throw new Exception($mess["ajxp_conf.67"]);
                         }
                         AuthService::deleteRole($roleId);
                         AJXP_XMLWriter::header();
                         AJXP_XMLWriter::sendMessage($mess["ajxp_conf.68"], null);
                         AJXP_XMLWriter::reloadDataNode();
                         AJXP_XMLWriter::close();
                     } else {
                         if (isset($httpVars["group"])) {
                             $groupPath = $httpVars["group"];
                             $basePath = substr(AJXP_Utils::forwardSlashDirname($groupPath), strlen("/data/users"));
                             $gName = basename($groupPath);
                             AuthService::deleteGroup($basePath, $gName);
                             AJXP_XMLWriter::header();
                             AJXP_XMLWriter::sendMessage($mess["ajxp_conf.125"], null);
                             AJXP_XMLWriter::reloadDataNode();
                             AJXP_XMLWriter::close();
                         } else {
                             if (!isset($httpVars["user_id"]) || $httpVars["user_id"] == "" || AuthService::isReservedUserId($httpVars["user_id"]) || $loggedUser->getId() == $httpVars["user_id"]) {
                                 AJXP_XMLWriter::header();
                                 AJXP_XMLWriter::sendMessage(null, $mess["ajxp_conf.61"]);
                                 AJXP_XMLWriter::close();
                             }
                             $res = AuthService::deleteUser($httpVars["user_id"]);
                             AJXP_XMLWriter::header();
                             AJXP_XMLWriter::sendMessage($mess["ajxp_conf.60"], null);
                             AJXP_XMLWriter::reloadDataNode();
                             AJXP_XMLWriter::close();
                         }
                     }
                 }
             }
             break;
         case "clear_expired":
             $deleted = $this->clearExpiredFiles();
             AJXP_XMLWriter::header();
             if (count($deleted)) {
                 AJXP_XMLWriter::sendMessage(sprintf($mess["ajxp_shared.23"], count($deleted) . ""), null);
                 AJXP_XMLWriter::reloadDataNode();
             } else {
                 AJXP_XMLWriter::sendMessage($mess["ajxp_shared.24"], null);
             }
             AJXP_XMLWriter::close();
             break;
         case "get_plugin_manifest":
             $ajxpPlugin = AJXP_PluginsService::getInstance()->getPluginById($httpVars["plugin_id"]);
             AJXP_XMLWriter::header("admin_data");
             $fullManifest = $ajxpPlugin->getManifestRawContent("", "xml");
             $xPath = new DOMXPath($fullManifest->ownerDocument);
             $addParams = "";
             $pInstNodes = $xPath->query("server_settings/global_param[contains(@type, 'plugin_instance:')]");
             foreach ($pInstNodes as $pInstNode) {
                 $type = $pInstNode->getAttribute("type");
                 $instType = str_replace("plugin_instance:", "", $type);
                 $fieldName = $pInstNode->getAttribute("name");
                 $pInstNode->setAttribute("type", "group_switch:" . $fieldName);
                 $typePlugs = AJXP_PluginsService::getInstance()->getPluginsByType($instType);
                 foreach ($typePlugs as $typePlug) {
                     if ($typePlug->getId() == "auth.multi") {
                         continue;
                     }
                     $checkErrorMessage = "";
                     try {
                         $typePlug->performChecks();
                     } catch (Exception $e) {
                         $checkErrorMessage = " (Warning : " . $e->getMessage() . ")";
                     }
                     $tParams = AJXP_XMLWriter::replaceAjxpXmlKeywords($typePlug->getManifestRawContent("server_settings/param[not(@group_switch_name)]"));
                     $addParams .= '<global_param group_switch_name="' . $fieldName . '" name="instance_name" group_switch_label="' . $typePlug->getManifestLabel() . $checkErrorMessage . '" group_switch_value="' . $typePlug->getId() . '" default="' . $typePlug->getId() . '" type="hidden"/>';
                     $addParams .= str_replace("<param", "<global_param group_switch_name=\"{$fieldName}\" group_switch_label=\"" . $typePlug->getManifestLabel() . $checkErrorMessage . "\" group_switch_value=\"" . $typePlug->getId() . "\" ", $tParams);
                     $addParams .= str_replace("<param", "<global_param", AJXP_XMLWriter::replaceAjxpXmlKeywords($typePlug->getManifestRawContent("server_settings/param[@group_switch_name]")));
                     $addParams .= AJXP_XMLWriter::replaceAjxpXmlKeywords($typePlug->getManifestRawContent("server_settings/global_param"));
                 }
             }
             $allParams = AJXP_XMLWriter::replaceAjxpXmlKeywords($fullManifest->ownerDocument->saveXML($fullManifest));
             $allParams = str_replace('type="plugin_instance:', 'type="group_switch:', $allParams);
             $allParams = str_replace("</server_settings>", $addParams . "</server_settings>", $allParams);
             echo $allParams;
             $definitions = $ajxpPlugin->getConfigsDefinitions();
             $values = $ajxpPlugin->getConfigs();
             if (!is_array($values)) {
                 $values = array();
             }
             echo "<plugin_settings_values>";
             foreach ($values as $key => $value) {
                 $attribute = true;
                 $type = $definitions[$key]["type"];
                 if ($type == "array" && is_array($value)) {
                     $value = implode(",", $value);
                 } else {
                     if ((strpos($type, "group_switch:") === 0 || strpos($type, "plugin_instance:") === 0) && is_array($value)) {
                         $res = array();
                         $this->flattenKeyValues($res, $value, $key);
                         foreach ($res as $newKey => $newVal) {
                             echo "<param name=\"{$newKey}\" value=\"" . AJXP_Utils::xmlEntities($newVal) . "\"/>";
                         }
                         continue;
                     } else {
                         if ($type == "boolean") {
                             $value = $value === true || $value === "true" || $value == 1 ? "true" : "false";
                         } else {
                             if ($type == "textarea") {
                                 $attribute = false;
                             }
                         }
                     }
                 }
                 if ($attribute) {
                     echo "<param name=\"{$key}\" value=\"" . AJXP_Utils::xmlEntities($value) . "\"/>";
                 } else {
                     echo "<param name=\"{$key}\" cdatavalue=\"true\"><![CDATA[" . $value . "]]></param>";
                 }
             }
             if ($ajxpPlugin->getType() != "core") {
                 echo "<param name=\"AJXP_PLUGIN_ENABLED\" value=\"" . ($ajxpPlugin->isEnabled() ? "true" : "false") . "\"/>";
             }
             echo "</plugin_settings_values>";
             echo "<plugin_doc><![CDATA[<p>" . $ajxpPlugin->getPluginInformationHTML("Charles du Jeu", "http://pyd.io/plugins/") . "</p>";
             if (file_exists($ajxpPlugin->getBaseDir() . "/plugin_doc.html")) {
                 echo file_get_contents($ajxpPlugin->getBaseDir() . "/plugin_doc.html");
             }
             echo "]]></plugin_doc>";
             AJXP_XMLWriter::close("admin_data");
             break;
         case "run_plugin_action":
             $options = array();
             $this->parseParameters($httpVars, $options, null, true);
             $pluginId = $httpVars["action_plugin_id"];
             if (isset($httpVars["button_key"])) {
                 $options = $options[$httpVars["button_key"]];
             }
             $plugin = AJXP_PluginsService::getInstance()->softLoad($pluginId, $options);
             if (method_exists($plugin, $httpVars["action_plugin_method"])) {
                 try {
                     $res = call_user_func(array($plugin, $httpVars["action_plugin_method"]), $options);
                 } catch (Exception $e) {
                     echo "ERROR:" . $e->getMessage();
                     break;
                 }
                 echo $res;
             } else {
                 echo 'ERROR: Plugin ' . $httpVars["action_plugin_id"] . ' does not implement ' . $httpVars["action_plugin_method"] . ' method!';
             }
             break;
         case "edit_plugin_options":
             $options = array();
             $this->parseParameters($httpVars, $options, null, true);
             $confStorage = ConfService::getConfStorageImpl();
             $confStorage->savePluginConfig($httpVars["plugin_id"], $options);
             @unlink(AJXP_PLUGINS_CACHE_FILE);
             @unlink(AJXP_PLUGINS_REQUIRES_FILE);
             @unlink(AJXP_PLUGINS_MESSAGES_FILE);
             AJXP_XMLWriter::header();
             AJXP_XMLWriter::sendMessage($mess["ajxp_conf.97"], null);
             AJXP_XMLWriter::close();
             break;
         case "generate_api_docs":
             PydioSdkGenerator::analyzeRegistry();
             break;
         default:
             break;
     }
     return;
 }