summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2012-09-18 09:58:01 +0400
committerAndrew Dolgov <[email protected]>2012-09-18 10:03:26 +0400
commit4864633612ab8619e0f2664474b4dce8e74ac81f (patch)
tree624055f34f3e26a2fe4a71f31e87df4f0ccdfde2 /include
parent0f556e3edbffa8d0c307e57bd7436fc2e3c3c945 (diff)
API: support nested categories
Diffstat (limited to 'include')
-rw-r--r--include/functions.php30
1 files changed, 27 insertions, 3 deletions
diff --git a/include/functions.php b/include/functions.php
index 5af4cb667..2b0b3a40c 100644
--- a/include/functions.php
+++ b/include/functions.php
@@ -4454,7 +4454,7 @@
return $rv;
}
- function api_get_feeds($link, $cat_id, $unread_only, $limit, $offset) {
+ function api_get_feeds($link, $cat_id, $unread_only, $limit, $offset, $include_nested = false) {
$feeds = array();
@@ -4502,6 +4502,30 @@
}
}
+ /* Child cats */
+
+ if ($include_nested && $cat_id) {
+ $result = db_query($link, "SELECT
+ id, title FROM ttrss_feed_categories
+ WHERE parent_cat = '$cat_id' AND owner_uid = " . $_SESSION["uid"] .
+ "ORDER BY id, title");
+
+ while ($line = db_fetch_assoc($result)) {
+ $unread = getFeedUnread($link, $line["id"], true) +
+ getCategoryChildrenUnread($link, $line["id"]);
+
+ if ($unread || !$unread_only) {
+ $row = array(
+ "id" => $line["id"],
+ "title" => $line["title"],
+ "unread" => $unread,
+ "is_cat" => true,
+ );
+ array_push($feeds, $row);
+ }
+ }
+ }
+
/* Real feeds */
if ($limit) {
@@ -4560,11 +4584,11 @@
function api_get_headlines($link, $feed_id, $limit, $offset,
$filter, $is_cat, $show_excerpt, $show_content, $view_mode, $order,
$include_attachments, $since_id,
- $search = "", $search_mode = "", $match_on = "") {
+ $search = "", $search_mode = "", $match_on = "", $include_nested = false) {
$qfh_ret = queryFeedHeadlines($link, $feed_id, $limit,
$view_mode, $is_cat, $search, $search_mode, $match_on,
- $order, $offset, 0, false, $since_id);
+ $order, $offset, 0, false, $since_id, $include_nested);
$result = $qfh_ret[0];
$feed_title = $qfh_ret[1];