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

@ -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;
}
/**