From 74b046a1c9d10e5c937361c89c3ae790925b76d7 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 29 Mar 2011 12:09:42 +0400 Subject: [PATCH] add ttrss_feeds.update_on_checksum_change --- functions.php | 6 +++--- modules/pref-feeds.php | 25 +++++++++++++++++++++++++ schema/ttrss_schema_mysql.sql | 2 +- schema/ttrss_schema_pgsql.sql | 2 +- schema/versions/mysql/83.sql | 9 +++++++-- schema/versions/pgsql/83.sql | 9 +++++++-- 6 files changed, 44 insertions(+), 9 deletions(-) diff --git a/functions.php b/functions.php index e3e477f0f..ec449f274 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, - mark_unread_on_update, owner_uid + mark_unread_on_update, owner_uid, update_on_checksum_change FROM ttrss_feeds WHERE id = '$feed'"); } @@ -533,6 +533,7 @@ $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"); + $update_on_checksum_change = db_fetch_result($result, 0, "update_on_checksum_change"); db_query($link, "UPDATE ttrss_feeds SET last_update_started = NOW() WHERE id = '$feed'"); @@ -1202,8 +1203,7 @@ $post_needs_update = false; - if (get_pref($link, "UPDATE_POST_ON_CHECKSUM_CHANGE", $owner_uid, false) && - ($content_hash != $orig_content_hash)) { + if ($update_on_checksum_change && $content_hash != $orig_content_hash) { // print ""; $post_needs_update = true; } diff --git a/modules/pref-feeds.php b/modules/pref-feeds.php index 76b24bfd0..9b06cbe5f 100644 --- a/modules/pref-feeds.php +++ b/modules/pref-feeds.php @@ -462,6 +462,18 @@ name=\"mark_unread_on_update\" $checked> "; + $update_on_checksum_change = sql_bool_to_bool(db_fetch_result($result, 0, "update_on_checksum_change")); + + if ($update_on_checksum_change) { + $checked = "checked"; + } else { + $checked = ""; + } + + print "
 "; + # print ""; print ""; @@ -639,6 +651,11 @@ print " "; batch_edit_cbox("mark_unread_on_update", "mark_unread_on_update_l"); + print "
 "; + + print " "; batch_edit_cbox("update_on_checksum_change", "update_on_checksum_change_l"); print ""; @@ -679,6 +696,9 @@ $mark_unread_on_update = checkbox_to_sql_bool( db_escape_string($_POST["mark_unread_on_update"])); + $update_on_checksum_change = checkbox_to_sql_bool( + db_escape_string($_POST["update_on_checksum_change"])); + if (get_pref($link, 'ENABLE_FEED_CATS')) { if ($cat_id && $cat_id != 0) { $category_qpart = "cat_id = '$cat_id',"; @@ -713,6 +733,7 @@ include_in_digest = $include_in_digest, always_display_enclosures = $always_display_enclosures, mark_unread_on_update = $mark_unread_on_update, + update_on_checksum_change = $update_on_checksum_change, update_method = '$update_method' WHERE id = '$feed_id' AND owner_uid = " . $_SESSION["uid"]); @@ -772,6 +793,10 @@ $qpart = "mark_unread_on_update = '$mark_unread_on_update'"; break; + case "update_on_checksum_change": + $qpart = "update_on_checksum_change = '$update_on_checksum_change'"; + break; + case "cache_images": $qpart = "cache_images = '$cache_images'"; break; diff --git a/schema/ttrss_schema_mysql.sql b/schema/ttrss_schema_mysql.sql index ab27c1b75..46e08dea4 100644 --- a/schema/ttrss_schema_mysql.sql +++ b/schema/ttrss_schema_mysql.sql @@ -123,6 +123,7 @@ create table ttrss_feeds (id integer not null auto_increment primary key, update_method integer not null default 0, order_id integer not null default 0, mark_unread_on_update boolean not null default false, + update_on_checksum_change 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, @@ -304,7 +305,6 @@ create table ttrss_prefs (pref_name varchar(250) not null primary key, foreign key (section_id) references ttrss_prefs_sections(id)) TYPE=InnoDB DEFAULT CHARSET=UTF8; insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('PURGE_OLD_DAYS', 3, '60', 'Purge old posts after this number of days (0 - disables)',1); -insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('UPDATE_POST_ON_CHECKSUM_CHANGE', 1, 'true', 'Update post on checksum change',1); insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('DEFAULT_UPDATE_INTERVAL', 3, '30', 'Default interval between feed updates',1); diff --git a/schema/ttrss_schema_pgsql.sql b/schema/ttrss_schema_pgsql.sql index c7c51c5ae..8d87663d5 100644 --- a/schema/ttrss_schema_pgsql.sql +++ b/schema/ttrss_schema_pgsql.sql @@ -86,6 +86,7 @@ create table ttrss_feeds (id serial not null primary key, always_display_enclosures boolean not null default false, order_id integer not null default 0, mark_unread_on_update boolean not null default false, + update_on_checksum_change boolean not null default false, strip_images boolean not null default false, auth_pass_encrypted boolean not null default false); @@ -267,7 +268,6 @@ create table ttrss_prefs (pref_name varchar(250) not null primary key, def_value text not null); insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('PURGE_OLD_DAYS', 3, '60', 'Purge old posts after this number of days (0 - disables)',1); -insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('UPDATE_POST_ON_CHECKSUM_CHANGE', 1, 'true', 'Update post on checksum change',1); insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('DEFAULT_UPDATE_INTERVAL', 3, '30', 'Default interval between feed updates',1); diff --git a/schema/versions/mysql/83.sql b/schema/versions/mysql/83.sql index aa1d6c1ee..b86091532 100644 --- a/schema/versions/mysql/83.sql +++ b/schema/versions/mysql/83.sql @@ -10,9 +10,14 @@ 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'); +alter table ttrss_feeds add column update_on_checksum_change boolean; +update ttrss_feeds set update_on_checksum_change = false; +alter table ttrss_feeds change update_on_checksum_change update_on_checksum_change boolean not null; +alter table ttrss_feeds alter column update_on_checksum_change set default false; -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'); +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', 'UPDATE_POST_ON_CHECKSUM_CHANGE'); + +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_POST_ON_CHECKSUM_CHANGE'); update ttrss_version set schema_version = 83; diff --git a/schema/versions/pgsql/83.sql b/schema/versions/pgsql/83.sql index 4ba7120c1..12ffb1733 100644 --- a/schema/versions/pgsql/83.sql +++ b/schema/versions/pgsql/83.sql @@ -10,9 +10,14 @@ 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'); +alter table ttrss_feeds add column update_on_checksum_change boolean; +update ttrss_feeds set update_on_checksum_change = false; +alter table ttrss_feeds alter column update_on_checksum_change set not null; +alter table ttrss_feeds alter column update_on_checksum_change set default false; -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'); +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', 'UPDATE_POST_ON_CHECKSUM_CHANGE'); + +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_POST_ON_CHECKSUM_CHANGE'); update ttrss_version set schema_version = 83;