Skip to content
Snippets Groups Projects
Unverified Commit 8a1cbbd9 authored by Robin Appelman's avatar Robin Appelman
Browse files

Don't pretend we can add/remove users to/from groups when we can't


Signed-off-by: default avatarRobin Appelman <robin@icewind.nl>
parent c3aea9cd
No related branches found
No related tags found
No related merge requests found
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
namespace OC\Group; namespace OC\Group;
use OCP\GroupInterface;
use OCP\IGroup; use OCP\IGroup;
use OCP\IUser; use OCP\IUser;
use OCP\Group\Backend\ICountDisabledInGroup; use OCP\Group\Backend\ICountDisabledInGroup;
...@@ -323,4 +324,30 @@ class Group implements IGroup { ...@@ -323,4 +324,30 @@ class Group implements IGroup {
} }
return $users; 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;
}
} }
...@@ -165,7 +165,9 @@ class MetaData { ...@@ -165,7 +165,9 @@ class MetaData {
'id' => $group->getGID(), 'id' => $group->getGID(),
'name' => $group->getDisplayName(), 'name' => $group->getDisplayName(),
'usercount' => $this->sorting === self::SORT_USERCOUNT ? $group->count($userSearch) : 0, 'usercount' => $this->sorting === self::SORT_USERCOUNT ? $group->count($userSearch) : 0,
'disabled' => $group->countDisabled() 'disabled' => $group->countDisabled(),
'canAdd' => $group->canAddUser(),
'canRemove' => $group->canRemoveUser(),
); );
} }
......
...@@ -126,4 +126,16 @@ interface IGroup { ...@@ -126,4 +126,16 @@ interface IGroup {
* @since 8.0.0 * @since 8.0.0
*/ */
public function delete(); public function delete();
/**
* @return bool
* @since 14.0.0
*/
public function canRemoveUser();
/**
* @return bool
* @since 14.0.0
*/
public function canAddUser();
} }
Source diff could not be displayed: it is too large. Options to address this: view the blob.
This diff is collapsed.
...@@ -374,6 +374,9 @@ export default { ...@@ -374,6 +374,9 @@ export default {
* @returns {Promise} * @returns {Promise}
*/ */
addUserGroup(group) { addUserGroup(group) {
if (!group.canAdd) {
return false;
}
this.loading.groups = true; this.loading.groups = true;
let userid = this.user.id; let userid = this.user.id;
let gid = group.id; let gid = group.id;
...@@ -388,6 +391,9 @@ export default { ...@@ -388,6 +391,9 @@ export default {
* @returns {Promise} * @returns {Promise}
*/ */
removeUserGroup(group) { removeUserGroup(group) {
if (!group.canRemove) {
return false;
}
this.loading.groups = true; this.loading.groups = true;
let userid = this.user.id; let userid = this.user.id;
let gid = group.id; let gid = group.id;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment