$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
$filter["reg_exp"] = $line["reg_exp"];
$filter["action"] = $line["action"];
-
+ $filter["action_param"] = $line["action_param"];
+
array_push($filters[$line["name"]], $filter);
}
// 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;
}
$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");
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"]);
}
}
}
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"]);
}
}
}
$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"]);
}
}
}
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"]);
}
}
}
print "<tr><td>Action:</td>";
- print "<td colspan='2'><select name=\"action_id\">";
+ print "<td colspan='2'><select name=\"action_id\"
+ onchange=\"filterDlgCheckAction(this)\">";
$result = db_query($link, "SELECT id,description FROM ttrss_filter_actions
ORDER BY name");
print "</select>";
- print "</td></tr></table>";
+ print "</td></tr>";
+
+ print "<tr><td>Params:</td>";
+
+ print "<td><input disabled class='iedit' name='action_param'></td></tr>";
+
+ print "</table>";
print "</form>";
$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"));
print "<tr><td>Action:</td>";
- print "<td colspan='2'><select name=\"action_id\">";
+ print "<td colspan='2'><select name=\"action_id\"
+ onchange=\"filterDlgCheckAction(this)\">";
$result = db_query($link, "SELECT id,description FROM ttrss_filter_actions
ORDER BY name");
print "</td></tr>";
+ print "<tr><td>Params:</td>";
+
+ $param_disabled = ($action_id == 4) ? "" : "disabled";
+
+ print "<td><input $param_disabled class='iedit'
+ name=\"action_param\" value=\"$action_param\"></td></tr>";
+
if ($enabled) {
$checked = "checked";
} else {
$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) {
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"]);
}
$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;
$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')");
}
}
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");
+ }
+
+}