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

Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
Robin Appelman 2018-06-19 16:23:02 +02:00
parent c3aea9cdf6
commit 8a1cbbd90e
No known key found for this signature in database
GPG Key ID: 42B69D8A64526EFB
6 changed files with 51 additions and 4 deletions

View File

@ -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;
}
}

View File

@ -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(),
);
}

View File

@ -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();
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -374,6 +374,9 @@ export default {
* @returns {Promise}
*/
addUserGroup(group) {
if (!group.canAdd) {
return false;
}
this.loading.groups = true;
let userid = this.user.id;
let gid = group.id;
@ -388,6 +391,9 @@ export default {
* @returns {Promise}
*/
removeUserGroup(group) {
if (!group.canRemove) {
return false;
}
this.loading.groups = true;
let userid = this.user.id;
let gid = group.id;