mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
MDL-12938, MDL-12937 - unenrol fixes - can not unenrol if can not unassign all users roles in course, do not show self unenrol if enrolment comes from parent context, fixed rturn value from get_user_roles; based on patch by Eric Merrill; merged from MOODLE_19_STABLE
This commit is contained in:
parent
a18fbcfb50
commit
76b570d602
4 changed files with 49 additions and 22 deletions
|
@ -37,6 +37,16 @@
|
|||
|
||||
if ($userid) { // Unenrolling someone else
|
||||
require_capability('moodle/role:assign', $context, NULL, false);
|
||||
|
||||
$roles = get_user_roles($context, $userid, false);
|
||||
|
||||
// verify user may unassign all roles at course context
|
||||
foreach($roles as $role) {
|
||||
if (!user_can_assign($context, $role->roleid)) {
|
||||
error('Can not unassign this user from role id:'.$role->roleid);
|
||||
}
|
||||
}
|
||||
|
||||
} else { // Unenrol yourself
|
||||
require_capability('moodle/role:unassignself', $context, NULL, false);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue