summaryrefslogtreecommitdiff
path: root/classes
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2013-03-28 15:28:37 +0400
committerAndrew Dolgov <[email protected]>2013-03-28 15:28:37 +0400
commit66ca7c30975a0435f7c8a2aa6c1009f201ccec8c (patch)
tree8cc1fcb137d29c2b5d0524433ac73fb2ea660507 /classes
parenteb734e52254e46f90c49a1919652f7aefd2ff989 (diff)
api: add include_empty to getCategories/getFeedTree
Diffstat (limited to 'classes')
-rw-r--r--classes/api.php6
-rw-r--r--classes/pref/feeds.php11
2 files changed, 12 insertions, 5 deletions
diff --git a/classes/api.php b/classes/api.php
index 1efa3865f..d1733842c 100644
--- a/classes/api.php
+++ b/classes/api.php
@@ -125,6 +125,7 @@ class API extends Handler {
function getCategories() {
$unread_only = sql_bool_to_bool($_REQUEST["unread_only"]);
$enable_nested = sql_bool_to_bool($_REQUEST["enable_nested"]);
+ $include_empty = (int)$_REQUEST['include_empty'];
// TODO do not return empty categories, return Uncategorized and standard virtual cats
@@ -147,7 +148,7 @@ class API extends Handler {
$cats = array();
while ($line = db_fetch_assoc($result)) {
- if ($line["num_feeds"] > 0 || $line["num_cats"] > 0) {
+ if ($include_empty || $line["num_feeds"] > 0 || $line["num_cats"] > 0) {
$unread = getFeedUnread($this->link, $line["id"], true);
if ($enable_nested)
@@ -705,9 +706,12 @@ class API extends Handler {
}
function getFeedTree() {
+ $include_empty = (int)$_REQUEST['include_empty'];
+
$pf = new Pref_Feeds($this->link, $_REQUEST);
$_REQUEST['mode'] = 2;
+ $_REQUEST['force_show_empty'] = $include_empty;
if ($pf){
$data = $pf->makefeedtree();
diff --git a/classes/pref/feeds.php b/classes/pref/feeds.php
index 362d046e8..1ec0b7b54 100644
--- a/classes/pref/feeds.php
+++ b/classes/pref/feeds.php
@@ -33,8 +33,10 @@ class Pref_Feeds extends Handler_Protected {
if ($search) $search_qpart = " AND LOWER(title) LIKE LOWER('%$search%')";
- $show_empty_cats = $_REQUEST['mode'] != 2 && !$search &&
- get_pref($this->link, '_PREFS_SHOW_EMPTY_CATS');
+ // first one is set by API
+ $show_empty_cats = $_REQUEST['force_show_empty'] ||
+ ($_REQUEST['mode'] != 2 && !$search &&
+ get_pref($this->link, '_PREFS_SHOW_EMPTY_CATS'));
$items = array();
@@ -183,8 +185,9 @@ class Pref_Feeds extends Handler_Protected {
}
if ($enable_cats) {
- $show_empty_cats = $_REQUEST['mode'] != 2 && !$search &&
- get_pref($this->link, '_PREFS_SHOW_EMPTY_CATS');
+ $show_empty_cats = $_REQUEST['force_show_empty'] ||
+ ($_REQUEST['mode'] != 2 && !$search &&
+ get_pref($this->link, '_PREFS_SHOW_EMPTY_CATS'));
$result = db_query($this->link, "SELECT id, title FROM ttrss_feed_categories
WHERE owner_uid = " . $_SESSION["uid"] . " AND parent_cat IS NULL ORDER BY order_id, title");