MDL-22531 fix for broken sql in get_users_by_capability() in cases where role_assignmetns is not in the resulting query such as when only default role is interesting for us - thanks Ye Chen for the report and solution

This commit is contained in:
Petr Skoda
2010-05-20 18:35:05 +00:00
parent a4a0264df6
commit e720dbd79a
+2 -2
View File
@@ -4497,13 +4497,13 @@ function get_users_by_capability($context, $capability, $fields='', $sort='',
} else {
$grouptest = 'gm.groupid = ' . $groups;
}
$grouptest = 'ra.userid IN (SELECT userid FROM ' .
$grouptest = 'u.id IN (SELECT userid FROM ' .
$CFG->prefix . 'groups_members gm WHERE ' . $grouptest . ')';
if ($useviewallgroups) {
$viewallgroupsusers = get_users_by_capability($context,
'moodle/site:accessallgroups', 'u.id, u.id', '', '', '', '', $exceptions);
$wherecond['groups'] = '('. $grouptest . ' OR ra.userid IN (' .
$wherecond['groups'] = '('. $grouptest . ' OR u.id IN (' .
implode(',', array_keys($viewallgroupsusers)) . '))';
} else {
$wherecond['groups'] = '(' . $grouptest .')';