summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2017-07-02 20:37:01 +0300
committerAndrew Dolgov <[email protected]>2017-07-02 20:37:01 +0300
commitf5d174bda96ddc41aa3828bf372a2a3d99cc4460 (patch)
tree59fe48af6ddc9c49aae003e3c29b1ac6ec88a490 /include
parente0f51d786f6bb14ab0a349fe167e797e7a5429b4 (diff)
Revert "filters: support matching on multiple feeds/categories"
This reverts commit 0bf7e007bb3a7039ea11601c7f93c6da33604228.
Diffstat (limited to 'include')
-rw-r--r--include/controls.php98
-rw-r--r--include/functions.php73
2 files changed, 22 insertions, 149 deletions
diff --git a/include/controls.php b/include/controls.php
index 0129db501..3ddf4fd9d 100644
--- a/include/controls.php
+++ b/include/controls.php
@@ -70,104 +70,6 @@ function print_radio($id, $default, $true_is, $values, $attributes = "") {
}
}
-function print_feed_multi_select($id, $default_ids = [],
- $attributes = "", $include_all_feeds = true,
- $root_id = false, $nest_level = 0) {
-
- print_r(in_array("CAT:6",$default_ids));
-
- if (!$root_id) {
- print "<select multiple=\true\" id=\"$id\" name=\"$id\" $attributes>";
- if ($include_all_feeds) {
- $is_selected = (in_array("0", $default_ids)) ? "selected=\"1\"" : "";
- print "<option $is_selected value=\"0\">".__('All feeds')."</option>";
- }
- }
-
- if (get_pref('ENABLE_FEED_CATS')) {
-
- if ($root_id)
- $parent_qpart = "parent_cat = '$root_id'";
- else
- $parent_qpart = "parent_cat IS NULL";
-
- $result = db_query("SELECT id,title,
- (SELECT COUNT(id) FROM ttrss_feed_categories AS c2 WHERE
- c2.parent_cat = ttrss_feed_categories.id) AS num_children
- FROM ttrss_feed_categories
- WHERE owner_uid = ".$_SESSION["uid"]." AND $parent_qpart ORDER BY title");
-
- while ($line = db_fetch_assoc($result)) {
-
- for ($i = 0; $i < $nest_level; $i++)
- $line["title"] = " - " . $line["title"];
-
- $is_selected = in_array("CAT:".$line["id"], $default_ids) ? "selected=\"1\"" : "";
-
- printf("<option $is_selected value='CAT:%d'>%s</option>",
- $line["id"], htmlspecialchars($line["title"]));
-
- if ($line["num_children"] > 0)
- print_feed_multi_select($id, $default_ids, $attributes,
- $include_all_feeds, $line["id"], $nest_level+1);
-
- $feed_result = db_query("SELECT id,title FROM ttrss_feeds
- WHERE cat_id = '".$line["id"]."' AND owner_uid = ".$_SESSION["uid"] . " ORDER BY title");
-
- while ($fline = db_fetch_assoc($feed_result)) {
- $is_selected = (in_array($fline["id"], $default_ids)) ? "selected=\"1\"" : "";
-
- $fline["title"] = " + " . $fline["title"];
-
- for ($i = 0; $i < $nest_level; $i++)
- $fline["title"] = " - " . $fline["title"];
-
- printf("<option $is_selected value='%d'>%s</option>",
- $fline["id"], htmlspecialchars($fline["title"]));
- }
- }
-
- if (!$root_id) {
- $is_selected = in_array("CAT:0", $default_ids) ? "selected=\"1\"" : "";
-
- printf("<option $is_selected value='CAT:0'>%s</option>",
- __("Uncategorized"));
-
- $feed_result = db_query("SELECT id,title FROM ttrss_feeds
- WHERE cat_id IS NULL AND owner_uid = ".$_SESSION["uid"] . " ORDER BY title");
-
- while ($fline = db_fetch_assoc($feed_result)) {
- $is_selected = in_array($fline["id"], $default_ids) ? "selected=\"1\"" : "";
-
- $fline["title"] = " + " . $fline["title"];
-
- for ($i = 0; $i < $nest_level; $i++)
- $fline["title"] = " - " . $fline["title"];
-
- printf("<option $is_selected value='%d'>%s</option>",
- $fline["id"], htmlspecialchars($fline["title"]));
- }
- }
-
- } else {
- $result = db_query("SELECT id,title FROM ttrss_feeds
- WHERE owner_uid = ".$_SESSION["uid"]." ORDER BY title");
-
- while ($line = db_fetch_assoc($result)) {
-
- $is_selected = (in_array($line["id"], $default_ids)) ? "selected=\"1\"" : "";
-
- printf("<option $is_selected value='%d'>%s</option>",
- $line["id"], htmlspecialchars($line["title"]));
- }
- }
-
- if (!$root_id) {
- print "</select>";
- }
-}
-
-
function print_feed_select($id, $default_id = "",
$attributes = "", $include_all_feeds = true,
$root_id = false, $nest_level = 0) {
diff --git a/include/functions.php b/include/functions.php
index 4ad6e6394..6ea3e9ff2 100644
--- a/include/functions.php
+++ b/include/functions.php
@@ -1813,26 +1813,20 @@
$result = db_query("SELECT * FROM ttrss_filters2 WHERE
owner_uid = $owner_uid AND enabled = true ORDER BY order_id, title");
- $check_cats = array_merge(
+ $check_cats = join(",", array_merge(
Feeds::getParentCategories($cat_id, $owner_uid),
- [$cat_id]);
-
- $check_cats_str = join(",", $check_cats);
- $check_cats_fullids = array_map(function($a) { return "CAT:$a"; }, $check_cats);
+ array($cat_id)));
while ($line = db_fetch_assoc($result)) {
$filter_id = $line["id"];
- $match_any_rule = sql_bool_to_bool($line["match_any_rule"]);
-
$result2 = db_query("SELECT
- r.reg_exp, r.inverse, r.feed_id, r.cat_id, r.cat_filter, r.match_on, 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
- (match_on IS NOT NULL OR
- (($null_cat_qpart (cat_id IS NULL AND cat_filter = false) OR cat_id IN ($check_cats_str)) AND
- (feed_id IS NULL OR feed_id = '$feed_id'))) AND
+ ($null_cat_qpart (cat_id IS NULL AND cat_filter = false) OR cat_id IN ($check_cats)) AND
+ (feed_id IS NULL OR feed_id = '$feed_id') AND
filter_type = t.id AND filter_id = '$filter_id'");
$rules = array();
@@ -1841,53 +1835,30 @@
while ($rule_line = db_fetch_assoc($result2)) {
# print_r($rule_line);
- if ($rule_line["match_on"]) {
- $match_on = json_decode($rule_line["match_on"], true);
-
- if (in_array("0", $match_on) || in_array($feed_id, $match_on) || count(array_intersect($check_cats_fullids, $match_on)) > 0) {
+ $rule = array();
+ $rule["reg_exp"] = $rule_line["reg_exp"];
+ $rule["type"] = $rule_line["type_name"];
+ $rule["inverse"] = sql_bool_to_bool($rule_line["inverse"]);
- $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);
- } else if (!$match_any_rule) {
- // this filter contains a rule that doesn't match to this feed/category combination
- // thus filter has to be rejected
+ array_push($rules, $rule);
+ }
- $rules = [];
- break;
- }
+ $result2 = db_query("SELECT a.action_param,t.name AS type_name
+ FROM ttrss_filters2_actions AS a,
+ ttrss_filter_actions AS t
+ WHERE
+ action_id = t.id AND filter_id = '$filter_id'");
- } else {
+ while ($action_line = db_fetch_assoc($result2)) {
+ # print_r($action_line);
- $rule = array();
- $rule["reg_exp"] = $rule_line["reg_exp"];
- $rule["type"] = $rule_line["type_name"];
- $rule["inverse"] = sql_bool_to_bool($rule_line["inverse"]);
+ $action = array();
+ $action["type"] = $action_line["type_name"];
+ $action["param"] = $action_line["action_param"];
- array_push($rules, $rule);
- }
+ array_push($actions, $action);
}
- if (count($rules) > 0) {
- $result2 = db_query("SELECT a.action_param,t.name AS type_name
- FROM ttrss_filters2_actions AS a,
- ttrss_filter_actions AS t
- WHERE
- action_id = t.id AND filter_id = '$filter_id'");
-
- while ($action_line = db_fetch_assoc($result2)) {
- # print_r($action_line);
-
- $action = array();
- $action["type"] = $action_line["type_name"];
- $action["param"] = $action_line["action_param"];
-
- array_push($actions, $action);
- }
- }
$filter = array();
$filter["match_any_rule"] = sql_bool_to_bool($line["match_any_rule"]);