diff options
Diffstat (limited to 'lib/private/Group/Group.php')
-rw-r--r-- | lib/private/Group/Group.php | 53 |
1 files changed, 51 insertions, 2 deletions
diff --git a/lib/private/Group/Group.php b/lib/private/Group/Group.php index 6795f0e2f53..0d54cf8e35a 100644 --- a/lib/private/Group/Group.php +++ b/lib/private/Group/Group.php @@ -10,6 +10,7 @@ * @author Robin McCorkell <robin@mccorkell.me.uk> * @author Roeland Jago Douma <roeland@famdouma.nl> * @author Vincent Petry <pvince81@owncloud.com> + * @author John Molakvoæ <skjnldsv@protonmail.com> * * @license AGPL-3.0 * @@ -29,8 +30,10 @@ namespace OC\Group; +use OCP\GroupInterface; use OCP\IGroup; use OCP\IUser; +use OCP\Group\Backend\ICountDisabledInGroup; class Group implements IGroup { /** @var null|string */ @@ -209,10 +212,10 @@ class Group implements IGroup { $userIds = $backend->usersInGroup($this->gid, $search, $limit, $offset); $users += $this->getVerifiedUsers($userIds); if (!is_null($limit) and $limit <= 0) { - return array_values($users); + return $users; } } - return array_values($users); + return $users; } /** @@ -237,6 +240,26 @@ class Group implements IGroup { } /** + * returns the number of disabled users + * + * @return int|bool + */ + public function countDisabled() { + $users = false; + foreach ($this->backends as $backend) { + if($backend instanceOf ICountDisabledInGroup) { + if($users === false) { + //we could directly add to a bool variable, but this would + //be ugly + $users = 0; + } + $users += $backend->countDisabledInGroup($this->gid); + } + } + return $users; + } + + /** * search for users in the group by displayname * * @param string $search @@ -301,4 +324,30 @@ class Group implements IGroup { } return $users; } + + /** + * @return bool + * @since 14.0.0 + */ + public function canRemoveUser() { + foreach ($this->backends as $backend) { + if ($backend->implementsActions(GroupInterface::REMOVE_FROM_GOUP)) { + return true; + } + } + return false; + } + + /** + * @return bool + * @since 14.0.0 + */ + public function canAddUser() { + foreach ($this->backends as $backend) { + if ($backend->implementsActions(GroupInterface::ADD_TO_GROUP)) { + return true; + } + } + return false; + } } |