From 9382ca847f6a6be7458b07ed3accc9e4ddb6bd31 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 29 Mar 2011 11:54:44 +0400 Subject: [PATCH] add ttrss_feeds.mark_unread_on_update, bump schema, cleanup ttrss_prefs --- functions.php | 5 +++-- modules/pref-feeds.php | 27 +++++++++++++++++++++++++++ modules/pref-prefs.php | 12 ++++-------- sanity_check.php | 2 +- schema/ttrss_schema_mysql.sql | 8 +++----- schema/ttrss_schema_pgsql.sql | 8 +++----- schema/versions/mysql/83.sql | 19 +++++++++++++++++++ schema/versions/pgsql/83.sql | 19 +++++++++++++++++++ 8 files changed, 79 insertions(+), 21 deletions(-) create mode 100644 schema/versions/mysql/83.sql create mode 100644 schema/versions/pgsql/83.sql diff --git a/functions.php b/functions.php index 974e2b9a..e3e477f0 100644 --- a/functions.php +++ b/functions.php @@ -517,7 +517,7 @@ $result = db_query($link, "SELECT id,update_interval,auth_login, feed_url,auth_pass,cache_images,update_method,last_updated, - owner_uid + mark_unread_on_update, owner_uid FROM ttrss_feeds WHERE id = '$feed'"); } @@ -532,6 +532,7 @@ $update_method = db_fetch_result($result, 0, "update_method"); $last_updated = db_fetch_result($result, 0, "last_updated"); $owner_uid = db_fetch_result($result, 0, "owner_uid"); + $mark_unread_on_update = db_fetch_result($result, 0, "mark_unread_on_update"); db_query($link, "UPDATE ttrss_feeds SET last_update_started = NOW() WHERE id = '$feed'"); @@ -1237,7 +1238,7 @@ num_comments = '$num_comments' WHERE id = '$ref_id'"); - if (get_pref($link, "MARK_UNREAD_ON_UPDATE", $owner_uid, false)) { + if ($mark_unread_on_update) { db_query($link, "UPDATE ttrss_user_entries SET last_read = null, unread = true WHERE ref_id = '$ref_id'"); } else { diff --git a/modules/pref-feeds.php b/modules/pref-feeds.php index d8e2c0f0..76b24bfd 100644 --- a/modules/pref-feeds.php +++ b/modules/pref-feeds.php @@ -450,6 +450,18 @@ __('Cache images locally (SimplePie only)').""; } + $mark_unread_on_update = sql_bool_to_bool(db_fetch_result($result, 0, "mark_unread_on_update")); + + if ($mark_unread_on_update) { + $checked = "checked"; + } else { + $checked = ""; + } + + print "
 "; + # print ""; print ""; @@ -621,6 +633,13 @@ print " "; batch_edit_cbox("cache_images", "cache_images_l"); } + print "
 "; + + print " "; batch_edit_cbox("mark_unread_on_update", "mark_unread_on_update_l"); + + print ""; print "
@@ -657,6 +676,9 @@ $always_display_enclosures = checkbox_to_sql_bool( db_escape_string($_POST["always_display_enclosures"])); + $mark_unread_on_update = checkbox_to_sql_bool( + db_escape_string($_POST["mark_unread_on_update"])); + if (get_pref($link, 'ENABLE_FEED_CATS')) { if ($cat_id && $cat_id != 0) { $category_qpart = "cat_id = '$cat_id',"; @@ -690,6 +712,7 @@ $cache_images_qpart include_in_digest = $include_in_digest, always_display_enclosures = $always_display_enclosures, + mark_unread_on_update = $mark_unread_on_update, update_method = '$update_method' WHERE id = '$feed_id' AND owner_uid = " . $_SESSION["uid"]); @@ -745,6 +768,10 @@ $qpart = "always_display_enclosures = '$always_display_enclosures'"; break; + case "mark_unread_on_update": + $qpart = "mark_unread_on_update = '$mark_unread_on_update'"; + break; + case "cache_images": $qpart = "cache_images = '$cache_images'"; break; diff --git a/modules/pref-prefs.php b/modules/pref-prefs.php index 87f8b642..c78937dc 100644 --- a/modules/pref-prefs.php +++ b/modules/pref-prefs.php @@ -5,17 +5,13 @@ $subop = $_REQUEST["subop"]; - $prefs_blacklist = array("HIDE_FEEDLIST", "SYNC_COUNTERS", "ENABLE_LABELS", - "ENABLE_SEARCH_TOOLBAR", "HIDE_READ_FEEDS", "ENABLE_FEED_ICONS", - "ENABLE_OFFLINE_READING", "EXTENDED_FEEDLIST", "FEEDS_SORT_BY_UNREAD", - "OPEN_LINKS_IN_NEW_WINDOW", "USER_STYLESHEET_URL", "ENABLE_FLASH_PLAYER", - "HEADLINES_SMART_DATE"); + $prefs_blacklist = array("HIDE_READ_FEEDS", "FEEDS_SORT_BY_UNREAD", + "USER_STYLESHEET_URL"); $profile_blacklist = array("ALLOW_DUPLICATE_POSTS", "PURGE_OLD_DAYS", "PURGE_UNREAD_ARTICLES", "DIGEST_ENABLE", "DIGEST_CATCHUP", - "BLACKLISTED_TAGS", "ENABLE_FEED_ICONS", "ENABLE_API_ACCESS", - "UPDATE_POST_ON_CHECKSUM_CHANGE", "DEFAULT_UPDATE_INTERVAL", - "MARK_UNREAD_ON_UPDATE", "USER_TIMEZONE", "SORT_HEADLINES_BY_FEED_DATE", + "BLACKLISTED_TAGS", "ENABLE_API_ACCESS", "UPDATE_POST_ON_CHECKSUM_CHANGE", + "DEFAULT_UPDATE_INTERVAL", "USER_TIMEZONE", "SORT_HEADLINES_BY_FEED_DATE", "SSL_CERT_SERIAL"); if (FORCE_ARTICLE_PURGE != 0) { diff --git a/sanity_check.php b/sanity_check.php index 96f4e839..3b9de347 100644 --- a/sanity_check.php +++ b/sanity_check.php @@ -2,7 +2,7 @@ require_once "functions.php"; define('EXPECTED_CONFIG_VERSION', 21); - define('SCHEMA_VERSION', 82); + define('SCHEMA_VERSION', 83); if (!file_exists("config.php")) { print "Fatal Error: You forgot to copy diff --git a/schema/ttrss_schema_mysql.sql b/schema/ttrss_schema_mysql.sql index 69cf6dce..ab27c1b7 100644 --- a/schema/ttrss_schema_mysql.sql +++ b/schema/ttrss_schema_mysql.sql @@ -122,6 +122,8 @@ create table ttrss_feeds (id integer not null auto_increment primary key, always_display_enclosures boolean not null default false, update_method integer not null default 0, order_id integer not null default 0, + mark_unread_on_update boolean not null default false, + strip_images boolean not null default false, index(owner_uid), foreign key (owner_uid) references ttrss_users(id) ON DELETE CASCADE, index(cat_id), @@ -258,7 +260,7 @@ create table ttrss_tags (id integer primary key auto_increment, create table ttrss_version (schema_version int not null) TYPE=InnoDB DEFAULT CHARSET=UTF8; -insert into ttrss_version values (82); +insert into ttrss_version values (83); create table ttrss_enclosures (id integer primary key auto_increment, content_url text not null, @@ -317,8 +319,6 @@ insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) valu insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('SHORT_DATE_FORMAT', 2, 'M d, G:i', 'Short date format',3); insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('LONG_DATE_FORMAT', 2, 'D, M d Y - G:i', 'Long date format',3); -insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('HEADLINES_SMART_DATE', 1, 'true', 'Use more accessible date/time format for headlines',3); - insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id,help_text) values('COMBINED_DISPLAY_MODE', 1, 'false', 'Combined feed display',2, 'Display expanded list of feed articles, instead of separate displays for headlines and article content'); insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('HIDE_READ_FEEDS', 1, 'false', 'Hide feeds with no unread messages',2); @@ -327,8 +327,6 @@ 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) values('FEEDS_SORT_BY_UNREAD', 1, 'false', 'Sort feeds by unread articles count',2); -insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('MARK_UNREAD_ON_UPDATE', 1, 'false', 'Set articles as unread on update',3); - insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('REVERSE_HEADLINES', 1, 'false', 'Reverse headline order (oldest first)',2); insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id,help_text) values('DIGEST_ENABLE', 1, 'false', 'Enable e-mail digest',1, 'This option enables sending daily digest of new (and unread) headlines on your configured e-mail address'); diff --git a/schema/ttrss_schema_pgsql.sql b/schema/ttrss_schema_pgsql.sql index 7718aa30..c7c51c5a 100644 --- a/schema/ttrss_schema_pgsql.sql +++ b/schema/ttrss_schema_pgsql.sql @@ -85,6 +85,8 @@ create table ttrss_feeds (id serial not null primary key, update_method integer not null default 0, always_display_enclosures boolean not null default false, order_id integer not null default 0, + mark_unread_on_update boolean not null default false, + strip_images boolean not null default false, auth_pass_encrypted boolean not null default false); create index ttrss_feeds_owner_uid_index on ttrss_feeds(owner_uid); @@ -229,7 +231,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 (82); +insert into ttrss_version values (83); create table ttrss_enclosures (id serial not null primary key, content_url text not null, @@ -281,8 +283,6 @@ insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) valu insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('LONG_DATE_FORMAT', 2, 'D, M d Y - G:i', 'Long date format',3); -insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('HEADLINES_SMART_DATE', 1, 'true', 'Use more accessible date/time format for headlines',3); - insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id,help_text) values('COMBINED_DISPLAY_MODE', 1, 'false', 'Combined feed display',2, 'Display expanded list of feed articles, instead of separate displays for headlines and article content'); insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('HIDE_READ_FEEDS', 1, 'false', 'Hide feeds with no unread messages',2); @@ -291,8 +291,6 @@ 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) values('FEEDS_SORT_BY_UNREAD', 1, 'false', 'Sort feeds by unread articles count',2); -insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('MARK_UNREAD_ON_UPDATE', 1, 'false', 'Set articles as unread on update',3); - insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('REVERSE_HEADLINES', 1, 'false', 'Reverse headline order (oldest first)',2); insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id,help_text) values('DIGEST_ENABLE', 1, 'false', 'Enable e-mail digest',1, 'This option enables sending daily digest of new (and unread) headlines on your configured e-mail address'); diff --git a/schema/versions/mysql/83.sql b/schema/versions/mysql/83.sql new file mode 100644 index 00000000..aa1d6c1e --- /dev/null +++ b/schema/versions/mysql/83.sql @@ -0,0 +1,19 @@ +begin; + +alter table ttrss_feeds add column mark_unread_on_update boolean; +update ttrss_feeds set mark_unread_on_update = false; +alter table ttrss_feeds change mark_unread_on_update mark_unread_on_update boolean not null; +alter table ttrss_feeds alter column mark_unread_on_update set default false; + +alter table ttrss_feeds add column strip_images boolean; +update ttrss_feeds set strip_images = false; +alter table ttrss_feeds change strip_images strip_images boolean not null; +alter table ttrss_feeds alter column strip_images set default false; + +DELETE FROM ttrss_user_prefs WHERE pref_name IN ('HIDE_FEEDLIST', 'SYNC_COUNTERS', 'ENABLE_LABELS', 'ENABLE_SEARCH_TOOLBAR', 'ENABLE_FEED_ICONS', 'ENABLE_OFFLINE_READING', 'EXTENDED_FEEDLIST', 'OPEN_LINKS_IN_NEW_WINDOW', 'ENABLE_FLASH_PLAYER', 'HEADLINES_SMART_DATE', 'MARK_UNREAD_ON_UPDATE'); + +DELETE FROM ttrss_prefs WHERE pref_name IN ('HIDE_FEEDLIST', 'SYNC_COUNTERS', 'ENABLE_LABELS', 'ENABLE_SEARCH_TOOLBAR', 'ENABLE_FEED_ICONS', 'ENABLE_OFFLINE_READING', 'EXTENDED_FEEDLIST', 'OPEN_LINKS_IN_NEW_WINDOW', 'ENABLE_FLASH_PLAYER', 'HEADLINES_SMART_DATE', 'MARK_UNREAD_ON_UPDATE'); + +update ttrss_version set schema_version = 83; + +commit; diff --git a/schema/versions/pgsql/83.sql b/schema/versions/pgsql/83.sql new file mode 100644 index 00000000..4ba7120c --- /dev/null +++ b/schema/versions/pgsql/83.sql @@ -0,0 +1,19 @@ +begin; + +alter table ttrss_feeds add column mark_unread_on_update boolean; +update ttrss_feeds set mark_unread_on_update = false; +alter table ttrss_feeds alter column mark_unread_on_update set not null; +alter table ttrss_feeds alter column mark_unread_on_update set default false; + +alter table ttrss_feeds add column strip_images boolean; +update ttrss_feeds set strip_images = false; +alter table ttrss_feeds alter column strip_images set not null; +alter table ttrss_feeds alter column strip_images set default false; + +DELETE FROM ttrss_user_prefs WHERE pref_name IN ('HIDE_FEEDLIST', 'SYNC_COUNTERS', 'ENABLE_LABELS', 'ENABLE_SEARCH_TOOLBAR', 'ENABLE_FEED_ICONS', 'ENABLE_OFFLINE_READING', 'EXTENDED_FEEDLIST', 'OPEN_LINKS_IN_NEW_WINDOW', 'ENABLE_FLASH_PLAYER', 'HEADLINES_SMART_DATE', 'MARK_UNREAD_ON_UPDATE'); + +DELETE FROM ttrss_prefs WHERE pref_name IN ('HIDE_FEEDLIST', 'SYNC_COUNTERS', 'ENABLE_LABELS', 'ENABLE_SEARCH_TOOLBAR', 'ENABLE_FEED_ICONS', 'ENABLE_OFFLINE_READING', 'EXTENDED_FEEDLIST', 'OPEN_LINKS_IN_NEW_WINDOW', 'ENABLE_FLASH_PLAYER', 'HEADLINES_SMART_DATE', 'MARK_UNREAD_ON_UPDATE'); + +update ttrss_version set schema_version = 83; + +commit; -- 2.39.5