Skip to content

Commit

Permalink
MDL-43621 badges: Fix has_awards() result when deleted users are the …
Browse files Browse the repository at this point in the history
…only recipients of a badge
  • Loading branch information
Yuliya Bozhko committed Jan 15, 2014
1 parent 7f964cf commit e477ec0
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/badgeslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -331,10 +331,11 @@ public function is_locked() {
*/
public function has_awards() {
global $DB;
if ($DB->record_exists('badge_issued', array('badgeid' => $this->id))) {
return true;
}
return false;
$awarded = $DB->record_exists_sql('SELECT b.uniquehash
FROM {badge_issued} b INNER JOIN {user} u ON b.userid = u.id
WHERE b.badgeid = :badgeid AND u.deleted = 0', array('badgeid' => $this->id));

return $awarded;
}

/**
Expand Down

0 comments on commit e477ec0

Please sign in to comment.