api: block real categories with 0 feeds to appear in getCategories

This commit is contained in:
Andrew Dolgov 2013-02-10 11:40:03 +04:00
parent b44587922c
commit d49dfa381e

View file

@ -131,13 +131,17 @@ class API extends Handler {
$nested_qpart = "true"; $nested_qpart = "true";
$result = db_query($this->link, "SELECT $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 = " . WHERE $nested_qpart AND owner_uid = " .
$_SESSION["uid"]); $_SESSION["uid"]);
$cats = array(); $cats = array();
while ($line = db_fetch_assoc($result)) { while ($line = db_fetch_assoc($result)) {
if ($line["num_feeds"] > 0) {
$unread = getFeedUnread($this->link, $line["id"], true); $unread = getFeedUnread($this->link, $line["id"], true);
if ($enable_nested) if ($enable_nested)
@ -151,6 +155,7 @@ class API extends Handler {
)); ));
} }
} }
}
foreach (array(-2,-1,0) as $cat_id) { foreach (array(-2,-1,0) as $cat_id) {
$unread = getFeedUnread($this->link, $cat_id, true); $unread = getFeedUnread($this->link, $cat_id, true);