refs #13 resist to missing timeaccess in recent items

Signed-off-by: Julien Veyssier <eneiluj@posteo.net>
This commit is contained in:
Julien Veyssier 2020-12-30 10:26:37 +01:00
parent d98e5a7f60
commit eddf1fb5da
No known key found for this signature in database
GPG key ID: 4141FEE162030638

View file

@ -58,8 +58,8 @@ class MoodleAPIService {
// sort recent items by date DESC
$a = usort($recentItems, function($a, $b) {
$ta = $a['timeaccess'];
$tb = $b['timeaccess'];
$ta = $a['timeaccess'] ?? 0;
$tb = $b['timeaccess'] ?? 0;
return ($ta > $tb) ? -1 : 1;
});
@ -91,13 +91,13 @@ class MoodleAPIService {
}
// sort upcoming events by date ASC
$a = usort($upcomingEvents, function($a, $b) {
$ta = $a['timestart'];
$tb = $b['timestart'];
$ta = $a['timestart'] ?? 0;
$tb = $b['timestart'] ?? 0;
return ($ta < $tb) ? -1 : 1;
});
foreach ($upcomingEvents as $k => $upcomingEvent) {
$upcomingEvents[$k]['time'] = $upcomingEvent['timestart'];
$upcomingEvents[$k]['time'] = $upcomingEvent['timestart'] ?? 0;
$upcomingEvents[$k]['type'] = 'event';
}