diff --git a/files/lib/system/dashboard/box/UnksoLatestPostsDashboardBox.class.php b/files/lib/system/dashboard/box/UnksoLatestPostsDashboardBox.class.php index fe0ca6b..228a793 100644 --- a/files/lib/system/dashboard/box/UnksoLatestPostsDashboardBox.class.php +++ b/files/lib/system/dashboard/box/UnksoLatestPostsDashboardBox.class.php @@ -8,10 +8,29 @@ protected function render() { if (!count($this->latestPostsList)) return ''; + $sortedPostsList = array(); + + $today = new DateTime("now"); + $yesterday = new DateTime(); + $yesterday->sub(new DateInterval("P1D")); + + for ($i=0; $ilatestPostsList); $i++) { + $thisPost = $this->latestPostsList[$i]; + + if ($thisPost["date"] > $yesterday) + $sortedPostsList["today"][] = $thisPost; + + else if ($thisPost["date"] == $yesterday) + $sortedPostsList["yesterday"][] = $thisPost; + + else + $sortedPostsList["earlier"][] = $thisPost; + } + WCF::getTPL()->assign(array( - 'latestPostsList' => $this->latestPostsList + 'latestPostsList' => $sortedPostsList )); return WCF::getTPL()->fetch('unksoDashboardBoxLatestPosts', 'wbb'); } -} \ No newline at end of file +} diff --git a/templates/unksoDashboardBoxLatestPosts.tpl b/templates/unksoDashboardBoxLatestPosts.tpl index 455d87c..8586f69 100644 --- a/templates/unksoDashboardBoxLatestPosts.tpl +++ b/templates/unksoDashboardBoxLatestPosts.tpl @@ -1,7 +1,17 @@ {hascontent} -{/hascontent} \ No newline at end of file + + +{/hascontent}