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

Commit 25f4a33

Browse files
committed
writeRepositoriesData: remove unnecessary code
Definitely skip the admin rights check, just give the access to ajxp_conf
1 parent b4a46d4 commit 25f4a33

File tree

4 files changed

+6
-47
lines changed

4 files changed

+6
-47
lines changed

core/src/core/classes/class.AJXP_XMLWriter.php

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -629,11 +629,6 @@ public static function writeRepositoriesData($loggedUser)
629629

630630
$accessible = ConfService::getAccessibleRepositories($loggedUser, false, false);
631631
foreach ($accessible as $repoId => $repoObject) {
632-
$toLast = false;
633-
if ($repoObject->getAccessType()=="ajxp_conf") {
634-
if(AuthService::usersEnabled() && !$loggedUser->isAdmin())continue;
635-
$toLast = true;
636-
}
637632
$rightString = "";
638633
$streamString = "";
639634
if (in_array($repoObject->accessType, $streams)) {
@@ -648,13 +643,11 @@ public static function writeRepositoriesData($loggedUser)
648643
$slugString = "repositorySlug=\"$slug\"";
649644
}
650645
$isSharedString = "";
651-
$ownerLabel = null;
652646
if ($repoObject->hasOwner()) {
653647
$uId = $repoObject->getOwner();
654648
$uObject = ConfService::getConfStorageImpl()->createUserObject($uId);
655649
$label = $uObject->personalRole->filterParameterValue("core.conf", "USER_DISPLAY_NAME", AJXP_REPO_SCOPE_ALL, $uId);
656650
if(empty($label)) $label = $uId;
657-
$ownerLabel = $label;
658651
$isSharedString = 'owner="'.AJXP_Utils::xmlEntities($label).'"';
659652
}
660653
$descTag = "";
@@ -686,17 +679,9 @@ public static function writeRepositoriesData($loggedUser)
686679
}
687680
$roleString.='acl="'.$merged->getAcl($repoId).'"';
688681
}
689-
$xmlString = "<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>";
690-
if ($toLast) {
691-
$lastString = $xmlString;
692-
} else {
693-
$st .= $xmlString;
694-
}
682+
$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>";
695683
}
696684

697-
if (isSet($lastString)) {
698-
$st.= $lastString;
699-
}
700685
$st .= "</repositories>";
701686
return $st;
702687
}

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

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -592,23 +592,6 @@ public static function getDefaultRootId()
592592
if (!empty($right) && ConfService::getRepositoryById($key) != null) return $key;
593593
}
594594
return 0;
595-
/*
596-
$repoList = ConfService::getRepositoriesList();
597-
foreach ($repoList as $rootDirIndex => $rootDirObject) {
598-
if ($loggedUser->canRead($rootDirIndex."") || $loggedUser->canWrite($rootDirIndex."")) {
599-
// Warning : do not grant access to admin repository to a non admin, or there will be
600-
// an "Empty Repository Object" error.
601-
if ($rootDirObject->getAccessType()=="ajxp_conf" && self::usersEnabled() && !$loggedUser->isAdmin()) {
602-
continue;
603-
}
604-
if ($rootDirObject->getAccessType() == "ajxp_shared" && count($repoList) > 1) {
605-
continue;
606-
}
607-
return $rootDirIndex;
608-
}
609-
}
610-
return 0;
611-
*/
612595
}
613596

614597
/**
@@ -618,16 +601,7 @@ public static function getDefaultRootId()
618601
*/
619602
public static function updateAdminRights($adminUser)
620603
{
621-
if(ConfService::getCoreConf("SKIP_ADMIN_RIGHTS_ALL_REPOS") !== true){
622-
$allRepoList = ConfService::getRepositoriesList("all", false);
623-
foreach ($allRepoList as $repoId => $repoObject) {
624-
if(!self::allowedForCurrentGroup($repoObject, $adminUser)) continue;
625-
if($repoObject->hasOwner() && $repoObject->getOwner() != $adminUser->getId()) continue;
626-
$adminUser->personalRole->setAcl($repoId, "rw");
627-
}
628-
$adminUser->recomputeMergedRole();
629-
$adminUser->save("superuser");
630-
}else if($adminUser->personalRole->getAcl('ajxp_conf') != "rw"){
604+
if($adminUser->personalRole->getAcl('ajxp_conf') != "rw"){
631605
$adminUser->personalRole->setAcl('ajxp_conf', 'rw');
632606
$adminUser->recomputeMergedRole();
633607
$adminUser->save("superuser");

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ public static function repositoryIsAccessible($repositoryId, $repositoryObject,
603603
if ($repositoryObject->isTemplate) {
604604
return false;
605605
}
606-
if ($repositoryObject->getAccessType()=="ajxp_conf" && $userObject != null) {
606+
if (($repositoryObject->getAccessType()=="ajxp_conf" || $repositoryObject->getAccessType()=="ajxp_admin") && $userObject != null) {
607607
if (AuthService::usersEnabled() && !$userObject->isAdmin()) {
608608
return false;
609609
}
@@ -1612,7 +1612,7 @@ private function loadRepositoryDriverInst(&$repository = null)
16121612
}
16131613

16141614
/**
1615-
* Search the manifests declaring ajxpdriver as their root node. Remove ajxp_conf & ajxp_shared
1615+
* Search the manifests declaring ajxpdriver as their root node. Remove ajxp_* drivers
16161616
* @static
16171617
* @param string $filterByTagName
16181618
* @param string $filterByDriverName
@@ -1626,7 +1626,7 @@ public static function availableDriversToXML($filterByTagName = "", $filterByDri
16261626
foreach ($nodeList as $node) {
16271627
$dName = $node->getAttribute("name");
16281628
if($filterByDriverName != "" && $dName != $filterByDriverName) continue;
1629-
if($dName == "ajxp_conf" || $dName == "ajxp_shared") continue;
1629+
if(strpos($dName, "ajxp_") === 0) continue;
16301630
if ($filterByTagName == "") {
16311631
$xmlBuffer .= $node->ownerDocument->saveXML($node);
16321632
continue;

core/src/core/classes/class.Repository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,7 @@ public function securityScope()
640640
if(strpos($path, "AJXP_GROUP_PATH_FLAT") !== false) return "GROUP";
641641
}
642642
$path = $this->getOption("PATH", true);
643-
if($this->accessType == "ajxp_conf") return "USER";
643+
if($this->accessType == "ajxp_conf" || $this->accessType == "ajxp_admin") return "USER";
644644
if(empty($path)) return false;
645645
if(strpos($path, "AJXP_USER") !== false) return "USER";
646646
if(strpos($path, "AJXP_GROUP_PATH") !== false) return "GROUP";

0 commit comments

Comments
 (0)