/** * @param String $repoId * @param $mixUsersAndGroups * @param $currentFileUrl * @return array */ public function computeSharedRepositoryAccessRights($repoId, $mixUsersAndGroups, $currentFileUrl = null) { $roles = AuthService::getRolesForRepository($repoId); $sharedEntries = $sharedGroups = $sharedRoles = array(); $mess = ConfService::getMessages(); foreach ($roles as $rId) { $role = AuthService::getRole($rId); if ($role == null) { continue; } $RIGHT = $role->getAcl($repoId); if (empty($RIGHT)) { continue; } $ID = $rId; $WATCH = false; if (strpos($rId, "AJXP_USR_/") === 0) { $userId = substr($rId, strlen('AJXP_USR_/')); $role = AuthService::getRole($rId); $userObject = ConfService::getConfStorageImpl()->createUserObject($userId); $LABEL = $role->filterParameterValue("core.conf", "USER_DISPLAY_NAME", AJXP_REPO_SCOPE_ALL, ""); if (empty($LABEL)) { $LABEL = $userId; } $TYPE = $userObject->hasParent() ? "tmp_user" : "user"; if ($this->watcher !== false && $currentFileUrl != null) { $WATCH = $this->watcher->hasWatchOnNode(new AJXP_Node($currentFileUrl), $userId, MetaWatchRegister::$META_WATCH_USERS_NAMESPACE); } $ID = $userId; } else { if (strpos($rId, "AJXP_GRP_/") === 0) { if (empty($loadedGroups)) { $displayAll = ConfService::getCoreConf("CROSSUSERS_ALLGROUPS_DISPLAY", "conf"); if ($displayAll) { AuthService::setGroupFiltering(false); } $loadedGroups = AuthService::listChildrenGroups(); if ($displayAll) { AuthService::setGroupFiltering(true); } else { $baseGroup = AuthService::filterBaseGroup("/"); foreach ($loadedGroups as $loadedG => $loadedLabel) { unset($loadedGroups[$loadedG]); $loadedGroups[rtrim($baseGroup, "/") . "/" . ltrim($loadedG, "/")] = $loadedLabel; } } } $groupId = substr($rId, strlen('AJXP_GRP_')); if (isset($loadedGroups[$groupId])) { $LABEL = $loadedGroups[$groupId]; } if ($groupId == "/") { $LABEL = $mess["447"]; } if (empty($LABEL)) { $LABEL = $groupId; } $TYPE = "group"; } else { if ($rId == "ROOT_ROLE") { $rId = "AJXP_GRP_/"; $TYPE = "group"; $LABEL = $mess["447"]; } else { $role = AuthService::getRole($rId); $LABEL = $role->getLabel(); $TYPE = 'group'; } } } if (empty($LABEL)) { $LABEL = $rId; } $entry = array("ID" => $ID, "TYPE" => $TYPE, "LABEL" => $LABEL, "RIGHT" => $RIGHT); if ($WATCH) { $entry["WATCH"] = $WATCH; } if ($TYPE == "group") { $sharedGroups[$entry["ID"]] = $entry; } else { $sharedEntries[$entry["ID"]] = $entry; } } if (!$mixUsersAndGroups) { return array("USERS" => $sharedEntries, "GROUPS" => $sharedGroups); } else { return array_merge(array_values($sharedGroups), array_values($sharedEntries)); } /* $users = AuthService::getUsersForRepository($repoId); //var_dump($roles); $baseGroup = "/"; $groups = AuthService::listChildrenGroups($baseGroup); $mess = ConfService::getMessages(); $groups[$baseGroup] = $mess["447"]; $sharedEntries = array(); if (!$mixUsersAndGroups) { $sharedGroups = array(); } foreach ($groups as $gId => $gLabel) { $r = AuthService::getRole("AJXP_GRP_".AuthService::filterBaseGroup($gId)); if ($r != null) { $right = $r->getAcl($repoId); if (!empty($right)) { $entry = array( "ID" => "AJXP_GRP_".AuthService::filterBaseGroup($gId), "TYPE" => "group", "LABEL" => $gLabel, "RIGHT" => $right); if (!$mixUsersAndGroups) { $sharedGroups[$gId] = $entry; } else { $sharedEntries[] = $entry; } } } } foreach ($roles as $rId){ if(strpos($rId, "AJXP_GRP_") === 0 || strpos($rId, "AJXP_USR_") === 0) continue; $role = AuthService::getRole($rId); if ($role != null) { $right = $role->getAcl($repoId); if (!empty($right)) { $label = $role->getLabel(); if(empty($label)) $label = $rId; $entry = array( "ID" => $rId, "TYPE" => "group", "LABEL" => $label, "RIGHT" => $right); if (!$mixUsersAndGroups) { $sharedGroups[$rId] = $entry; } else { $sharedEntries[] = $entry; } } } } foreach ($users as $userId => $userObject) { if($userObject->getId() == $loggedUser->getId() && !$loggedUser->isAdmin()) { continue; } $ri = $userObject->personalRole->getAcl($repoId); $uLabel = $userObject->personalRole->filterParameterValue("core.conf", "USER_DISPLAY_NAME", AJXP_REPO_SCOPE_ALL, ""); if(empty($uLabel)) $uLabel = $userId; if (!empty($ri)) { $entry = array( "ID" => $userId, "TYPE" => $userObject->hasParent()?"tmp_user":"******", "LABEL" => $uLabel, "RIGHT" => $userObject->personalRole->getAcl($repoId) ); if ($this->watcher !== false && $currentFileUrl != null) { $entry["WATCH"] = $this->watcher->hasWatchOnNode( new AJXP_Node($currentFileUrl), $userId, MetaWatchRegister::$META_WATCH_USERS_NAMESPACE ); } if (!$mixUsersAndGroups) { $sharedEntries[$userId] = $entry; } else { $sharedEntries[] = $entry; } } } if (!$mixUsersAndGroups) { return array("USERS" => $sharedEntries, "GROUPS" => $sharedGroups); } return $sharedEntries; */ }
/** * @param String $repoId * @param bool $mixUsersAndGroups * @param AJXP_Node|null $watcherNode * @return array */ public function computeSharedRepositoryAccessRights($repoId, $mixUsersAndGroups, $watcherNode = null) { $roles = AuthService::getRolesForRepository($repoId); $sharedEntries = $sharedGroups = array(); $mess = ConfService::getMessages(); foreach ($roles as $rId) { $role = AuthService::getRole($rId); if ($role == null) { continue; } $RIGHT = $role->getAcl($repoId); if (empty($RIGHT)) { continue; } $ID = $rId; $WATCH = false; $HIDDEN = false; $AVATAR = false; if (strpos($rId, "AJXP_USR_/") === 0) { $userId = substr($rId, strlen('AJXP_USR_/')); $role = AuthService::getRole($rId); $userObject = ConfService::getConfStorageImpl()->createUserObject($userId); $LABEL = $role->filterParameterValue("core.conf", "USER_DISPLAY_NAME", AJXP_REPO_SCOPE_ALL, ""); $AVATAR = $role->filterParameterValue("core.conf", "avatar", AJXP_REPO_SCOPE_ALL, ""); if (empty($LABEL)) { $LABEL = $userId; } $TYPE = $userObject->hasParent() ? "tmp_user" : "user"; $HIDDEN = $userObject->isHidden(); if ($this->watcher !== false && $watcherNode != null) { $WATCH = $this->watcher->hasWatchOnNode($watcherNode, $userId, MetaWatchRegister::$META_WATCH_USERS_NAMESPACE); } $ID = $userId; } else { if ($rId == "AJXP_GRP_" . AuthService::filterBaseGroup("/")) { $TYPE = "group"; $LABEL = $mess["447"]; } else { if (strpos($rId, "AJXP_GRP_/") === 0) { if (empty($loadedGroups)) { $displayAll = ConfService::getCoreConf("CROSSUSERS_ALLGROUPS_DISPLAY", "conf"); if ($displayAll) { AuthService::setGroupFiltering(false); } $loadedGroups = AuthService::listChildrenGroups(); if ($displayAll) { AuthService::setGroupFiltering(true); } else { $baseGroup = AuthService::filterBaseGroup("/"); foreach ($loadedGroups as $loadedG => $loadedLabel) { unset($loadedGroups[$loadedG]); $loadedGroups[rtrim($baseGroup, "/") . "/" . ltrim($loadedG, "/")] = $loadedLabel; } } } $groupId = substr($rId, strlen('AJXP_GRP_')); if (isset($loadedGroups[$groupId])) { $LABEL = $loadedGroups[$groupId]; } /* if($groupId == AuthService::filterBaseGroup("/")){ $LABEL = $mess["447"]; } */ if (empty($LABEL)) { $LABEL = $groupId; } $TYPE = "group"; } else { $role = AuthService::getRole($rId); $LABEL = $role->getLabel(); $TYPE = 'group'; } } } if (empty($LABEL)) { $LABEL = $rId; } $entry = array("ID" => $ID, "TYPE" => $TYPE, "LABEL" => $LABEL, "RIGHT" => $RIGHT); if ($WATCH) { $entry["WATCH"] = $WATCH; } if ($HIDDEN) { $entry["HIDDEN"] = true; } if ($AVATAR !== false) { $entry["AVATAR"] = $AVATAR; } if ($TYPE == "group") { $sharedGroups[$entry["ID"]] = $entry; } else { $sharedEntries[$entry["ID"]] = $entry; } } if (!$mixUsersAndGroups) { return array("USERS" => $sharedEntries, "GROUPS" => $sharedGroups); } else { return array_merge(array_values($sharedGroups), array_values($sharedEntries)); } }