From 33ed15457c6ec3248e29d0db532d43f5d7c9dfd7 Mon Sep 17 00:00:00 2001 From: "pau.ferrer-ocana" Date: Wed, 29 Oct 2014 10:32:57 +0100 Subject: [PATCH] MDL-42875 users: Show only profile visible roles on participants list --- user/index.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/user/index.php b/user/index.php index 3efbb159fed..4400b5aca89 100644 --- a/user/index.php +++ b/user/index.php @@ -418,14 +418,19 @@ $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 + // 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); -- 2.43.0