summaryrefslogtreecommitdiffstats
path: root/settings/controller/userscontroller.php
diff options
context:
space:
mode:
Diffstat (limited to 'settings/controller/userscontroller.php')
-rw-r--r--settings/controller/userscontroller.php36
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
+ ]
+ );
+ }
+
}