mirror of
https://github.com/moodle/moodle.git
synced 2025-08-06 09:26:35 +02:00
Merge branch 'MDL-61441_35' of https://github.com/timhunt/moodle into MOODLE_35_STABLE
This commit is contained in:
commit
07579a6bba
1 changed files with 8 additions and 6 deletions
|
@ -3496,19 +3496,21 @@ function get_users_by_capability(context $context, $capability, $fields = '', $s
|
|||
if ($groups) {
|
||||
$groups = (array)$groups;
|
||||
list($grouptest, $grpparams) = $DB->get_in_or_equal($groups, SQL_PARAMS_NAMED, 'grp');
|
||||
$grouptest = "u.id IN (SELECT userid FROM {groups_members} gm WHERE gm.groupid $grouptest)";
|
||||
$joins[] = "LEFT OUTER JOIN (SELECT DISTINCT userid
|
||||
FROM {groups_members}
|
||||
WHERE groupid $grouptest
|
||||
) gm ON gm.userid = u.id";
|
||||
|
||||
$params = array_merge($params, $grpparams);
|
||||
|
||||
$grouptest = 'gm.userid IS NOT NULL';
|
||||
if ($useviewallgroups) {
|
||||
$viewallgroupsusers = get_users_by_capability($context, 'moodle/site:accessallgroups', 'u.id, u.id', '', '', '', '', $exceptions);
|
||||
if (!empty($viewallgroupsusers)) {
|
||||
$wherecond[] = "($grouptest OR u.id IN (" . implode(',', array_keys($viewallgroupsusers)) . '))';
|
||||
} else {
|
||||
$wherecond[] = "($grouptest)";
|
||||
$grouptest .= ' OR u.id IN (' . implode(',', array_keys($viewallgroupsusers)) . ')';
|
||||
}
|
||||
} else {
|
||||
$wherecond[] = "($grouptest)";
|
||||
}
|
||||
$wherecond[] = "($grouptest)";
|
||||
}
|
||||
|
||||
// User exceptions
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue