diff options
author | Vincent Petry <pvince81@owncloud.com> | 2015-10-29 16:40:39 +0100 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2015-10-29 17:41:49 +0100 |
commit | 781bca2437628d2f932abd60c5dcec0ece4504e3 (patch) | |
tree | 9729ae043ff4061570e95f127db82a4197b5ee62 /settings/controller | |
parent | 73d9699be9d2a343b0573dc6a5bcc65f5f9c7303 (diff) | |
download | nextcloud-server-781bca2437628d2f932abd60c5dcec0ece4504e3.tar.gz nextcloud-server-781bca2437628d2f932abd60c5dcec0ece4504e3.zip |
Fix everyone count for subadmins
Also moved the logic to the UsersController
Diffstat (limited to 'settings/controller')
-rw-r--r-- | settings/controller/userscontroller.php | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/settings/controller/userscontroller.php b/settings/controller/userscontroller.php index 8183bc4739b..fed9e268a7c 100644 --- a/settings/controller/userscontroller.php +++ b/settings/controller/userscontroller.php @@ -548,4 +548,40 @@ class UsersController extends Controller { ); } + /** + * Count all unique users visible for the current admin/subadmin. + * + * @NoAdminRequired + * + * @return DataResponse + */ + public function stats() { + $userCount = 0; + if ($this->isAdmin) { + $countByBackend = $this->userManager->countUsers(); + + if (!empty($countByBackend)) { + foreach ($countByBackend as $count) { + $userCount += $count; + } + } + } else { + $groups = $this->groupManager->getSubAdmin()->getSubAdminsGroups($this->userSession->getUser()); + + foreach ($groups as $group) { + foreach($group->getUsers() as $uid => $displayName) { + $uniqueUsers[$uid] = true; + } + } + + $userCount = count($uniqueUsers); + } + + return new DataResponse( + [ + 'totalUsers' => $userCount + ] + ); + } + } |