mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +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
|
@ -4083,15 +4083,19 @@ function get_user_roles($context, $userid=0, $checkparentcontexts=true, $order='
|
|||
$contexts = ' ra.contextid = \''.$context->id.'\'';
|
||||
}
|
||||
|
||||
return get_records_sql('SELECT ra.*, r.name, r.shortname
|
||||
FROM '.$CFG->prefix.'role_assignments ra,
|
||||
'.$CFG->prefix.'role r,
|
||||
'.$CFG->prefix.'context c
|
||||
WHERE ra.userid = '.$userid.
|
||||
' AND ra.roleid = r.id
|
||||
AND ra.contextid = c.id
|
||||
AND '.$contexts . $hiddensql .
|
||||
' ORDER BY '.$order);
|
||||
if (!$return = get_records_sql('SELECT ra.*, r.name, r.shortname
|
||||
FROM '.$CFG->prefix.'role_assignments ra,
|
||||
'.$CFG->prefix.'role r,
|
||||
'.$CFG->prefix.'context c
|
||||
WHERE ra.userid = '.$userid.'
|
||||
AND ra.roleid = r.id
|
||||
AND ra.contextid = c.id
|
||||
AND '.$contexts . $hiddensql .'
|
||||
ORDER BY '.$order)) {
|
||||
$return = array();
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue