diff options
author | blizzz <blizzz@arthur-schiwon.de> | 2019-10-21 11:53:44 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-21 11:53:44 +0200 |
commit | 75ecae28e6dae37e6e80ce493f28b162dfa7c4d1 (patch) | |
tree | 82e9137c38979776a138febbd008f79d3bb4914f /apps/settings/lib | |
parent | 7dcf9479556ea5f8df715f0e270b43d55f044fe5 (diff) | |
parent | 419bcb3a091378214dea551c15883760e8192fe4 (diff) | |
download | nextcloud-server-75ecae28e6dae37e6e80ce493f28b162dfa7c4d1.tar.gz nextcloud-server-75ecae28e6dae37e6e80ce493f28b162dfa7c4d1.zip |
Merge pull request #17450 from nextcloud/fix/17368/odd-group-numbers
hide strange Everyone and Disabled group numbers with LDAP
Diffstat (limited to 'apps/settings/lib')
-rw-r--r-- | apps/settings/lib/Controller/UsersController.php | 57 |
1 files changed, 32 insertions, 25 deletions
diff --git a/apps/settings/lib/Controller/UsersController.php b/apps/settings/lib/Controller/UsersController.php index aaa4736087e..cb99d1bd74b 100644 --- a/apps/settings/lib/Controller/UsersController.php +++ b/apps/settings/lib/Controller/UsersController.php @@ -184,31 +184,38 @@ class UsersController extends Controller { }); } - if ($this->isAdmin) { - $disabledUsers = $isLDAPUsed ? -1 : $this->userManager->countDisabledUsers(); - $userCount = $isLDAPUsed ? 0 : array_reduce($this->userManager->countUsers(), function($v, $w) { - return $v + (int)$w; - }, 0); - } else { - // User is subadmin ! - // Map group list to names to retrieve the countDisabledUsersOfGroups - $userGroups = $this->groupManager->getUserGroups($user); - $groupsNames = []; - $userCount = 0; - - foreach($groups as $key => $group) { - // $userCount += (int)$group['usercount']; - array_push($groupsNames, $group['name']); - // we prevent subadmins from looking up themselves - // so we lower the count of the groups he belongs to - if (array_key_exists($group['id'], $userGroups)) { - $groups[$key]['usercount']--; - $userCount = -1; // we also lower from one the total count - } - }; - $userCount += $isLDAPUsed ? 0 : $this->userManager->countUsersOfGroups($groupsInfo->getGroups()); - $disabledUsers = $isLDAPUsed ? -1 : $this->userManager->countDisabledUsersOfGroups($groupsNames); + $disabledUsers = -1; + $userCount = 0; + + if(!$isLDAPUsed) { + if ($this->isAdmin) { + $disabledUsers = $this->userManager->countDisabledUsers(); + $userCount = array_reduce($this->userManager->countUsers(), function($v, $w) { + return $v + (int)$w; + }, 0); + } else { + // User is subadmin ! + // Map group list to names to retrieve the countDisabledUsersOfGroups + $userGroups = $this->groupManager->getUserGroups($user); + $groupsNames = []; + + foreach($groups as $key => $group) { + // $userCount += (int)$group['usercount']; + array_push($groupsNames, $group['name']); + // we prevent subadmins from looking up themselves + // so we lower the count of the groups he belongs to + if (array_key_exists($group['id'], $userGroups)) { + $groups[$key]['usercount']--; + $userCount -= 1; // we also lower from one the total count + } + }; + $userCount += $this->userManager->countUsersOfGroups($groupsInfo->getGroups()); + $disabledUsers = $this->userManager->countDisabledUsersOfGroups($groupsNames); + } + + $userCount -= $disabledUsers; } + $disabledUsersGroup = [ 'id' => 'disabled', 'name' => 'Disabled users', @@ -237,7 +244,7 @@ class UsersController extends Controller { $serverData['isAdmin'] = $this->isAdmin; $serverData['sortGroups'] = $sortGroupsBy; $serverData['quotaPreset'] = $quotaPreset; - $serverData['userCount'] = $userCount - $disabledUsers; + $serverData['userCount'] = $userCount; $serverData['languages'] = $languages; $serverData['defaultLanguage'] = $this->config->getSystemValue('default_language', 'en'); // Settings |