diff options
author | Robin Appelman <robin@icewind.nl> | 2018-06-19 17:23:02 +0300 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2018-06-19 17:23:02 +0300 |
commit | 8a1cbbd90e73b44f1884b4a65fe4c55d40d377e9 (patch) | |
tree | cf3cd4279835e6cb8cf8aa30bb6f2d522bbf1415 /lib | |
parent | c3aea9cdf6d88895b1a1fc54ead9a2f0aa792cd3 (diff) |
Don't pretend we can add/remove users to/from groups when we can't
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/Group/Group.php | 27 | ||||
-rw-r--r-- | lib/private/Group/MetaData.php | 4 | ||||
-rw-r--r-- | lib/public/IGroup.php | 12 |
3 files changed, 42 insertions, 1 deletions
diff --git a/lib/private/Group/Group.php b/lib/private/Group/Group.php index 275b697bc3b..0d54cf8e35a 100644 --- a/lib/private/Group/Group.php +++ b/lib/private/Group/Group.php @@ -30,6 +30,7 @@ namespace OC\Group; +use OCP\GroupInterface; use OCP\IGroup; use OCP\IUser; use OCP\Group\Backend\ICountDisabledInGroup; @@ -323,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; + } } diff --git a/lib/private/Group/MetaData.php b/lib/private/Group/MetaData.php index 497dcf72b59..f4877237ec7 100644 --- a/lib/private/Group/MetaData.php +++ b/lib/private/Group/MetaData.php @@ -165,7 +165,9 @@ class MetaData { 'id' => $group->getGID(), 'name' => $group->getDisplayName(), 'usercount' => $this->sorting === self::SORT_USERCOUNT ? $group->count($userSearch) : 0, - 'disabled' => $group->countDisabled() + 'disabled' => $group->countDisabled(), + 'canAdd' => $group->canAddUser(), + 'canRemove' => $group->canRemoveUser(), ); } diff --git a/lib/public/IGroup.php b/lib/public/IGroup.php index 22fa28f94be..8fa87e35ce3 100644 --- a/lib/public/IGroup.php +++ b/lib/public/IGroup.php @@ -126,4 +126,16 @@ interface IGroup { * @since 8.0.0 */ public function delete(); + + /** + * @return bool + * @since 14.0.0 + */ + public function canRemoveUser(); + + /** + * @return bool + * @since 14.0.0 + */ + public function canAddUser(); } |