diff --git a/functions.php b/functions.php index 5fe75c288..c03264213 100644 --- a/functions.php +++ b/functions.php @@ -450,7 +450,8 @@ $result = db_query($link, "SELECT reg_exp, ttrss_filter_types.name AS name, - ttrss_filter_actions.name AS action + ttrss_filter_actions.name AS action, + action_param FROM ttrss_filters,ttrss_filter_types,ttrss_filter_actions WHERE enabled = true AND owner_uid = $owner_uid AND @@ -463,7 +464,8 @@ $filter["reg_exp"] = $line["reg_exp"]; $filter["action"] = $line["action"]; - + $filter["action_param"] = $line["action_param"]; + array_push($filters[$line["name"]], $filter); } @@ -653,9 +655,12 @@ // error_reporting(0); - $filter_name = get_filter_name($entry_title, $entry_content, + $tuple = get_filter_name($entry_title, $entry_content, $entry_link, $filters); + $filter_name = $tuple[0]; + $filter_param = $tuple[1]; + if ($filter_name == "filter") { continue; } @@ -750,6 +755,19 @@ $entry_tags = $entry_tags[1]; + # check for manual tags + + if ($filter_name == "tag") { + + $manual_tags = trim_array(split(",", $filter_param)); + + foreach ($manual_tags as $tag) { + if (!preg_match("/^[0-9]*$/", $tag)) { + array_push($entry_tags, $tag); + } + } + } + if (count($entry_tags) > 0) { db_query($link, "BEGIN"); @@ -838,7 +856,7 @@ foreach ($filters["title"] as $filter) { $reg_exp = $filter["reg_exp"]; if (preg_match("/$reg_exp/i", $title)) { - return $filter["action"]; + return array($filter["action"], $filter["action_param"]); } } } @@ -847,7 +865,7 @@ foreach ($filters["content"] as $filter) { $reg_exp = $filter["reg_exp"]; if (preg_match("/$reg_exp/i", $content)) { - return $filter["action"]; + return array($filter["action"], $filter["action_param"]); } } } @@ -857,7 +875,7 @@ $reg_exp = $filter["reg_exp"]; if (preg_match("/$reg_exp/i", $title) || preg_match("/$reg_exp/i", $content)) { - return $filter["action"]; + return array($filter["action"], $filter["action_param"]); } } } @@ -867,7 +885,7 @@ foreach ($filters["link"] as $filter) { $reg_exp = $filter["reg_exp"]; if (preg_match("/$reg_exp/i", $link)) { - return $filter["action"]; + return array($filter["action"], $filter["action_param"]); } } } diff --git a/modules/popup-dialog.php b/modules/popup-dialog.php index 459b3b3e9..5549a2d79 100644 --- a/modules/popup-dialog.php +++ b/modules/popup-dialog.php @@ -208,7 +208,8 @@ print "Action:"; - print ""; $result = db_query($link, "SELECT id,description FROM ttrss_filter_actions ORDER BY name"); @@ -219,7 +220,13 @@ print ""; - print ""; + print ""; + + print "Params:"; + + print ""; + + print ""; print ""; diff --git a/modules/pref-filters.php b/modules/pref-filters.php index 0570b7ac5..610e3dcd0 100644 --- a/modules/pref-filters.php +++ b/modules/pref-filters.php @@ -14,6 +14,7 @@ $filter_type = db_fetch_result($result, 0, "filter_type"); $feed_id = db_fetch_result($result, 0, "feed_id"); $action_id = db_fetch_result($result, 0, "action_id"); + $action_param = db_fetch_result($result, 0, "action_param"); $enabled = sql_bool_to_bool(db_fetch_result($result, 0, "enabled")); @@ -58,7 +59,8 @@ print "Action:"; - print ""; $result = db_query($link, "SELECT id,description FROM ttrss_filter_actions ORDER BY name"); @@ -72,6 +74,13 @@ print ""; + print "Params:"; + + $param_disabled = ($action_id == 4) ? "" : "disabled"; + + print ""; + if ($enabled) { $checked = "checked"; } else { @@ -110,6 +119,7 @@ $filter_id = db_escape_string($_GET["id"]); $feed_id = db_escape_string($_GET["feed_id"]); $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"])); if (!$feed_id) { @@ -123,7 +133,8 @@ feed_id = $feed_id, action_id = '$action_id', filter_type = '$filter_type', - enabled = $enabled + enabled = $enabled, + action_param = '$action_param' WHERE id = '$filter_id' AND owner_uid = " . $_SESSION["uid"]); } @@ -148,6 +159,7 @@ $filter_type = db_escape_string(trim($_GET["filter_type"])); $feed_id = db_escape_string($_GET["feed_id"]); $action_id = db_escape_string($_GET["action_id"]); + $action_param = db_escape_string($_GET["action_param"]); if (!$regexp) return; @@ -159,10 +171,10 @@ $result = db_query($link, "INSERT INTO ttrss_filters (reg_exp,filter_type,owner_uid,feed_id, - action_id) + action_id, action_param) VALUES ('$regexp', '$filter_type','".$_SESSION["uid"]."', - $feed_id, '$action_id')"); + $feed_id, '$action_id', '$action_param')"); } } diff --git a/prefs.js b/prefs.js index 6b772b1cd..37b738358 100644 --- a/prefs.js +++ b/prefs.js @@ -1548,3 +1548,40 @@ function editFeedCats() { function showFeedsWithErrors() { displayDlg('feedUpdateErrors'); } + +function filterDlgCheckAction(sender) { + + try { + + var action = sender[sender.selectedIndex].value; + + var form = document.forms["filter_add_form"]; + + if (!form) { + form = document.forms["filter_edit_form"]; + } + + if (!form) { + debug("filterDlgCheckAction: can't find form!"); + return; + } + + var action_param = form.action_param; + + if (!action_param) { + debug("filterDlgCheckAction: can't find action param!"); + return; + } + + // if selected action supports parameters, enable params field + if (action == 4) { + action_param.disabled = false; + } else { + action_param.disabled = true; + } + + } catch (e) { + exception_error(e, "filterDlgCheckAction"); + } + +}