Add function to get next and previous unread item

This commit is contained in:
Frederic Guillot 2013-03-26 21:56:20 -04:00
parent 151c35b9df
commit 7b155c6ce2

View File

@ -157,6 +157,31 @@ function get_item($id)
} }
function get_nav_item($item)
{
$next_item = \PicoTools\singleton('db')
->table('items')
->columns('items.id')
->eq('status', 'unread')
->lt('updated', $item['updated'])
->desc('updated')
->findOne();
$previous_item = \PicoTools\singleton('db')
->table('items')
->columns('items.id')
->eq('status', 'unread')
->gt('updated', $item['updated'])
->asc('updated')
->findOne();
return array(
'next' => $next_item,
'previous' => $previous_item
);
}
function set_item_read($id) function set_item_read($id)
{ {
\PicoTools\singleton('db') \PicoTools\singleton('db')