MDL-43621 badges: Don't display deleted users in badge recipients list

This commit is contained in:
Yuliya Bozhko 2014-01-10 09:00:01 +13:00
parent 12efa52762
commit 7f964cfdc7
3 changed files with 8 additions and 4 deletions

View File

@ -91,7 +91,7 @@ $namefields = get_all_user_name_fields(true, 'u');
$sql = "SELECT b.userid, b.dateissued, b.uniquehash, $namefields
FROM {badge_issued} b INNER JOIN {user} u
ON b.userid = u.id
WHERE b.badgeid = :badgeid
WHERE b.badgeid = :badgeid AND u.deleted = 0
ORDER BY $sortby $sorthow";
$totalcount = $DB->count_records('badge_issued', array('badgeid' => $badge->id));

View File

@ -663,7 +663,9 @@ class core_badges_renderer extends plugin_renderer_base {
}
if (has_capability('moodle/badges:viewawarded', $context)) {
$awarded = $DB->count_records('badge_issued', array('badgeid' => $badgeid));
$awarded = $DB->count_records_sql('SELECT COUNT(b.userid)
FROM {badge_issued} b INNER JOIN {user} u ON b.userid = u.id
WHERE b.badgeid = :badgeid AND u.deleted = 0', array('badgeid' => $badgeid));
$row[] = new tabobject('awards',
new moodle_url('/badges/recipients.php', array('id' => $badgeid)),
get_string('bawards', 'badges', $awarded)

View File

@ -349,7 +349,7 @@ class badge {
'SELECT b.userid, b.dateissued, b.uniquehash, u.firstname, u.lastname
FROM {badge_issued} b INNER JOIN {user} u
ON b.userid = u.id
WHERE b.badgeid = :badgeid', array('badgeid' => $this->id));
WHERE b.badgeid = :badgeid AND u.deleted = 0', array('badgeid' => $this->id));
return $awards;
}
@ -815,7 +815,9 @@ function badges_get_badges($type, $courseid = 0, $sort = '', $dir = '', $page =
$badges[$r->id]->dateissued = $r->dateissued;
$badges[$r->id]->uniquehash = $r->uniquehash;
} else {
$badges[$r->id]->awards = $DB->count_records('badge_issued', array('badgeid' => $badge->id));
$badges[$r->id]->awards = $DB->count_records_sql('SELECT COUNT(b.userid)
FROM {badge_issued} b INNER JOIN {user} u ON b.userid = u.id
WHERE b.badgeid = :badgeid AND u.deleted = 0', array('badgeid' => $badge->id));
$badges[$r->id]->statstring = $badge->get_status_name();
}
}