Permalink
Browse files

MDL-22531 fix for broken sql in get_users_by_capability() in cases wh…

…ere 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
  • Loading branch information...
1 parent a4a0264 commit e720dbd79adcf22695d4657bed1295c69598df99 @skodak skodak committed May 20, 2010
Showing with 2 additions and 2 deletions.
  1. +2 −2 lib/accesslib.php
View
@@ -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 .')';

0 comments on commit e720dbd

Please sign in to comment.