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;
|
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 {
|
||||||
}
|
}
|
||||||
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 {
|
||||||
'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 {
|
||||||
* @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();
|
||||||
}
|
}
|
||||||
|
|
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}
|
* @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 {
|
||||||
* @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;
|
||||||
|
|
Loading…
Reference in New Issue