mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 00:12:56 +02:00
when unassign users in course, if user has no more course:view capability left, he should be removed from all groups in course
This commit is contained in:
parent
bf4bb28d4f
commit
3527464679
@ -2290,9 +2290,9 @@ function role_unassign($roleid=0, $userid=0, $groupid=0, $contextid=0, $enrol=NU
|
||||
|
||||
/// now handle metacourse role unassigment and removing from goups if in course context
|
||||
if (!empty($context) and $context->contextlevel == CONTEXT_COURSE) {
|
||||
//remove from groups when user has no role
|
||||
$roles = get_user_roles($context, $ra->userid, true);
|
||||
if (empty($roles)) {
|
||||
// remove from groups when user has no capability to view course
|
||||
// this may be slow, but this is the proper way of doing it
|
||||
if (!has_capability('moodle/course:view', $context, $ra->userid)) {
|
||||
if ($groups = get_groups($context->instanceid, $ra->userid)) {
|
||||
foreach ($groups as $group) {
|
||||
delete_records('groups_members', 'groupid', $group->id, 'userid', $ra->userid);
|
||||
|
Loading…
x
Reference in New Issue
Block a user