From 1ca244426749a97dd737d0c2ee3c82baad2eb723 Mon Sep 17 00:00:00 2001 From: Mathias Kresin Date: Thu, 19 Nov 2015 16:31:31 +0100 Subject: [PATCH] take care of groups during navigating between items --- controllers/item.php | 4 +++- models/item.php | 4 +++- templates/item.php | 2 +- templates/show_item.php | 4 ++-- templates/unread_items.php | 1 + 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/controllers/item.php b/controllers/item.php index 5912bbe..b805148 100644 --- a/controllers/item.php +++ b/controllers/item.php @@ -58,13 +58,14 @@ Router\get_action('show', function() { $menu = Request\param('menu'); $item = Model\Item\get($id); $feed = Model\Feed\get($item['feed_id']); + $group_id = Request\int_param('group_id', null); Model\Item\set_read($id); $item['status'] = 'read'; switch ($menu) { case 'unread': - $nav = Model\Item\get_nav($item); + $nav = Model\Item\get_nav($item, array('unread'), array(1, 0), null, $group_id); break; case 'history': $nav = Model\Item\get_nav($item, array('read')); @@ -93,6 +94,7 @@ Router\get_action('show', function() { 'item_nav' => isset($nav) ? $nav : null, 'menu' => $menu, 'title' => $item['title'], + 'group_id' => $group_id, ))); }); diff --git a/models/item.php b/models/item.php index 5eabdb5..1baabc7 100644 --- a/models/item.php +++ b/models/item.php @@ -218,7 +218,7 @@ function get($id) } // Get item naviguation (next/prev items) -function get_nav($item, $status = array('unread'), $bookmark = array(1, 0), $feed_id = null) +function get_nav($item, $status = array('unread'), $bookmark = array(1, 0), $feed_id = null, $group_id = null) { $query = Database::getInstance('db') ->table('items') @@ -228,6 +228,8 @@ function get_nav($item, $status = array('unread'), $bookmark = array(1, 0), $fee if ($feed_id) $query->eq('feed_id', $feed_id); + if ($group_id) $query->in('feed_id', Group\get_feeds_by_group($group_id)); + $items = $query->findAll(); $next_item = null; diff --git a/templates/item.php b/templates/item.php index c079e49..b68e878 100644 --- a/templates/item.php +++ b/templates/item.php @@ -11,7 +11,7 @@ diff --git a/templates/show_item.php b/templates/show_item.php index 23869d5..02afbff 100644 --- a/templates/show_item.php +++ b/templates/show_item.php @@ -13,7 +13,7 @@