Merge branch 'MDL-42875_master' of https://github.com/crazyserver/moodle

This commit is contained in:
Sam Hemelryk
2014-10-31 10:27:46 +13:00
+9 -4
View File
@@ -438,14 +438,19 @@ $params['contextlevel'] = CONTEXT_USER;
$select .= $ccselect;
$joins[] = $ccjoin;
// We want to query both the current context and parent contexts.
list($relatedctxsql, $relatedctxparams) = $DB->get_in_or_equal($context->get_parent_context_ids(true), SQL_PARAMS_NAMED, 'relatedctx');
$params = array_merge($params, $relatedctxparams);
// Limit list to users with some role only.
if ($roleid) {
// We want to query both the current context and parent contexts.
list($relatedctxsql, $relatedctxparams) = $DB->get_in_or_equal($context->get_parent_context_ids(true), SQL_PARAMS_NAMED, 'relatedctx');
$wheres[] = "u.id IN (SELECT userid FROM {role_assignments} WHERE roleid = :roleid AND contextid $relatedctxsql)";
$params = array_merge($params, array('roleid' => $roleid), $relatedctxparams);
$params = array_merge($params, array('roleid' => $roleid));
} else {
$profileroles = explode(',', $CFG->profileroles);
list($insql, $inparams) = $DB->get_in_or_equal($profileroles, SQL_PARAMS_NAMED);
$wheres[] = "u.id IN (SELECT userid FROM {role_assignments} WHERE roleid $insql AND contextid $relatedctxsql)";
$params = array_merge($params, $inparams);
}
$from = implode("\n", $joins);