summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2013-03-25 19:46:43 +0400
committerAndrew Dolgov <[email protected]>2013-03-25 19:46:43 +0400
commita3a896a127b90548d404d347f3665a7e6ac90f40 (patch)
treecc2650a5c396adf69e45b69f5862e14733765763 /include
parentaff02f89c112dc147213a877d582c873ae981514 (diff)
let us rejoice on being able to create double negative filters (refs #631)
Diffstat (limited to 'include')
-rw-r--r--include/functions.php18
-rw-r--r--include/rssfuncs.php6
2 files changed, 19 insertions, 5 deletions
diff --git a/include/functions.php b/include/functions.php
index b52531f66..9a855a9bc 100644
--- a/include/functions.php
+++ b/include/functions.php
@@ -1,6 +1,6 @@
<?php
define('EXPECTED_CONFIG_VERSION', 26);
- define('SCHEMA_VERSION', 106);
+ define('SCHEMA_VERSION', 107);
$fetch_last_error = false;
$pluginhost = false;
@@ -3214,7 +3214,7 @@
$filter_id = $line["id"];
$result2 = db_query($link, "SELECT
- r.reg_exp, r.feed_id, r.cat_id, r.cat_filter, t.name AS type_name
+ r.reg_exp, r.inverse, r.feed_id, r.cat_id, r.cat_filter, t.name AS type_name
FROM ttrss_filters2_rules AS r,
ttrss_filter_types AS t
WHERE
@@ -3231,6 +3231,7 @@
$rule = array();
$rule["reg_exp"] = $rule_line["reg_exp"];
$rule["type"] = $rule_line["type_name"];
+ $rule["inverse"] = sql_bool_to_bool($rule_line["inverse"]);
array_push($rules, $rule);
}
@@ -3254,6 +3255,7 @@
$filter = array();
$filter["match_any_rule"] = sql_bool_to_bool($line["match_any_rule"]);
+ $filter["inverse"] = sql_bool_to_bool($line["inverse"]);
$filter["rules"] = $rules;
$filter["actions"] = $actions;
@@ -3875,7 +3877,7 @@
$rule['reg_exp'] = db_escape_string($link, $rule['reg_exp']);
- switch ($rule["type"]) {
+ switch ($rule["type"]) {
case "title":
$qpart = "LOWER(ttrss_entries.title) $reg_qpart LOWER('".
$rule['reg_exp'] . "')";
@@ -3923,16 +3925,22 @@
$qpart .= " AND $cat_qpart";
}
+ if (isset($rule['inverse'])) $qpart = "NOT ($qpart)";
+
array_push($query, "($qpart)");
}
}
if (count($query) > 0) {
- return "(" . join($filter["match_any_rule"] ? "OR" : "AND", $query) . ")";
+ $fullquery = "(" . join($filter["match_any_rule"] ? "OR" : "AND", $query) . ")";
} else {
- return "(false)";
+ $fullquery = "(false)";
}
+
+ if ($filter['inverse']) $fullquery = "(NOT $fullquery)";
+
+ return $fullquery;
}
if (!function_exists('gzdecode')) {
diff --git a/include/rssfuncs.php b/include/rssfuncs.php
index 92bfaa023..11aa0e4ba 100644
--- a/include/rssfuncs.php
+++ b/include/rssfuncs.php
@@ -1165,11 +1165,13 @@
foreach ($filters as $filter) {
$match_any_rule = $filter["match_any_rule"];
+ $inverse = $filter["inverse"];
$filter_match = false;
foreach ($filter["rules"] as $rule) {
$match = false;
$reg_exp = $rule["reg_exp"];
+ $rule_inverse = $rule["inverse"];
if (!$reg_exp)
continue;
@@ -1202,6 +1204,8 @@
break;
}
+ if ($rule_inverse) $match = !$match;
+
if ($match_any_rule) {
if ($match) {
$filter_match = true;
@@ -1215,6 +1219,8 @@
}
}
+ if ($inverse) $filter_match = !$filter_match;
+
if ($filter_match) {
foreach ($filter["actions"] AS $action) {
array_push($matches, $action);