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

Commit fb1eb59

Browse files
committed
Allow editing permission mask for non-editable workspace
Tweak how we display Root Group role When editing a group, compute a "Parent Role" based on the parent groups
1 parent aadb2cf commit fb1eb59

File tree

1 file changed

+52
-2
lines changed

1 file changed

+52
-2
lines changed

core/src/plugins/access.ajxp_conf/class.ajxp_confAccessDriver.php

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,26 @@ public function switchAction($action, $httpVars, $fileVars)
683683
}
684684
} else if (isSet($groupPath)) {
685685
$data["GROUP"] = array("PATH" => $groupPath, "LABEL" => $groupLabel);
686+
if($roleId != "AJXP_GRP_/"){
687+
$parentGroupRoles = array();
688+
$parentPath = AJXP_Utils::forwardSlashDirname($roleId);
689+
while($parentPath != "AJXP_GRP_"){
690+
$parentRole = AuthService::getRole($parentPath);
691+
if($parentRole != null) {
692+
array_unshift($parentGroupRoles, $parentRole);
693+
}
694+
$parentPath = AJXP_Utils::forwardSlashDirname($parentPath);
695+
}
696+
$rootGroup = AuthService::getRole("AJXP_GRP_/");
697+
if($rootGroup != null) array_unshift($parentGroupRoles, $rootGroup);
698+
if(count($parentGroupRoles)){
699+
$parentRole = clone array_shift($parentGroupRoles);
700+
foreach($parentGroupRoles as $pgRole){
701+
$parentRole = $pgRole->override($parentRole);
702+
}
703+
$data["PARENT_ROLE"] = $parentRole->getDataArray();
704+
}
705+
}
686706
}
687707

688708

@@ -1562,7 +1582,23 @@ public function switchAction($action, $httpVars, $fileVars)
15621582
$repId = $httpVars["repository_id"];
15631583
$repo = ConfService::getRepositoryById($repId);
15641584
if(!$repo->isWriteable()){
1565-
throw new Exception("This workspace is not writeable. Please edit directly the conf/bootstrap_repositories.php file.");
1585+
if (isSet($httpVars["permission_mask"]) && !empty($httpVars["permission_mask"])){
1586+
$mask = json_decode($httpVars["permission_mask"], true);
1587+
$rootGroup = AuthService::getRole("AJXP_GRP_/");
1588+
if(count($mask)){
1589+
$perm = new AJXP_PermissionMask($mask);
1590+
$rootGroup->setMask($repId, $perm);
1591+
}else{
1592+
$rootGroup->clearMask($repId);
1593+
}
1594+
AuthService::updateRole($rootGroup);
1595+
AJXP_XMLWriter::header();
1596+
AJXP_XMLWriter::sendMessage("The permission mask was updated for this workspace", null);
1597+
AJXP_XMLWriter::close();
1598+
break;
1599+
}else{
1600+
throw new Exception("This workspace is not writeable. Please edit directly the conf/bootstrap_repositories.php file.");
1601+
}
15661602
}
15671603
$res = 0;
15681604
if (isSet($httpVars["newLabel"])) {
@@ -2203,6 +2239,20 @@ public function listUsers($root, $child, $hashValue = null, $returnNodes = false
22032239
$users = AuthService::listUsers($baseGroup, "", -1, -1, true, false);
22042240
$groups = AuthService::listChildrenGroups($baseGroup);
22052241
}
2242+
2243+
if($this->getName() == "ajxp_admin" && $baseGroup == "/" && $hashValue == 1){
2244+
$nodeKey = "/data/".$root."/";
2245+
$meta = array(
2246+
"icon" => "users-folder.png",
2247+
"icon_class" => "icon-home",
2248+
"ajxp_mime" => "group",
2249+
"object_id" => "/"
2250+
);
2251+
$xml = AJXP_XMLWriter::renderNode($nodeKey, "Root Group", true, $meta, true, false);
2252+
if(!$returnNodes) print($xml);
2253+
else $allNodes[$nodeKey] = $xml;
2254+
}
2255+
22062256
foreach ($groups as $groupId => $groupLabel) {
22072257

22082258
$nodeKey = "/data/".$root."/".ltrim($groupId,"/");
@@ -2307,7 +2357,7 @@ public function listRoles($root, $child, $hashValue = null, $returnNodes = false
23072357
if(!AuthService::usersEnabled()) return array();
23082358
$roles = AuthService::getRolesList(array(), !$this->listSpecialRoles);
23092359
ksort($roles);
2310-
if(!$this->listSpecialRoles){
2360+
if(!$this->listSpecialRoles && !$this->getName() == "ajxp_admin"){
23112361
$rootGroupRole = AuthService::getRole("AJXP_GRP_/", true);
23122362
if($rootGroupRole->getLabel() == "AJXP_GRP_/"){
23132363
$rootGroupRole->setLabel("Root Group");

0 commit comments

Comments
 (0)