Browse files

Prevent get_users_by_capability() to retrn deleted users. MDL-16323

  • Loading branch information...
1 parent 26c2ccb commit 28d6c12579b4b5738b7572b6765ba6121c1bf9ae stronk7 committed Sep 11, 2008
Showing with 5 additions and 8 deletions.
  1. +5 −8 lib/accesslib.php
View
13 lib/accesslib.php
@@ -4346,6 +4346,10 @@ function get_users_by_capability($context, $capability, $fields='', $sort='',
// Prepare query clauses
//
$wherecond = array();
+
+ // Non-deleted users. We never return deleted users.
+ $wherecond['nondeleted'] = 'u.deleted = 0';
+
/// Groups
if ($groups) {
if (is_array($groups)) {
@@ -4424,6 +4428,7 @@ function get_users_by_capability($context, $capability, $fields='', $sort='',
return get_records_sql("SELECT $fields
FROM {$CFG->prefix}user u
+ WHERE u.deleted = 0
ORDER BY $sort",
$limitfrom, $limitnum);
}
@@ -4455,10 +4460,6 @@ function get_users_by_capability($context, $capability, $fields='', $sort='',
$sscondhiddenra
) ra ON ra.userid = u.id
$uljoin ";
- $where = " WHERE u.deleted = 0 ";
- if (count(array_keys($wherecond))) {
- $where .= ' AND ' . implode(' AND ', array_values($wherecond));
- }
return get_records_sql($select.$from.$where.$sortby, $limitfrom, $limitnum);
}
@@ -4537,10 +4538,6 @@ function get_users_by_capability($context, $capability, $fields='', $sort='',
JOIN {$CFG->prefix}user u
ON ra.userid=u.id
$uljoin ";
- $where = "WHERE u.deleted = 0 ";
- if (count(array_keys($wherecond))) {
- $where .= ' AND ' . implode(' AND ', array_values($wherecond));
- }
// Each user's entries MUST come clustered together
// and RAs ordered in depth DESC - the role/cap resolution

0 comments on commit 28d6c12

Please sign in to comment.