From: poltawski Date: Tue, 5 Feb 2008 17:19:41 +0000 (+0000) Subject: MDL-13314 count_role_users was showing different count to those returned from X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=f405c6e4d8985e3438be9c7dbec6d6f2fa015718;p=moodle.git MDL-13314 count_role_users was showing different count to those returned from get_role_users(), based on patch from Patrick Pollett merged from MOODLE_19_STABLE --- diff --git a/lib/accesslib.php b/lib/accesslib.php index 7a66344899..e550f46c1b 100755 --- a/lib/accesslib.php +++ b/lib/accesslib.php @@ -4927,10 +4927,13 @@ function count_role_users($roleid, $context, $parent=false) { $parentcontexts = ''; } - $SQL = "SELECT count(*) - FROM {$CFG->prefix}role_assignments r - WHERE (r.contextid = $context->id $parentcontexts) - AND r.roleid = $roleid"; + $SQL = "SELECT count(u.id) + FROM {$CFG->prefix}role_assignments r + JOIN {$CFG->prefix}user u + ON u.id = r.userid + WHERE (r.contextid = $context->id $parentcontexts) + AND r.roleid = $roleid + AND u.deleted = 0"; return count_records_sql($SQL); }