mirror of
https://github.com/moodle/moodle.git
synced 2025-08-06 01:16:44 +02:00
MDL-40468 libraries: removed usages of get_related_contexts_string() in core
Also tidied up the functions by removing unused parameters.
This commit is contained in:
parent
b645284403
commit
4e829d48d1
10 changed files with 96 additions and 104 deletions
|
@ -370,9 +370,6 @@
|
|||
));
|
||||
$table->setup();
|
||||
|
||||
// we are looking for all users with this role assigned in this context or higher
|
||||
$contextlist = get_related_contexts_string($context);
|
||||
|
||||
list($esql, $params) = get_enrolled_sql($context, NULL, $currentgroup, true);
|
||||
$joins = array("FROM {user} u");
|
||||
$wheres = array();
|
||||
|
@ -410,8 +407,11 @@
|
|||
|
||||
// limit list to users with some role only
|
||||
if ($roleid) {
|
||||
$wheres[] = "u.id IN (SELECT userid FROM {role_assignments} WHERE roleid = :roleid AND contextid $contextlist)";
|
||||
$params['roleid'] = $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);
|
||||
}
|
||||
|
||||
$from = implode("\n", $joins);
|
||||
|
|
|
@ -781,6 +781,9 @@ class group_non_members_selector extends groups_user_selector_base {
|
|||
$roleparams = array();
|
||||
}
|
||||
|
||||
// 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');
|
||||
|
||||
// Get the search condition.
|
||||
list($searchcondition, $searchparams) = $this->search_sql($search, 'u');
|
||||
|
||||
|
@ -794,7 +797,7 @@ class group_non_members_selector extends groups_user_selector_base {
|
|||
WHERE igm.userid = u.id AND ig.courseid = :courseid) AS numgroups";
|
||||
$sql = " FROM {user} u
|
||||
JOIN ($enrolsql) e ON e.id = u.id
|
||||
LEFT JOIN {role_assignments} ra ON (ra.userid = u.id AND ra.contextid " . get_related_contexts_string($context) . " AND ra.roleid $roleids)
|
||||
LEFT JOIN {role_assignments} ra ON (ra.userid = u.id AND ra.contextid $relatedctxsql AND ra.roleid $roleids)
|
||||
LEFT JOIN {role} r ON r.id = ra.roleid
|
||||
LEFT JOIN {groups_members} gm ON (gm.userid = u.id AND gm.groupid = :groupid)
|
||||
WHERE u.deleted = 0
|
||||
|
@ -804,7 +807,7 @@ class group_non_members_selector extends groups_user_selector_base {
|
|||
list($sort, $sortparams) = users_order_by_sql('u', $search, $this->accesscontext);
|
||||
$orderby = ' ORDER BY ' . $sort;
|
||||
|
||||
$params = array_merge($searchparams, $roleparams, $enrolparams);
|
||||
$params = array_merge($searchparams, $roleparams, $enrolparams, $relatedctxparams);
|
||||
$params['courseid'] = $this->courseid;
|
||||
$params['groupid'] = $this->groupid;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue