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:
parent
c3aea9cdf6
commit
8a1cbbd90e
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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(),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue