summaryrefslogtreecommitdiff
path: root/classes
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2013-04-01 14:04:56 +0400
committerAndrew Dolgov <[email protected]>2013-04-01 14:04:56 +0400
commitc0a08063d679042d5616127f39632241d73604fe (patch)
treefa07442e260ebdb99820e7b5fe8e808df7be8d3b /classes
parent417591034a3e02d160abd226033b0781749f285b (diff)
api: do not return Labels category when there are no labels (closes #651)
Diffstat (limited to 'classes')
-rw-r--r--classes/api.php28
1 files changed, 23 insertions, 5 deletions
diff --git a/classes/api.php b/classes/api.php
index 0e56e58f9..d3b61c15a 100644
--- a/classes/api.php
+++ b/classes/api.php
@@ -165,12 +165,14 @@ class API extends Handler {
}
foreach (array(-2,-1,0) as $cat_id) {
- $unread = getFeedUnread($this->link, $cat_id, true);
+ if ($include_empty || !$this->isCategoryEmpty($cat_id)) {
+ $unread = getFeedUnread($this->link, $cat_id, true);
- if ($unread || !$unread_only) {
- array_push($cats, array("id" => $cat_id,
- "title" => getCategoryTitle($this->link, $cat_id),
- "unread" => $unread));
+ if ($unread || !$unread_only) {
+ array_push($cats, array("id" => $cat_id,
+ "title" => getCategoryTitle($this->link, $cat_id),
+ "unread" => $unread));
+ }
}
}
@@ -724,6 +726,22 @@ class API extends Handler {
}
}
+
+ // only works for labels for the time being
+ private function isCategoryEmpty($id) {
+
+ if ($id == -2) {
+ $result = db_query($this->link, "SELECT COUNT(*) AS count FROM ttrss_labels2
+ WHERE owner_uid = " . $_SESSION["uid"]);
+
+ return db_fetch_result($result, 0, "count") == 0;
+
+ }
+
+ return false;
+ }
+
+
}
?>