]> git.wh0rd.org Git - tt-rss.git/commitdiff
add interface/schema for inverse matching filters
authorAndrew Dolgov <fox@bah.spb.su>
Tue, 30 Jan 2007 16:23:35 +0000 (17:23 +0100)
committerAndrew Dolgov <fox@bah.spb.su>
Tue, 30 Jan 2007 16:23:35 +0000 (17:23 +0100)
backend.php
modules/popup-dialog.php
modules/pref-filters.php
schema/obsolete/upgrade-1.2.4-1.2.6-mysql.sql [new file with mode: 0644]
schema/obsolete/upgrade-1.2.4-1.2.6-pgsql.sql [new file with mode: 0644]
schema/ttrss_schema_mysql.sql
schema/ttrss_schema_pgsql.sql
schema/upgrade-1.2.4-1.2.6-mysql.sql [deleted file]
schema/upgrade-1.2.4-1.2.6-pgsql.sql [deleted file]
schema/upgrade-1.2.6-1.2.8-mysql.sql [new file with mode: 0644]
schema/upgrade-1.2.6-1.2.8-pgsql.sql [new file with mode: 0644]

index 326911e356f54a10a3989856bdd6a18dbfa6506d..0437ce819fe696703406a889739c3a5bbf841b44 100644 (file)
@@ -18,7 +18,7 @@
 
        $op = $_REQUEST["op"];
 
-       define('SCHEMA_VERSION', 12);
+       define('SCHEMA_VERSION', 13);
 
        require_once "sanity_check.php";
        require_once "config.php";
index 240b09ba4b3a987774508857d6b8aeac73d79387..f9a9551981506859a994a687feade34d3133644a 100644 (file)
 
                        print "<td><input disabled class='iedit' name='action_param'></td></tr>";
 
+                       print "<tr><td valign='top'>Options:</td><td>";
+
+                       print "<input type=\"checkbox\" name=\"inverse\" id=\"inverse\">
+                               <label for=\"inverse\">Inverse match</label></td></tr>";
+
                        print "</table>";
 
                        print "</form>";
index 2a4747b8f57dd2751d32ec86260d011cc51d85e8..cbd94214268b44530779b1f5dcdab943d920e3a1 100644 (file)
@@ -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 "<div id=\"infoBoxTitle\">Filter editor</div>";
                        print "<div class=\"infoBoxContents\">";
                                $checked = "";
                        }
 
-                       print "<tr><td>Options:</td><td>
+                       print "<tr><td valign='top'>Options:</td><td>
                                        <input type=\"checkbox\" name=\"enabled\" id=\"enabled\" $checked>
-                                       <label for=\"enabled\">Enabled</label>";
+                                       <label for=\"enabled\">Enabled</label><br/>";
+
+                       if ($inverse) {
+                               $checked = "checked";
+                       } else {
+                               $checked = "";
+                       }
+
+                       print "<input type=\"checkbox\" name=\"inverse\" id=\"inverse\" $checked>
+                               <label for=\"inverse\">Inverse match</label>";
 
                        print "</td></tr></table>";
 
                        $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';
                                        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"]);
                }
                                $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) {
 
                                $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)");
                        } 
                }
 
                                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
                                $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 = "";
        
                                print "<td><a href=\"javascript:editFilter($filter_id);\">" . 
                                        $line["feed_title"] . "</td>";                  
+
+                               $inverse_label = "";
+
+                               if ($inverse) {
+                                       $inverse_label = " <span class='insensitive'>(Inverse)</span>";
+                               }
        
                                print "<td><a href=\"javascript:editFilter($filter_id);\">" . 
-                                       $line["filter_type_descr"] . "</td>";           
+                                       $line["filter_type_descr"] . "$inverse_label</td>";             
                
                                print "<td><a href=\"javascript:editFilter($filter_id);\">" . 
                                        $line["action_description"] . "</td>";                  
diff --git a/schema/obsolete/upgrade-1.2.4-1.2.6-mysql.sql b/schema/obsolete/upgrade-1.2.4-1.2.6-mysql.sql
new file mode 100644 (file)
index 0000000..73af4e3
--- /dev/null
@@ -0,0 +1,12 @@
+alter table ttrss_filters add column action_param varchar(200);
+
+update ttrss_filters set action_param = '';
+
+alter table ttrss_filters change action_param action_param varchar(200) not null;
+alter table ttrss_filters alter column action_param set default '';
+
+insert into ttrss_filter_actions (id,name,description) values (4, 'tag', 
+               'Assign tags');
+
+update ttrss_version set schema_version = 12;
+
diff --git a/schema/obsolete/upgrade-1.2.4-1.2.6-pgsql.sql b/schema/obsolete/upgrade-1.2.4-1.2.6-pgsql.sql
new file mode 100644 (file)
index 0000000..6de90f1
--- /dev/null
@@ -0,0 +1,15 @@
+begin;
+
+alter table ttrss_filters add column action_param varchar(200);
+
+update ttrss_filters set action_param = '';
+
+alter table ttrss_filters alter column action_param set not null;
+alter table ttrss_filters alter column action_param set default '';
+
+insert into ttrss_filter_actions (id,name,description) values (4, 'tag', 
+               'Assign tags');
+
+update ttrss_version set schema_version = 12;
+
+commit;
index e8c43dde6d70551e9a6258e8fbe0095273a8fe61..2f967022572a0e6c044a3d060843c44579e000f6 100644 (file)
@@ -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;
index 3feacb75bbaf68613f49edaa52ca0983587649e5..a9f0563507d70ccd35110c0709092b72a1ae5c8b 100644 (file)
@@ -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.4-1.2.6-mysql.sql b/schema/upgrade-1.2.4-1.2.6-mysql.sql
deleted file mode 100644 (file)
index 73af4e3..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-alter table ttrss_filters add column action_param varchar(200);
-
-update ttrss_filters set action_param = '';
-
-alter table ttrss_filters change action_param action_param varchar(200) not null;
-alter table ttrss_filters alter column action_param set default '';
-
-insert into ttrss_filter_actions (id,name,description) values (4, 'tag', 
-               'Assign tags');
-
-update ttrss_version set schema_version = 12;
-
diff --git a/schema/upgrade-1.2.4-1.2.6-pgsql.sql b/schema/upgrade-1.2.4-1.2.6-pgsql.sql
deleted file mode 100644 (file)
index 6de90f1..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-begin;
-
-alter table ttrss_filters add column action_param varchar(200);
-
-update ttrss_filters set action_param = '';
-
-alter table ttrss_filters alter column action_param set not null;
-alter table ttrss_filters alter column action_param set default '';
-
-insert into ttrss_filter_actions (id,name,description) values (4, 'tag', 
-               'Assign tags');
-
-update ttrss_version set schema_version = 12;
-
-commit;
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 (file)
index 0000000..ad068c8
--- /dev/null
@@ -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 (file)
index 0000000..bf2a2b4
--- /dev/null
@@ -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;