Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
Fix the way we list repositories for a user ACL.
Browse files Browse the repository at this point in the history
  • Loading branch information
cdujeu committed Nov 26, 2014
1 parent cd0987d commit ffbfed8
Showing 1 changed file with 22 additions and 24 deletions.
46 changes: 22 additions & 24 deletions core/src/plugins/access.ajxp_conf/class.ajxp_confAccessDriver.php
Expand Up @@ -69,7 +69,7 @@ private function getEditableParameters($withLabel = false){
foreach ($actions as $actPid => $actionGroup) {
ksort($actionGroup, SORT_STRING);
$actions[$actPid] = array();
foreach ($actionGroup as $k => $v) {
foreach ($actionGroup as $v) {
$actions[$actPid][] = $v;
}
}
Expand Down Expand Up @@ -137,7 +137,7 @@ public function listAllActions($action, $httpVars, $fileVars)
foreach ($actions as $actPid => $actionGroup) {
ksort($actionGroup, SORT_STRING);
$actions[$actPid] = array();
foreach ($actionGroup as $k => $v) {
foreach ($actionGroup as $v) {
$actions[$actPid][] = $v;
}
}
Expand Down Expand Up @@ -209,7 +209,6 @@ public function preProcessBookmarkAction($action, &$httpVars, $fileVars)
if (isSet($httpVars["bm_action"]) && $httpVars["bm_action"] == "add_bookmark" && AuthService::usersEnabled()) {
$bmUser = AuthService::getLoggedUser();
$bookmarks = $bmUser->getBookmarks();
$found = false;
foreach ($bookmarks as $bm) {
if ($bm["PATH"] == $httpVars["bm_path"]) {
$httpVars["bm_action"] = "delete_bookmark";
Expand Down Expand Up @@ -389,6 +388,7 @@ public function switchAction($action, $httpVars, $fileVars)
unset($rootNodes["developer"]);
}
AJXP_Controller::applyHook("ajxp_conf.list_config_nodes", array(&$rootNodes));
$parentName = "";
$dir = trim(AJXP_Utils::decodeSecureMagic((isset($httpVars["dir"])?$httpVars["dir"]:"")), " /");
if ($dir != "") {
$hash = null;
Expand Down Expand Up @@ -514,6 +514,8 @@ public function switchAction($action, $httpVars, $fileVars)
case "edit_role" :
$roleId = SystemTextEncoding::magicDequote($httpVars["role_id"]);
$roleGroup = false;
$userObject = null;
$groupLabel = null;
if (strpos($roleId, "AJXP_GRP_") === 0) {
$groupPath = substr($roleId, strlen("AJXP_GRP_"));
$filteredGroupPath = AuthService::filterBaseGroup($groupPath);
Expand Down Expand Up @@ -542,13 +544,15 @@ public function switchAction($action, $httpVars, $fileVars)
if (isSet($httpVars["format"]) && $httpVars["format"] == "json") {
HTMLWriter::charsetHeader("application/json");
$roleData = $role->getDataArray();
//$repos = ConfService::getAccessibleRepositories($userObject, true, true, ($userObject == null ? false:true));
$allReps = ConfService::getRepositoriesList("all", ($userObject == null ? false:true));
$allReps = ConfService::getRepositoriesList("all", false);
$repos = array();
if(!empty($userObject)){
// USER
foreach ($allReps as $repositoryId => $repositoryObject) {
if (!ConfService::repositoryIsAccessible($repositoryId, $repositoryObject, $userObject, true, ($userObject == null ? false:true))) {
if (!AuthService::canAssign($repositoryObject, $userObject) || $repositoryObject->isTemplate
|| ($repositoryObject->getAccessType()=="ajxp_conf" && !$userObject->isAdmin())
|| ($repositoryObject->getUniqueUser() != null && $repositoryObject->getUniqueUser() != $userObject->getId())
){
continue;
}
$repos[$repositoryId] = SystemTextEncoding::toUTF8($repositoryObject->getDisplay());
Expand Down Expand Up @@ -606,6 +610,7 @@ public function switchAction($action, $httpVars, $fileVars)

$roleId = SystemTextEncoding::magicDequote($httpVars["role_id"]);
$roleGroup = false;
$userObject = $usrId = $filteredGroupPath = null;
if (strpos($roleId, "AJXP_GRP_") === 0) {
$groupPath = substr($roleId, strlen("AJXP_GRP_"));
$filteredGroupPath = AuthService::filterBaseGroup($groupPath);
Expand Down Expand Up @@ -686,13 +691,11 @@ public function switchAction($action, $httpVars, $fileVars)
$roleData["ACTIONS"] = $originalRole->listActionsStates();
}

$output = array();
try {
$originalRole->bunchUpdate($roleData);
if (isSet($userObject)) {
$userObject->personalRole = $originalRole;
$userObject->save("superuser");
//AuthService::updateRole($originalRole, $userObject);
} else {
AuthService::updateRole($originalRole);
}
Expand Down Expand Up @@ -856,7 +859,7 @@ public function switchAction($action, $httpVars, $fileVars)
}

$confStorage = ConfService::getConfStorageImpl();

$userId = null;
foreach ($userSelection->getFiles() as $selectedUser) {
$userId = basename($selectedUser);
if (!AuthService::userExists($userId)) {
Expand Down Expand Up @@ -910,6 +913,7 @@ public function switchAction($action, $httpVars, $fileVars)
$selection->initFromHttpVars($httpVars);
$files = $selection->getFiles();
$detectedRoles = array();
$roleId = null;

if (isSet($httpVars["role_id"]) && isset($httpVars["update_role_action"])) {
$update = $httpVars["update_role_action"];
Expand Down Expand Up @@ -1544,7 +1548,7 @@ public function switchAction($action, $httpVars, $fileVars)
AJXP_XMLWriter::sendMessage(null, $mess["ajxp_conf.61"]);
AJXP_XMLWriter::close();
}
$res = AuthService::deleteUser($httpVars["user_id"]);
AuthService::deleteUser($httpVars["user_id"]);
AJXP_XMLWriter::header();
AJXP_XMLWriter::sendMessage($mess["ajxp_conf.60"], null);
AJXP_XMLWriter::reloadDataNode();
Expand Down Expand Up @@ -1732,11 +1736,10 @@ public function listPlugins($dir, $root = NULL, $hash = null, $returnNodes = fal
<column messageId="ajxp_conf.102" attributeName="plugin_id" sortType="String"/>
<column messageId="ajxp_conf.103" attributeName="plugin_description" sortType="String"/>
</columns>');
$mess = ConfService::getMessages();
$all = $first = "";
foreach ($uniqTypes as $type) {
if(!isset($types[$type])) continue;
foreach ($types[$type] as $pId => $pObject) {
foreach ($types[$type] as $pObject) {
$isMain = ($pObject->getId() == "core.ajaxplorer");
$meta = array(
"icon" => ($isMain?"preferences_desktop.png":"desktop.png"),
Expand Down Expand Up @@ -1771,7 +1774,7 @@ public function listPlugins($dir, $root = NULL, $hash = null, $returnNodes = fal
<column messageId="ajxp_conf.105" attributeName="can_active" sortType="String" defaultWidth="10%"/>
</columns>');
$mess = ConfService::getMessages();
foreach ($types[$type] as $pId => $pObject) {
foreach ($types[$type] as $pObject) {
$errors = "OK";
try {
$pObject->performChecks();
Expand Down Expand Up @@ -1857,7 +1860,7 @@ public function listUsers($root, $child, $hashValue = null, $returnNodes = false
</columns>';
}
if(!$returnNodes) AJXP_XMLWriter::sendFilesListComponentConfig($columns);
if(!AuthService::usersEnabled()) return ;
if(!AuthService::usersEnabled()) return array();
if(empty($hashValue)) $hashValue = 1;

$count = AuthService::authCountUsers($baseGroup, "", null, null, false);
Expand Down Expand Up @@ -1892,7 +1895,7 @@ public function listUsers($root, $child, $hashValue = null, $returnNodes = false
$mess = ConfService::getMessages();
$loggedUser = AuthService::getLoggedUser();
$userArray = array();
foreach ($users as $userIndex => $userObject) {
foreach ($users as $userObject) {
$label = $userObject->getId();
if ($userObject->hasParent()) {
$label = $userObject->getParent()."000".$label;
Expand All @@ -1913,7 +1916,6 @@ public function listUsers($root, $child, $hashValue = null, $returnNodes = false
if ($userObject->hasParent()) {
$icon = "user_child";
}
$rightsString = "";
if ($isAdmin) {
$rightsString = $mess["ajxp_conf.63"];
} else {
Expand Down Expand Up @@ -1958,9 +1960,8 @@ public function listRoles($root, $child, $hashValue = null, $returnNodes = false
<column messageId="ajxp_conf.114" attributeName="is_default" sortType="String"/>
<column messageId="ajxp_conf.62" attributeName="rights_summary" sortType="String"/>
</columns>');
if(!AuthService::usersEnabled()) return ;
if(!AuthService::usersEnabled()) return array();
$roles = AuthService::getRolesList(array(), !$this->listSpecialRoles);
$mess = ConfService::getMessages();
ksort($roles);
foreach ($roles as $roleId => $roleObject) {
//if(strpos($roleId, "AJXP_GRP_") === 0 && !$this->listSpecialRoles) continue;
Expand Down Expand Up @@ -2111,7 +2112,7 @@ public function listActions($dir, $root = NULL, $hash = null, $returnNodes = fal
$allNodes = array();
$parts = explode("/",$dir);
$pServ = AJXP_PluginsService::getInstance();
$activePlugins = $pServ->getActivePlugins();
//$activePlugins = $pServ->getActivePlugins();
$types = $pServ->getDetectedPlugins();
if (count($parts) == 1) {
// list all types
Expand All @@ -2138,8 +2139,7 @@ public function listActions($dir, $root = NULL, $hash = null, $returnNodes = fal
<column messageId="ajxp_conf.101" attributeName="ajxp_label" sortType="String"/>
<column messageId="ajxp_conf.103" attributeName="actions" sortType="String"/>
</columns>');
$pObject = new AJXP_Plugin("","");
foreach ($types[$type] as $pId => $pObject) {
foreach ($types[$type] as $pObject) {
$actions = $pObject->getManifestRawContent("//action/@name", "xml", true);
$actLabel = array();
if ($actions->length) {
Expand Down Expand Up @@ -2169,7 +2169,6 @@ public function listActions($dir, $root = NULL, $hash = null, $returnNodes = fal
<column messageId="ajxp_conf.101" attributeName="ajxp_label" sortType="String" defaultWidth="10%"/>
<column messageId="ajxp_conf.103" attributeName="parameters" sortType="String" fixedWidth="30%"/>
</columns>');
$pObject = new AJXP_Plugin("","");
$pObject = $types[$type][$name];

$actions = $pObject->getManifestRawContent("//action", "xml", true);
Expand Down Expand Up @@ -2204,7 +2203,6 @@ public function listActions($dir, $root = NULL, $hash = null, $returnNodes = fal
$paramLabel[]= '. ['.$param->getAttribute("type").'] <b>'.$param->getAttribute("name").($param->getAttribute("mandatory") == "true" ? '*':'').'</b> : '.$param->getAttribute("description");
}
}
$parameters = "";
$meta = array(
"icon" => "preferences_plugin.png",
"action_id" => $actName,
Expand Down Expand Up @@ -2309,7 +2307,7 @@ public function printDiagnostic($dir, $root = NULL, $hash = null, $returnNodes =
$outputArray = array();
$testedParams = array();
$allNodes = array();
$passed = AJXP_Utils::runTests($outputArray, $testedParams);
AJXP_Utils::runTests($outputArray, $testedParams);
AJXP_Utils::testResultsToFile($outputArray, $testedParams);
if(!$returnNodes) AJXP_XMLWriter::sendFilesListComponentConfig('<columns switchDisplayMode="list" switchGridMode="fileList" template_name="ajxp_conf.diagnostic" defaultWidth="20%"><column messageId="ajxp_conf.23" attributeName="ajxp_label" sortType="String"/><column messageId="ajxp_conf.24" attributeName="data" sortType="String"/></columns>');
if (is_file(TESTS_RESULT_FILE)) {
Expand Down

0 comments on commit ffbfed8

Please sign in to comment.