summaryrefslogtreecommitdiff
path: root/classes
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 /classes
parent0f556e3edbffa8d0c307e57bd7436fc2e3c3c945 (diff)
API: support nested categories
Diffstat (limited to 'classes')
-rw-r--r--classes/api.php18
1 files changed, 15 insertions, 3 deletions
diff --git a/classes/api.php b/classes/api.php
index cce1d2a78..801f99566 100644
--- a/classes/api.php
+++ b/classes/api.php
@@ -114,20 +114,27 @@ class API extends Handler {
$unread_only = (bool)db_escape_string($_REQUEST["unread_only"]);
$limit = (int) db_escape_string($_REQUEST["limit"]);
$offset = (int) db_escape_string($_REQUEST["offset"]);
+ $include_nested = (bool)db_escape_string($_REQUEST["include_nested"]);
- $feeds = api_get_feeds($this->link, $cat_id, $unread_only, $limit, $offset);
+ $feeds = api_get_feeds($this->link, $cat_id, $unread_only, $limit, $offset, $include_nested);
print $this->wrap(self::STATUS_OK, $feeds);
}
function getCategories() {
$unread_only = (bool)db_escape_string($_REQUEST["unread_only"]);
+ $enable_nested = (bool)db_escape_string($_REQUEST["enable_nested"]);
// TODO do not return empty categories, return Uncategorized and standard virtual cats
+ if ($enable_nested)
+ $nested_qpart = "parent_cat IS NULL";
+ else
+ $nested_qpart = "true";
+
$result = db_query($this->link, "SELECT
id, title, order_id FROM ttrss_feed_categories
- WHERE owner_uid = " .
+ WHERE $nested_qpart AND owner_uid = " .
$_SESSION["uid"]);
$cats = array();
@@ -135,6 +142,9 @@ class API extends Handler {
while ($line = db_fetch_assoc($result)) {
$unread = getFeedUnread($this->link, $line["id"], true);
+ if ($enable_nested)
+ $unread += getCategoryChildrenUnread($this->link, $line["id"]);
+
if ($unread || !$unread_only) {
array_push($cats, array("id" => $line["id"],
"title" => $line["title"],
@@ -174,6 +184,7 @@ class API extends Handler {
$view_mode = db_escape_string($_REQUEST["view_mode"]);
$include_attachments = (bool)db_escape_string($_REQUEST["include_attachments"]);
$since_id = (int)db_escape_string($_REQUEST["since_id"]);
+ $include_nested = (bool)db_escape_string($_REQUEST["include_nested"]);
/* do not rely on params below */
@@ -183,7 +194,8 @@ class API extends Handler {
$headlines = api_get_headlines($this->link, $feed_id, $limit, $offset,
$filter, $is_cat, $show_excerpt, $show_content, $view_mode, false,
- $include_attachments, $since_id, $search, $search_mode, $match_on);
+ $include_attachments, $since_id, $search, $search_mode, $match_on,
+ $include_nested);
print $this->wrap(self::STATUS_OK, $headlines);
} else {