summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2012-08-13 20:53:45 +0400
committerAndrew Dolgov <[email protected]>2012-08-13 20:53:45 +0400
commit6d8d00e8c0293dbc7c643df21fe56e7d2a601157 (patch)
tree84d4fc72da6ba8a9c98f83f9f4daf868d22377ad /include
parent2c5f231e439dac3fc68422fbb1c8ec57e9d8b35d (diff)
allow queryFeedHeadlines() to show child category entries
Diffstat (limited to 'include')
-rw-r--r--include/functions.php29
1 files changed, 28 insertions, 1 deletions
diff --git a/include/functions.php b/include/functions.php
index b2319e6e1..0e2424c58 100644
--- a/include/functions.php
+++ b/include/functions.php
@@ -2273,6 +2273,19 @@
return $search_query_part;
}
+ function getChildCategories($link, $cat, $owner_uid) {
+ $rv = array();
+
+ $result = db_query($link, "SELECT id FROM ttrss_feed_categories
+ WHERE parent_cat = '$cat' AND owner_uid = $owner_uid");
+
+ while ($line = db_fetch_assoc($result)) {
+ array_push($rv, $line["id"]);
+ $rv = array_merge($rv, getChildCategories($link, $line["id"], $owner_uid));
+ }
+
+ return $rv;
+ }
function queryFeedHeadlines($link, $feed, $limit, $view_mode, $cat_view, $search, $search_mode, $match_on, $override_order = false, $offset = 0, $owner_uid = 0, $filter = false, $since_id = 0) {
@@ -2318,6 +2331,10 @@
$view_query_part = " ";
} else if ($feed != -1) {
$unread = getFeedUnread($link, $feed, $cat_view);
+
+ if ($cat_view && $feed > 0)
+ $unread = getCategoryUnreadRecursive($link, $feed);
+
if ($unread > 0) {
$view_query_part = " unread = true AND ";
}
@@ -2389,7 +2406,17 @@
if ($cat_view) {
if ($feed > 0) {
- $query_strategy_part = "cat_id = '$feed'";
+ # sub-cats
+ $subcats = getChildCategories($link, $feed, $owner_uid);
+
+ if (count($subcats) == 0) {
+ $query_strategy_part = "cat_id = '$feed'";
+ } else {
+ array_push($subcats, $feed);
+ $query_strategy_part = "cat_id IN (".
+ implode(",", $subcats).")";
+ }
+
} else {
$query_strategy_part = "cat_id IS NULL";
}