Fix subadmin listing of group
Without this patch filtering for the "_everyone" (empty) group did not work for subadmins. Fixes itself.
This commit is contained in:
parent
e7900ba255
commit
734dcc82dd
|
@ -161,7 +161,7 @@ class UsersController extends Controller {
|
||||||
private function getUsersForUID(array $userIDs) {
|
private function getUsersForUID(array $userIDs) {
|
||||||
$users = [];
|
$users = [];
|
||||||
foreach ($userIDs as $uid => $displayName) {
|
foreach ($userIDs as $uid => $displayName) {
|
||||||
$users[] = $this->userManager->get($uid);
|
$users[$uid] = $this->userManager->get($uid);
|
||||||
}
|
}
|
||||||
return $users;
|
return $users;
|
||||||
}
|
}
|
||||||
|
@ -196,7 +196,7 @@ class UsersController extends Controller {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$users = array();
|
$users = [];
|
||||||
if ($this->isAdmin) {
|
if ($this->isAdmin) {
|
||||||
|
|
||||||
if($gid !== '') {
|
if($gid !== '') {
|
||||||
|
@ -210,16 +210,31 @@ class UsersController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} 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
|
// 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 = '';
|
$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) {
|
foreach ($batch as $user) {
|
||||||
// Only add the groups, this user is a subadmin of
|
// Only add the groups, this user is a subadmin of
|
||||||
$userGroups = array_intersect($this->groupManager->getUserGroupIds($user),
|
$userGroups = array_intersect($this->groupManager->getUserGroupIds($user), $subAdminOf);
|
||||||
\OC_SubAdmin::getSubAdminsGroups($this->userSession->getUser()->getUID()));
|
|
||||||
$users[] = $this->formatUserForIndex($user, $userGroups);
|
$users[] = $this->formatUserForIndex($user, $userGroups);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue