diff options
author | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2018-05-24 11:29:48 +0200 |
---|---|---|
committer | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2018-05-24 17:52:15 +0200 |
commit | c55cf79453a91bbe58759c3188060c9e620e8f62 (patch) | |
tree | 8f498754e0173a96698c5a175e3c0804f87e00ab /lib | |
parent | ddd1c8bc8689017559f6d6af36898fb7ddb28adb (diff) | |
download | nextcloud-server-c55cf79453a91bbe58759c3188060c9e620e8f62.tar.gz nextcloud-server-c55cf79453a91bbe58759c3188060c9e620e8f62.zip |
Added total count for subadmins
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/Group/MetaData.php | 2 | ||||
-rw-r--r-- | lib/private/User/Manager.php | 19 |
2 files changed, 20 insertions, 1 deletions
diff --git a/lib/private/Group/MetaData.php b/lib/private/Group/MetaData.php index 1e89472bc30..497dcf72b59 100644 --- a/lib/private/Group/MetaData.php +++ b/lib/private/Group/MetaData.php @@ -188,7 +188,7 @@ class MetaData { * @param string $search a search string * @return \OCP\IGroup[] */ - protected function getGroups($search = '') { + public function getGroups($search = '') { if($this->isAdmin) { return $this->groupManager->search($search); } else { diff --git a/lib/private/User/Manager.php b/lib/private/User/Manager.php index 17712321933..6784359538d 100644 --- a/lib/private/User/Manager.php +++ b/lib/private/User/Manager.php @@ -34,6 +34,7 @@ namespace OC\User; use OC\Hooks\PublicEmitter; use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\IUser; +use OCP\IGroup; use OCP\IUserBackend; use OCP\IUserManager; use OCP\IConfig; @@ -385,6 +386,24 @@ class Manager extends PublicEmitter implements IUserManager { } /** + * returns how many users per backend exist in the requested groups (if supported by backend) + * + * @param IGroup[] $groups an array of gid to search in + * @return array|int an array of backend class as key and count number as value + * if $hasLoggedIn is true only an int is returned + */ + public function countUsersOfGroups(array $groups) { + $users = []; + foreach($groups as $group) { + $usersIds = array_map(function($user) { + return $user->getUID(); + }, $group->getUsers()); + $users = array_merge($users, $usersIds); + } + return count(array_unique($users)); + } + + /** * The callback is executed for each user on each backend. * If the callback returns false no further users will be retrieved. * |