summaryrefslogtreecommitdiff
path: root/classes
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2013-02-10 11:40:03 +0400
committerAndrew Dolgov <[email protected]>2013-02-10 11:40:03 +0400
commitd49dfa381e3b74e09839d9d858f410fa6ec707d2 (patch)
treebe0e6d73eaaa7e96ee85979e2420b4965ffbdc6d /classes
parentb44587922c963aeec9077543ea997e2f549e9a81 (diff)
api: block real categories with 0 feeds to appear in getCategories
Diffstat (limited to 'classes')
-rw-r--r--classes/api.php25
1 files changed, 15 insertions, 10 deletions
diff --git a/classes/api.php b/classes/api.php
index a4294e026..4b24b0110 100644
--- a/classes/api.php
+++ b/classes/api.php
@@ -131,24 +131,29 @@ class API extends Handler {
$nested_qpart = "true";
$result = db_query($this->link, "SELECT
- id, title, order_id FROM ttrss_feed_categories
+ id, title, order_id, (SELECT COUNT(id) FROM
+ ttrss_feeds WHERE
+ ttrss_feed_categories.id IS NOT NULL AND cat_id = ttrss_feed_categories.id) AS num_feeds
+ FROM ttrss_feed_categories
WHERE $nested_qpart AND owner_uid = " .
$_SESSION["uid"]);
$cats = array();
while ($line = db_fetch_assoc($result)) {
- $unread = getFeedUnread($this->link, $line["id"], true);
+ if ($line["num_feeds"] > 0) {
+ $unread = getFeedUnread($this->link, $line["id"], true);
- if ($enable_nested)
- $unread += getCategoryChildrenUnread($this->link, $line["id"]);
+ if ($enable_nested)
+ $unread += getCategoryChildrenUnread($this->link, $line["id"]);
- if ($unread || !$unread_only) {
- array_push($cats, array("id" => $line["id"],
- "title" => $line["title"],
- "unread" => $unread,
- "order_id" => (int) $line["order_id"],
- ));
+ if ($unread || !$unread_only) {
+ array_push($cats, array("id" => $line["id"],
+ "title" => $line["title"],
+ "unread" => $unread,
+ "order_id" => (int) $line["order_id"],
+ ));
+ }
}
}