Permalink
Browse files

MDL-27040 get_users_by_capability generates u.id IN () when no uesrs …

…have accessallgroups
  • Loading branch information...
1 parent 020f0ff commit ae912070eaa07cb8042dfa047715ee4c60b5122a @timhunt timhunt committed Jul 4, 2011
Showing with 5 additions and 1 deletion.
  1. +5 −1 lib/accesslib.php
View
@@ -5007,7 +5007,11 @@ function get_users_by_capability($context, $capability, $fields = '', $sort = ''
if ($useviewallgroups) {
$viewallgroupsusers = get_users_by_capability($context, 'moodle/site:accessallgroups', 'u.id, u.id', '', '', '', '', $exceptions);
- $wherecond[] = "($grouptest OR u.id IN (" . implode(',', array_keys($viewallgroupsusers)) . '))';
+ if (!empty($viewallgroupsusers)) {
+ $wherecond[] = "($grouptest OR u.id IN (" . implode(',', array_keys($viewallgroupsusers)) . '))';
+ } else {
+ $wherecond[] = "($grouptest)";
+ }
} else {
$wherecond[] = "($grouptest)";
}

0 comments on commit ae91207

Please sign in to comment.