Skip to content

Commit

Permalink
MDL-43621 badges: Don't display deleted users in badge recipients list
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuliya Bozhko committed Jan 14, 2014
1 parent 12efa52 commit 7f964cf
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion badges/recipients.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
$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));
Expand Down
4 changes: 3 additions & 1 deletion badges/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,9 @@ public function print_badge_tabs($badgeid, $context, $current = 'overview') {
}

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)
Expand Down
6 changes: 4 additions & 2 deletions lib/badgeslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ public function get_awards() {
'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;
}
Expand Down Expand Up @@ -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();
}
}
Expand Down

0 comments on commit 7f964cf

Please sign in to comment.