Skip to content

Commit

Permalink
Merge branch 'MDL-65705-master' of git://github.com/sarjona/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
abgreeve committed May 28, 2019
2 parents 4f8e821 + 39f4caf commit c970eef
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions badges/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -420,12 +420,14 @@ protected function render_issued_badge(\core_badges\output\issued_badge $ibadge)

$output .= $this->output->heading(get_string('issuancedetails', 'badges'), 3);
$dl = array();
$issued['issuedOn'] = !preg_match( '~^[1-9][0-9]*$~', $issued['issuedOn'] ) ?
strtotime($issued['issuedOn']) : $issued['issuedOn'];
if (!is_numeric($issued['issuedOn'])) {
$issued['issuedOn'] = strtotime($issued['issuedOn']);
}
$dl[get_string('dateawarded', 'badges')] = userdate($issued['issuedOn']);
if (isset($issued['expires'])) {
$issued['expires'] = !preg_match( '~^[1-9][0-9]*$~', $issued['expires'] ) ?
strtotime($issued['expires']) : $issued['expires'];
if (!is_numeric($issued['expires'])) {
$issued['expires'] = strtotime($issued['expires']);
}
if ($issued['expires'] < $now) {
$dl[get_string('expirydate', 'badges')] = userdate($issued['expires']) . get_string('warnexpired', 'badges');

Expand Down Expand Up @@ -508,7 +510,7 @@ protected function render_external_badge(\core_badges\output\external_badge $iba
}
$output .= html_writer::empty_tag('img', array('src' => $issued->image, 'width' => '100'));
if (isset($assertion->expires)) {
$expiration = !strtotime($assertion->expires) ? s($assertion->expires) : strtotime($assertion->expires);
$expiration = is_numeric($assertion->expires) ? $assertion->expires : strtotime($assertion->expires);
if ($expiration < $today) {
$output .= $this->output->pix_icon('i/expired',
get_string('expireddate', 'badges', userdate($expiration)),
Expand Down Expand Up @@ -564,7 +566,7 @@ protected function render_external_badge(\core_badges\output\external_badge $iba

$dl = array();
if (isset($assertion->issued_on)) {
$issuedate = !strtotime($assertion->issued_on) ? s($assertion->issued_on) : strtotime($assertion->issued_on);
$issuedate = is_numeric($assertion->issued_on) ? $assertion->issued_on : strtotime($assertion->issued_on);
$dl[get_string('dateawarded', 'badges')] = userdate($issuedate);
}
if (isset($assertion->expires)) {
Expand Down

0 comments on commit c970eef

Please sign in to comment.