aboutsummaryrefslogtreecommitdiffstats
path: root/settings/controller
diff options
context:
space:
mode:
authorLukas Reschke <lukas@owncloud.com>2015-01-30 12:00:57 +0100
committerLukas Reschke <lukas@owncloud.com>2015-01-30 14:29:46 +0100
commit734dcc82dd48bc06a2152a45f9d62546e122b822 (patch)
tree7f4321699466caffb2c5f92f1d1a4e15847bee6c /settings/controller
parente7900ba255df677fbea718e73e52931f8950c811 (diff)
downloadnextcloud-server-734dcc82dd48bc06a2152a45f9d62546e122b822.tar.gz
nextcloud-server-734dcc82dd48bc06a2152a45f9d62546e122b822.zip
Fix subadmin listing of group
Without this patch filtering for the "_everyone" (empty) group did not work for subadmins. Fixes itself.
Diffstat (limited to 'settings/controller')
-rw-r--r--settings/controller/userscontroller.php27
1 files changed, 21 insertions, 6 deletions
diff --git a/settings/controller/userscontroller.php b/settings/controller/userscontroller.php
index be1b26f86ad..fd88692d777 100644
--- a/settings/controller/userscontroller.php
+++ b/settings/controller/userscontroller.php
@@ -161,7 +161,7 @@ class UsersController extends Controller {
private function getUsersForUID(array $userIDs) {
$users = [];
foreach ($userIDs as $uid => $displayName) {
- $users[] = $this->userManager->get($uid);
+ $users[$uid] = $this->userManager->get($uid);
}
return $users;
}
@@ -196,7 +196,7 @@ class UsersController extends Controller {
}
}
- $users = array();
+ $users = [];
if ($this->isAdmin) {
if($gid !== '') {
@@ -210,16 +210,31 @@ class UsersController extends Controller {
}
} else {
+ /** @var array $subAdminOf List of groups the user is subadmin */
+ $subAdminOf = \OC_SubAdmin::getSubAdminsGroups($this->userSession->getUser()->getUID());
+
// Set the $gid parameter to an empty value if the subadmin has no rights to access a specific group
- if($gid !== '' && !in_array($gid, \OC_SubAdmin::getSubAdminsGroups($this->userSession->getUser()->getUID()))) {
+ if($gid !== '' && !in_array($gid, $subAdminOf)) {
$gid = '';
}
- $batch = $this->getUsersForUID($this->groupManager->displayNamesInGroup($gid, $pattern, $limit, $offset));
+ // Batch all groups the user is subadmin of when a group is specified
+ $batch = [];
+ if($gid === '') {
+ foreach($subAdminOf as $group) {
+ $groupUsers = $this->groupManager->displayNamesInGroup($group, $pattern, $limit, $offset);
+ foreach($groupUsers as $uid => $displayName) {
+ $batch[$uid] = $displayName;
+ }
+ }
+ } else {
+ $batch = $this->groupManager->displayNamesInGroup($gid, $pattern, $limit, $offset);
+ }
+ $batch = $this->getUsersForUID($batch);
+
foreach ($batch as $user) {
// Only add the groups, this user is a subadmin of
- $userGroups = array_intersect($this->groupManager->getUserGroupIds($user),
- \OC_SubAdmin::getSubAdminsGroups($this->userSession->getUser()->getUID()));
+ $userGroups = array_intersect($this->groupManager->getUserGroupIds($user), $subAdminOf);
$users[] = $this->formatUserForIndex($user, $userGroups);
}
}