From 572fc207c1cd00ffa812aa0e9225e2892fbf5a4e Mon Sep 17 00:00:00 2001 From: Richard Lawley Date: Wed, 9 Mar 2016 12:18:22 +0000 Subject: [PATCH] Import Notifications with Original Date/Time --- includes/notifications.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/includes/notifications.php b/includes/notifications.php index 313dcabd5..7d842cd9d 100644 --- a/includes/notifications.php +++ b/includes/notifications.php @@ -46,6 +46,7 @@ function get_notifications() { $obj = array_reverse(array_merge($obj,$feed)); echo '('.sizeof($obj).')'.PHP_EOL; } + $obj = array_sort($obj, 'datetime'); return $obj; } @@ -76,7 +77,12 @@ function parse_rss($feed) { $feed['channel']['item'] = array( $feed['channel']['item'] ); } foreach ($feed['channel']['item'] as $item) { - $obj[] = array('title'=>$item['title'],'body'=>$item['description'],'checksum'=>hash('sha512',$item['title'].$item['description'])); + $obj[] = array( + 'title'=>$item['title'], + 'body'=>$item['description'], + 'checksum'=>hash('sha512',$item['title'].$item['description']), + 'datetime'=>strftime('%F', strtotime($item['pubDate'])) + ); } return $obj; } @@ -92,7 +98,12 @@ function parse_atom($feed) { $feed['entry'] = array( $feed['entry'] ); } foreach ($feed['entry'] as $item) { - $obj[] = array('title'=>$item['title'],'body'=>$item['content'],'checksum'=>hash('sha512',$item['title'].$item['content'])); + $obj[] = array( + 'title'=>$item['title'], + 'body'=>$item['content'], + 'checksum'=>hash('sha512',$item['title'].$item['content']), + 'datetime'=>strftime('%F', strtotime($item['updated'])) + ); } return $obj; }