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

Commit dd8ffa7

Browse files
committed
Optional parameter for listAcls() function.
1 parent 97b5eee commit dd8ffa7

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

core/src/core/classes/class.AJXP_Role.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,22 @@ public function getAcl($repositoryId)
158158
}
159159
return "";
160160
}
161+
161162
/**
163+
* @param bool $accessibleOnly If set to true, return only r, w, or rw.
162164
* @return array Associative array[REPO_ID] => RIGHT_STRING (r / w / rw / AJXP_VALUE_CLEAR)
163165
*/
164-
public function listAcls()
166+
public function listAcls($accessibleOnly = false)
165167
{
166-
return $this->acls;
168+
if(!$accessibleOnly){
169+
return $this->acls;
170+
}
171+
$output = array();
172+
foreach ($this->acls as $id => $acl) {
173+
if(empty($acl) || $acl == AJXP_VALUE_CLEAR) continue;
174+
$output[$id] = $acl;
175+
}
176+
return $output;
167177
}
168178

169179
public function clearAcls()

core/src/core/classes/class.AuthService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ public static function getDefaultRootId()
599599
{
600600
$loggedUser = self::getLoggedUser();
601601
if($loggedUser == null) return 0;
602-
$acls = $loggedUser->mergedRole->listAcls();
602+
$acls = $loggedUser->mergedRole->listAcls(true);
603603
foreach($acls as $key => $right){
604604
if (!empty($right) && ConfService::getRepositoryById($key) != null) return $key;
605605
}

core/src/core/classes/class.ConfService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,7 @@ protected function initRepositoriesListInst($scope = "user", $includeShared = tr
810810
if($scope == "user"){
811811
$acls = array();
812812
if(AuthService::getLoggedUser() != null){
813-
$acls = AuthService::getLoggedUser()->mergedRole->listAcls();
813+
$acls = AuthService::getLoggedUser()->mergedRole->listAcls(true);
814814
}
815815
if(!count($acls)) {
816816
$drvList = array();

0 commit comments

Comments
 (0)