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:
skodak 2008-02-05 12:59:28 +00:00
parent a18fbcfb50
commit 76b570d602
4 changed files with 49 additions and 22 deletions

View file

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