From 3f2ff803b391b719397f606dabd0c182db6ec274 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 30 Jan 2007 17:23:35 +0100 Subject: [PATCH] add interface/schema for inverse matching filters --- backend.php | 2 +- modules/popup-dialog.php | 5 +++ modules/pref-filters.php | 34 +++++++++++++++---- .../upgrade-1.2.4-1.2.6-mysql.sql | 0 .../upgrade-1.2.4-1.2.6-pgsql.sql | 0 schema/ttrss_schema_mysql.sql | 3 +- schema/ttrss_schema_pgsql.sql | 3 +- schema/upgrade-1.2.6-1.2.8-mysql.sql | 6 ++++ schema/upgrade-1.2.6-1.2.8-pgsql.sql | 10 ++++++ 9 files changed, 54 insertions(+), 9 deletions(-) rename schema/{ => obsolete}/upgrade-1.2.4-1.2.6-mysql.sql (100%) rename schema/{ => obsolete}/upgrade-1.2.4-1.2.6-pgsql.sql (100%) create mode 100644 schema/upgrade-1.2.6-1.2.8-mysql.sql create mode 100644 schema/upgrade-1.2.6-1.2.8-pgsql.sql diff --git a/backend.php b/backend.php index 326911e35..0437ce819 100644 --- a/backend.php +++ b/backend.php @@ -18,7 +18,7 @@ $op = $_REQUEST["op"]; - define('SCHEMA_VERSION', 12); + define('SCHEMA_VERSION', 13); require_once "sanity_check.php"; require_once "config.php"; diff --git a/modules/popup-dialog.php b/modules/popup-dialog.php index 240b09ba4..f9a955198 100644 --- a/modules/popup-dialog.php +++ b/modules/popup-dialog.php @@ -262,6 +262,11 @@ print ""; + print "Options:"; + + print " + "; + print ""; print ""; diff --git a/modules/pref-filters.php b/modules/pref-filters.php index 2a4747b8f..cbd942142 100644 --- a/modules/pref-filters.php +++ b/modules/pref-filters.php @@ -17,6 +17,7 @@ $action_param = db_fetch_result($result, 0, "action_param"); $enabled = sql_bool_to_bool(db_fetch_result($result, 0, "enabled")); + $inverse = sql_bool_to_bool(db_fetch_result($result, 0, "inverse")); print "
Filter editor
"; print "
"; @@ -87,9 +88,18 @@ $checked = ""; } - print "Options: + print "Options: - "; +
"; + + if ($inverse) { + $checked = "checked"; + } else { + $checked = ""; + } + + print " + "; print ""; @@ -121,6 +131,7 @@ $action_id = db_escape_string($_GET["action_id"]); $action_param = db_escape_string($_GET["action_param"]); $enabled = checkbox_to_sql_bool(db_escape_string($_GET["enabled"])); + $inverse = checkbox_to_sql_bool(db_escape_string($_GET["inverse"])); if (!$feed_id) { $feed_id = 'NULL'; @@ -134,6 +145,7 @@ action_id = '$action_id', filter_type = '$filter_type', enabled = $enabled, + inverse = $inverse, action_param = '$action_param' WHERE id = '$filter_id' AND owner_uid = " . $_SESSION["uid"]); } @@ -161,6 +173,8 @@ $action_id = db_escape_string($_GET["action_id"]); $action_param = db_escape_string($_GET["action_param"]); + $inverse = checkbox_to_sql_bool(db_escape_string($_GET["inverse"])); + if (!$regexp) return; if (!$feed_id) { @@ -171,10 +185,10 @@ $result = db_query($link, "INSERT INTO ttrss_filters (reg_exp,filter_type,owner_uid,feed_id, - action_id, action_param) + action_id, action_param, inverse) VALUES ('$regexp', '$filter_type','".$_SESSION["uid"]."', - $feed_id, '$action_id', '$action_param')"); + $feed_id, '$action_id', '$action_param', $inverse)"); } } @@ -209,6 +223,7 @@ ttrss_filter_types.name AS filter_type_name, ttrss_filter_types.description AS filter_type_descr, enabled, + inverse, feed_id, ttrss_filter_actions.description AS action_description, ttrss_feeds.title AS feed_title @@ -251,7 +266,8 @@ $edit_filter_id = $_GET["id"]; $enabled = sql_bool_to_bool($line["enabled"]); - + $inverse = sql_bool_to_bool($line["inverse"]); + if ($subop == "edit" && $filter_id != $edit_filter_id) { $class .= "Grayed"; $this_row_id = ""; @@ -286,9 +302,15 @@ print "" . $line["feed_title"] . ""; + + $inverse_label = ""; + + if ($inverse) { + $inverse_label = " (Inverse)"; + } print "" . - $line["filter_type_descr"] . ""; + $line["filter_type_descr"] . "$inverse_label"; print "" . $line["action_description"] . ""; diff --git a/schema/upgrade-1.2.4-1.2.6-mysql.sql b/schema/obsolete/upgrade-1.2.4-1.2.6-mysql.sql similarity index 100% rename from schema/upgrade-1.2.4-1.2.6-mysql.sql rename to schema/obsolete/upgrade-1.2.4-1.2.6-mysql.sql diff --git a/schema/upgrade-1.2.4-1.2.6-pgsql.sql b/schema/obsolete/upgrade-1.2.4-1.2.6-pgsql.sql similarity index 100% rename from schema/upgrade-1.2.4-1.2.6-pgsql.sql rename to schema/obsolete/upgrade-1.2.4-1.2.6-pgsql.sql diff --git a/schema/ttrss_schema_mysql.sql b/schema/ttrss_schema_mysql.sql index e8c43dde6..2f9670225 100644 --- a/schema/ttrss_schema_mysql.sql +++ b/schema/ttrss_schema_mysql.sql @@ -154,6 +154,7 @@ create table ttrss_filters (id integer not null primary key auto_increment, feed_id integer default null, filter_type integer not null, reg_exp varchar(250) not null, + inverse bool not null default false, enabled bool not null default true, action_id integer not null default 1, action_param varchar(200) not null default '', @@ -190,7 +191,7 @@ create table ttrss_tags (id integer primary key auto_increment, create table ttrss_version (schema_version int not null) TYPE=InnoDB; -insert into ttrss_version values (12); +insert into ttrss_version values (13); create table ttrss_prefs_types (id integer not null primary key, type_name varchar(100) not null) TYPE=InnoDB; diff --git a/schema/ttrss_schema_pgsql.sql b/schema/ttrss_schema_pgsql.sql index 3feacb75b..a9f056350 100644 --- a/schema/ttrss_schema_pgsql.sql +++ b/schema/ttrss_schema_pgsql.sql @@ -149,6 +149,7 @@ create table ttrss_filters (id serial not null primary key, filter_type integer not null references ttrss_filter_types(id), reg_exp varchar(250) not null, enabled boolean not null default true, + inverse boolean not null default false, action_id integer not null default 1 references ttrss_filter_actions(id) on delete cascade, action_param varchar(200) not null default ''); @@ -174,7 +175,7 @@ create index ttrss_tags_owner_uid_index on ttrss_tags(owner_uid); create table ttrss_version (schema_version int not null); -insert into ttrss_version values (12); +insert into ttrss_version values (13); create table ttrss_prefs_types (id integer not null primary key, type_name varchar(100) not null); diff --git a/schema/upgrade-1.2.6-1.2.8-mysql.sql b/schema/upgrade-1.2.6-1.2.8-mysql.sql new file mode 100644 index 000000000..ad068c8a2 --- /dev/null +++ b/schema/upgrade-1.2.6-1.2.8-mysql.sql @@ -0,0 +1,6 @@ +alter table ttrss_filters add column inverse bool; +update ttrss_filters set inverse = false; +alter table ttrss_filters change inverse inverse bool not null; +alter table ttrss_filters alter column inverse set default false; + +update ttrss_version set schema_version = 13; diff --git a/schema/upgrade-1.2.6-1.2.8-pgsql.sql b/schema/upgrade-1.2.6-1.2.8-pgsql.sql new file mode 100644 index 000000000..bf2a2b438 --- /dev/null +++ b/schema/upgrade-1.2.6-1.2.8-pgsql.sql @@ -0,0 +1,10 @@ +begin; + +alter table ttrss_filters add column inverse boolean; +update ttrss_filters set inverse = false; +alter table ttrss_filters alter column inverse set not null; +alter table ttrss_filters alter column inverse set default false; + +update ttrss_version set schema_version = 13; + +commit;