Skip to content

Commit

Permalink
Merge branch 'MDL-36872-m23' of git://github.com/ankitagarwal/moodle …
Browse files Browse the repository at this point in the history
…into MOODLE_23_STABLE
  • Loading branch information
stronk7 committed Mar 19, 2013
2 parents b100f94 + 77df5b7 commit 28896f1
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions course/recent.php
Expand Up @@ -280,21 +280,37 @@

function compare_activities_by_time_desc($a, $b) {
// make sure the activities actually have a timestamp property
if ((!array_key_exists('timestamp', $a)) or (!array_key_exists('timestamp', $b))) {
return 0;
if ((!array_key_exists('timestamp', $a)) && (!array_key_exists('timestamp', $b))) {
return 0;
}
// We treat instances without timestamp as if they have a timestamp of 0.
if ((!array_key_exists('timestamp', $a)) && (array_key_exists('timestamp', $b))) {
return 1;
}
if ((array_key_exists('timestamp', $a)) && (!array_key_exists('timestamp', $b))) {
return -1;
}
if ($a->timestamp == $b->timestamp)
if ($a->timestamp == $b->timestamp) {
return 0;
}
return ($a->timestamp > $b->timestamp) ? -1 : 1;
}

function compare_activities_by_time_asc($a, $b) {
// make sure the activities actually have a timestamp property
if ((!array_key_exists('timestamp', $a)) or (!array_key_exists('timestamp', $b))) {
if ((!array_key_exists('timestamp', $a)) && (!array_key_exists('timestamp', $b))) {
return 0;
}
if ($a->timestamp == $b->timestamp)
// We treat instances without timestamp as if they have a timestamp of 0.
if ((!array_key_exists('timestamp', $a)) && (array_key_exists('timestamp', $b))) {
return -1;
}
if ((array_key_exists('timestamp', $a)) && (!array_key_exists('timestamp', $b))) {
return 1;
}
if ($a->timestamp == $b->timestamp) {
return 0;
}
return ($a->timestamp < $b->timestamp) ? -1 : 1;
}

0 comments on commit 28896f1

Please sign in to comment.