From 5b7bd238eeed1aa83fe47f715c79b16b42ab347f Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 5 Mar 2012 12:08:39 +0400 Subject: [PATCH] pref-feeds: apply patch by gmargo@forum to show/hide empty categories --- classes/pref_feeds.php | 12 ++++++++++-- include/sanity_check.php | 2 +- js/prefs.js | 15 +++++++++++++++ schema/ttrss_schema_mysql.sql | 4 +++- schema/ttrss_schema_pgsql.sql | 4 +++- schema/versions/mysql/90.sql | 7 +++++++ schema/versions/pgsql/90.sql | 7 +++++++ 7 files changed, 46 insertions(+), 5 deletions(-) create mode 100644 schema/versions/mysql/90.sql create mode 100644 schema/versions/pgsql/90.sql diff --git a/classes/pref_feeds.php b/classes/pref_feeds.php index ec594522..a091b735 100644 --- a/classes/pref_feeds.php +++ b/classes/pref_feeds.php @@ -45,6 +45,7 @@ class Pref_Feeds extends Protected_Handler { $root['type'] = 'category'; if (get_pref($this->link, 'ENABLE_FEED_CATS')) { + $show_empty_cats = 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"] . " ORDER BY order_id, title"); @@ -80,7 +81,7 @@ class Pref_Feeds extends Protected_Handler { $cat['param'] = T_sprintf('(%d feeds)', count($cat['items'])); - if (count($cat['items']) > 0) + if (count($cat['items']) > 0 || $show_empty_cats) array_push($root['items'], $cat); $root['param'] += count($cat['items']); @@ -118,7 +119,7 @@ class Pref_Feeds extends Protected_Handler { $cat['param'] = T_sprintf('(%d feeds)', count($cat['items'])); - if (count($cat['items']) > 0) + if (count($cat['items']) > 0 || $show_empty_cats) array_push($root['items'], $cat); $root['param'] += count($cat['items']); @@ -170,6 +171,11 @@ class Pref_Feeds extends Protected_Handler { return; } + function togglehiddenfeedcats() { + set_pref($this->link, '_PREFS_SHOW_EMPTY_CATS', + (get_pref($this->link, '_PREFS_SHOW_EMPTY_CATS') ? 'false' : 'true')); + } + function savefeedorder() { $data = json_decode($_POST['payload'], true); @@ -1328,6 +1334,8 @@ class Pref_Feeds extends Protected_Handler { print "
"; print "
".__('Edit categories')."
"; + print "
".__('(Un)hide empty categories')."
"; print "
".__('Reset sort order')."
"; print "
"; diff --git a/include/sanity_check.php b/include/sanity_check.php index 3de1593f..5c631574 100644 --- a/include/sanity_check.php +++ b/include/sanity_check.php @@ -6,7 +6,7 @@ } else { define('EXPECTED_CONFIG_VERSION', 25); - define('SCHEMA_VERSION', 89); + define('SCHEMA_VERSION', 90); require_once "config.php"; require_once "sanity_config.php"; diff --git a/js/prefs.js b/js/prefs.js index a151cbed..4342f617 100644 --- a/js/prefs.js +++ b/js/prefs.js @@ -1635,6 +1635,21 @@ function resetCatOrder() { } } +function toggleHiddenFeedCats() { + try { + notify_progress("Loading, please wait..."); + + new Ajax.Request("backend.php", { + parameters: "?op=pref-feeds&method=togglehiddenfeedcats", + onComplete: function(transport) { + updateFeedList(); + } }); + + } catch (e) { + exception_error("toggleHiddenFeedCats"); + } +} + function editCat(id, item, event) { try { var new_name = prompt(__('Rename category to:'), item.name); diff --git a/schema/ttrss_schema_mysql.sql b/schema/ttrss_schema_mysql.sql index 096587be..769922cf 100644 --- a/schema/ttrss_schema_mysql.sql +++ b/schema/ttrss_schema_mysql.sql @@ -260,7 +260,7 @@ create table ttrss_tags (id integer primary key auto_increment, create table ttrss_version (schema_version int not null) ENGINE=InnoDB DEFAULT CHARSET=UTF8; -insert into ttrss_version values (89); +insert into ttrss_version values (90); create table ttrss_enclosures (id integer primary key auto_increment, content_url text not null, @@ -394,6 +394,8 @@ insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id,help_ insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id,help_text) values('DIGEST_PREFERRED_TIME', 2, '00:00', 'Try to send digests around specified time', 1, 'Uses UTC timezone'); +insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_PREFS_SHOW_EMPTY_CATS', 1, 'false', '', 1); + create table ttrss_user_prefs ( owner_uid integer not null, pref_name varchar(250), diff --git a/schema/ttrss_schema_pgsql.sql b/schema/ttrss_schema_pgsql.sql index f2b760b1..eddc5e8f 100644 --- a/schema/ttrss_schema_pgsql.sql +++ b/schema/ttrss_schema_pgsql.sql @@ -229,7 +229,7 @@ create index ttrss_tags_post_int_id_idx on ttrss_tags(post_int_id); create table ttrss_version (schema_version int not null); -insert into ttrss_version values (89); +insert into ttrss_version values (90); create table ttrss_enclosures (id serial not null primary key, content_url text not null, @@ -356,6 +356,8 @@ insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id,help_ insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id,help_text) values('DIGEST_PREFERRED_TIME', 2, '00:00', 'Try to send digests around specified time', 1, 'Uses UTC timezone'); +insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_PREFS_SHOW_EMPTY_CATS', 1, 'false', '', 1); + create table ttrss_user_prefs ( owner_uid integer not null references ttrss_users(id) ON DELETE CASCADE, pref_name varchar(250) not null references ttrss_prefs(pref_name) ON DELETE CASCADE, diff --git a/schema/versions/mysql/90.sql b/schema/versions/mysql/90.sql new file mode 100644 index 00000000..b7935535 --- /dev/null +++ b/schema/versions/mysql/90.sql @@ -0,0 +1,7 @@ +begin; + +insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_PREFS_SHOW_EMPTY_CATS', 1, 'false', '', 1); + +update ttrss_version set schema_version = 90; + +commit; diff --git a/schema/versions/pgsql/90.sql b/schema/versions/pgsql/90.sql new file mode 100644 index 00000000..b7935535 --- /dev/null +++ b/schema/versions/pgsql/90.sql @@ -0,0 +1,7 @@ +begin; + +insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_PREFS_SHOW_EMPTY_CATS', 1, 'false', '', 1); + +update ttrss_version set schema_version = 90; + +commit; -- 2.39.5