From e720dbd79adcf22695d4657bed1295c69598df99 Mon Sep 17 00:00:00 2001 From: Petr Skoda Date: Thu, 20 May 2010 18:35:05 +0000 Subject: [PATCH] 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 --- lib/accesslib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/accesslib.php b/lib/accesslib.php index 682926ecbab..22947427e2f 100755 --- a/lib/accesslib.php +++ b/lib/accesslib.php @@ -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 .')';