From 29bc479355f84f613b5044ab285821c4821add29 Mon Sep 17 00:00:00 2001 From: Skylar Ittner Date: Tue, 24 Jul 2018 00:53:10 -0600 Subject: [PATCH] Sort results of Notifications::get() by seen status and timestamp --- lib/Notifications.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Notifications.lib.php b/lib/Notifications.lib.php index 5c39a83..7823915 100644 --- a/lib/Notifications.lib.php +++ b/lib/Notifications.lib.php @@ -48,7 +48,7 @@ class Notifications { public static function get(User $user) { global $database, $Strings; if ($user->exists()) { - $notifications = $database->select('notifications', ['notificationid (id)', 'timestamp', 'title', 'content', 'url', 'seen', 'sensitive'], ['uid' => $user->getUID()]); + $notifications = $database->select('notifications', ['notificationid (id)', 'timestamp', 'title', 'content', 'url', 'seen', 'sensitive'], ['uid' => $user->getUID(), 'ORDER' => ['seen', 'timestamp' => 'DESC']]); for ($i = 0; $i < count($notifications); $i++) { $notifications[$i]['id'] = $notifications[$i]['id'] * 1; $notifications[$i]['seen'] = ($notifications[$i]['seen'] == "1" ? true : false);