From ae912070eaa07cb8042dfa047715ee4c60b5122a Mon Sep 17 00:00:00 2001 From: Tim Hunt Date: Mon, 4 Jul 2011 18:50:21 +0100 Subject: [PATCH] MDL-27040 get_users_by_capability generates u.id IN () when no uesrs have accessallgroups --- lib/accesslib.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/accesslib.php b/lib/accesslib.php index e4f31b9bf03..98d21aa8627 100644 --- a/lib/accesslib.php +++ b/lib/accesslib.php @@ -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)"; }