diff --git a/core/src/core/classes/class.AJXP_Utils.php b/core/src/core/classes/class.AJXP_Utils.php index 231a98ca8c..e90b483d7d 100644 --- a/core/src/core/classes/class.AJXP_Utils.php +++ b/core/src/core/classes/class.AJXP_Utils.php @@ -1884,6 +1884,7 @@ public static function glob_recursive($pattern, $flags = 0) public static function regexpToLike($regexp) { + $regexp = trim($regexp, '/'); $left = "~"; $right = "~"; if ($regexp[0]=="^") { @@ -1900,6 +1901,7 @@ public static function regexpToLike($regexp) public static function cleanRegexp($regexp) { + $regexp = str_replace("\/", "/", trim($regexp, '/')); return ltrim(rtrim($regexp, "$"), "^"); } diff --git a/core/src/core/classes/class.AuthService.php b/core/src/core/classes/class.AuthService.php index 80b8c3890c..698ccd8d3a 100644 --- a/core/src/core/classes/class.AuthService.php +++ b/core/src/core/classes/class.AuthService.php @@ -1058,7 +1058,7 @@ public static function authSupportsPagination() public static function authCountUsers($baseGroup="/", $regexp="", $filterProperty = null, $filterValue = null, $recursive = true) { $authDriver = ConfService::getAuthDriverImpl(); - return $authDriver->getUsersCount($baseGroup, $regexp, $filterProperty, $filterValue, $recursive); + return $authDriver->getUsersCount(self::filterBaseGroup($baseGroup), $regexp, $filterProperty, $filterValue, $recursive); } /** diff --git a/core/src/core/classes/class.ConfService.php b/core/src/core/classes/class.ConfService.php index c98c5db29a..2216778a4f 100644 --- a/core/src/core/classes/class.ConfService.php +++ b/core/src/core/classes/class.ConfService.php @@ -514,8 +514,10 @@ public static function filterRepositoryListWithCriteria($repoList, $criteria){ $repositories = array(); $searchableKeys = array("uuid", "parent_uuid", "owner_user_id", "display", "accessType", "isTemplate", "slug", "groupPath"); foreach ($repoList as $repoId => $repoObject) { + $failOneCriteria = false; foreach($criteria as $key => $value){ if(!in_array($key, $searchableKeys)) continue; + $criteriumOk = false; if($key == "uuid") $comp = $repoObject->getUniqueId(); else if($key == "parent_uuid") $comp = $repoObject->getParentId(); else if($key == "owner_user_id") $comp = $repoObject->getUniqueUser(); @@ -525,16 +527,28 @@ public static function filterRepositoryListWithCriteria($repoList, $criteria){ else if($key == "slug") $comp = $repoObject->getSlug(); else if($key == "groupPath") $comp = $repoObject->getGroupPath(); if(is_array($value) && in_array($comp, $value)){ - $repositories[$repoId] = $repoObject; + //$repositories[$repoId] = $repoObject; + $criteriumOk = true; }else if($value == AJXP_FILTER_EMPTY && empty($comp)){ - $repositories[$repoId] = $repoObject; + //$repositories[$repoId] = $repoObject; + $criteriumOk = true; }else if($value == AJXP_FILTER_NOT_EMPTY && !empty($comp)){ - $repositories[$repoId] = $repoObject; + //$repositories[$repoId] = $repoObject; + $criteriumOk = true; }else if(is_string($value) && strpos($value, "regexp:")===0 && preg_match(str_replace("regexp:", "", $value), $comp)){ - $repositories[$repoId] = $repoObject; + //$repositories[$repoId] = $repoObject; + $criteriumOk = true; }else if($value == $comp){ - $repositories[$repoId] = $repoObject; + //$repositories[$repoId] = $repoObject; + $criteriumOk = true; } + if(!$criteriumOk) { + $failOneCriteria = true; + break; + } + } + if(!$failOneCriteria){ + $repositories[$repoId] = $repoObject; } } return $repositories; diff --git a/core/src/core/classes/class.Repository.php b/core/src/core/classes/class.Repository.php index 06271e9bd6..86ae19577d 100644 --- a/core/src/core/classes/class.Repository.php +++ b/core/src/core/classes/class.Repository.php @@ -423,7 +423,7 @@ public function getDisplay() */ public function getId() { - if($this->isWriteable()) return $this->getUniqueId(); + if($this->isWriteable() || $this->id == null) return $this->getUniqueId(); return $this->id; } diff --git a/core/src/plugins/access.ajxp_conf/class.ajxp_confAccessDriver.php b/core/src/plugins/access.ajxp_conf/class.ajxp_confAccessDriver.php index 0c0df5d867..2edbff2751 100644 --- a/core/src/plugins/access.ajxp_conf/class.ajxp_confAccessDriver.php +++ b/core/src/plugins/access.ajxp_conf/class.ajxp_confAccessDriver.php @@ -241,7 +241,12 @@ public function recursiveSearchGroups($baseGroup, $term) $users = AuthService::listUsers($baseGroup, $term); foreach ($users as $userId => $userObject) { - $trimmedG = trim($userObject->getGroupPath(), "/"); + $gPath = $userObject->getGroupPath(); + $realGroup = AuthService::filterBaseGroup(AuthService::getLoggedUser()->getGroupPath()); + if(strlen($realGroup) > 1 && strpos($gPath, $realGroup) === 0){ + $gPath = substr($gPath, strlen($realGroup)); + } + $trimmedG = trim($gPath, "/"); if(!empty($trimmedG)) $trimmedG .= "/"; $nodeKey = "/data/users/".$trimmedG.$userId; @@ -2019,13 +2024,25 @@ public function listRepositories($root, $child, $hashValue = null, $returnNodes $count = null; // Load all repositories = normal, templates, and templates children - $repos = ConfService::listRepositoriesWithCriteria(array( - "parent_uuid" => AJXP_FILTER_EMPTY, - "ORDERBY" => array("KEY" => "display", "DIR"=>"ASC"), - "CURSOR" => array("OFFSET" => $offset, "LIMIT" => $REPOS_PER_PAGE) - ), $count - ); + $currentUserIsGroupAdmin = (AuthService::getLoggedUser() != null && AuthService::getLoggedUser()->getGroupPath() != "/"); + if($currentUserIsGroupAdmin){ + $repos = ConfService::listRepositoriesWithCriteria(array( + "owner_user_id" => AJXP_FILTER_EMPTY, + "groupPath" => "regexp:/^".str_replace("/", "\/", AuthService::getLoggedUser()->getGroupPath()).'/', + "ORDERBY" => array("KEY" => "display", "DIR"=>"ASC"), + "CURSOR" => array("OFFSET" => $offset, "LIMIT" => $REPOS_PER_PAGE) + ), $count + ); + }else{ + $repos = ConfService::listRepositoriesWithCriteria(array( + "parent_uuid" => AJXP_FILTER_EMPTY, + "ORDERBY" => array("KEY" => "display", "DIR"=>"ASC"), + "CURSOR" => array("OFFSET" => $offset, "LIMIT" => $REPOS_PER_PAGE) + ), $count + ); + } if(!$returnNodes){ + var_dump($count); AJXP_XMLWriter::renderPaginationData($count, $hashValue, ceil($count/$REPOS_PER_PAGE)); AJXP_XMLWriter::sendFilesListComponentConfig(' diff --git a/core/src/plugins/conf.sql/class.sqlConfDriver.php b/core/src/plugins/conf.sql/class.sqlConfDriver.php index 2155eb5f0d..c009b9d42a 100644 --- a/core/src/plugins/conf.sql/class.sqlConfDriver.php +++ b/core/src/plugins/conf.sql/class.sqlConfDriver.php @@ -270,7 +270,7 @@ public function listRepositoriesWithCriteria($criteria, &$count = null){ } }else if(strpos($cValue, "regexp:") === 0){ $regexp = str_replace("regexp:", "", $cValue); - $wheres[] = array("[$cName] ".AJXP_Utils::regexpToLike($regexp), AJXP_Utils::cleanLike($regexp)); + $wheres[] = array("[$cName] ".AJXP_Utils::regexpToLike($regexp), AJXP_Utils::cleanRegexp($regexp)); }else if ($cValue == AJXP_FILTER_NOT_EMPTY){ $wheres[] = array("[$cName] IS NOT NULL"); }else if ($cValue == AJXP_FILTER_EMPTY){