add support for inverse filters
This commit is contained in:
parent
3f2ff803b3
commit
c2d9322b7f
|
@ -415,6 +415,7 @@
|
||||||
$result = db_query($link, "SELECT reg_exp,
|
$result = db_query($link, "SELECT reg_exp,
|
||||||
ttrss_filter_types.name AS name,
|
ttrss_filter_types.name AS name,
|
||||||
ttrss_filter_actions.name AS action,
|
ttrss_filter_actions.name AS action,
|
||||||
|
inverse,
|
||||||
action_param
|
action_param
|
||||||
FROM ttrss_filters,ttrss_filter_types,ttrss_filter_actions WHERE
|
FROM ttrss_filters,ttrss_filter_types,ttrss_filter_actions WHERE
|
||||||
enabled = true AND
|
enabled = true AND
|
||||||
|
@ -429,6 +430,7 @@
|
||||||
$filter["reg_exp"] = $line["reg_exp"];
|
$filter["reg_exp"] = $line["reg_exp"];
|
||||||
$filter["action"] = $line["action"];
|
$filter["action"] = $line["action"];
|
||||||
$filter["action_param"] = $line["action_param"];
|
$filter["action_param"] = $line["action_param"];
|
||||||
|
$filter["inverse"] = sql_bool_to_bool($line["inverse"]);
|
||||||
|
|
||||||
array_push($filters[$line["name"]], $filter);
|
array_push($filters[$line["name"]], $filter);
|
||||||
}
|
}
|
||||||
|
@ -841,7 +843,10 @@
|
||||||
if ($filters["title"]) {
|
if ($filters["title"]) {
|
||||||
foreach ($filters["title"] as $filter) {
|
foreach ($filters["title"] as $filter) {
|
||||||
$reg_exp = $filter["reg_exp"];
|
$reg_exp = $filter["reg_exp"];
|
||||||
if (preg_match("/$reg_exp/i", $title)) {
|
$inverse = $filter["inverse"];
|
||||||
|
if ((!$inverse && preg_match("/$reg_exp/i", $title)) ||
|
||||||
|
($inverse && !preg_match("/$reg_exp/i", $title))) {
|
||||||
|
|
||||||
array_push($matches, array($filter["action"], $filter["action_param"]));
|
array_push($matches, array($filter["action"], $filter["action_param"]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -850,7 +855,11 @@
|
||||||
if ($filters["content"]) {
|
if ($filters["content"]) {
|
||||||
foreach ($filters["content"] as $filter) {
|
foreach ($filters["content"] as $filter) {
|
||||||
$reg_exp = $filter["reg_exp"];
|
$reg_exp = $filter["reg_exp"];
|
||||||
if (preg_match("/$reg_exp/i", $content)) {
|
$inverse = $filter["inverse"];
|
||||||
|
|
||||||
|
if ((!$inverse && preg_match("/$reg_exp/i", $content)) ||
|
||||||
|
($inverse && !preg_match("/$reg_exp/i", $content))) {
|
||||||
|
|
||||||
array_push($matches, array($filter["action"], $filter["action_param"]));
|
array_push($matches, array($filter["action"], $filter["action_param"]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -859,17 +868,29 @@
|
||||||
if ($filters["both"]) {
|
if ($filters["both"]) {
|
||||||
foreach ($filters["both"] as $filter) {
|
foreach ($filters["both"] as $filter) {
|
||||||
$reg_exp = $filter["reg_exp"];
|
$reg_exp = $filter["reg_exp"];
|
||||||
|
$inverse = $filter["inverse"];
|
||||||
|
|
||||||
|
if ($inverse) {
|
||||||
|
if (!preg_match("/$reg_exp/i", $title) || !preg_match("/$reg_exp/i", $content)) {
|
||||||
|
array_push($matches, array($filter["action"], $filter["action_param"]));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
if (preg_match("/$reg_exp/i", $title) || preg_match("/$reg_exp/i", $content)) {
|
if (preg_match("/$reg_exp/i", $title) || preg_match("/$reg_exp/i", $content)) {
|
||||||
array_push($matches, array($filter["action"], $filter["action_param"]));
|
array_push($matches, array($filter["action"], $filter["action_param"]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($filters["link"]) {
|
if ($filters["link"]) {
|
||||||
$reg_exp = $filter["reg_exp"];
|
$reg_exp = $filter["reg_exp"];
|
||||||
foreach ($filters["link"] as $filter) {
|
foreach ($filters["link"] as $filter) {
|
||||||
$reg_exp = $filter["reg_exp"];
|
$reg_exp = $filter["reg_exp"];
|
||||||
if (preg_match("/$reg_exp/i", $link)) {
|
$inverse = $filter["inverse"];
|
||||||
|
|
||||||
|
if ((!$inverse && preg_match("/$reg_exp/i", $link)) ||
|
||||||
|
($inverse && !preg_match("/$reg_exp/i", $link))) {
|
||||||
|
|
||||||
array_push($matches, array($filter["action"], $filter["action_param"]));
|
array_push($matches, array($filter["action"], $filter["action_param"]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue