Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2015-10-29 18:40:39 +0300
committerVincent Petry <pvince81@owncloud.com>2015-10-29 19:41:49 +0300
commit781bca2437628d2f932abd60c5dcec0ece4504e3 (patch)
tree9729ae043ff4061570e95f127db82a4197b5ee62 /settings/controller
parent73d9699be9d2a343b0573dc6a5bcc65f5f9c7303 (diff)
Fix everyone count for subadmins
Also moved the logic to the UsersController
Diffstat (limited to 'settings/controller')
-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
+ ]
+ );
+ }
+
}