new filter action: tag article

master
Andrew Dolgov 18 years ago
parent de07b5eee9
commit 073ca0e663

@ -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,6 +464,7 @@
$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"]);
}
}
}

@ -208,7 +208,8 @@
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");
@ -219,7 +220,13 @@
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>";

@ -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 "<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");
@ -72,6 +74,13 @@
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 {
@ -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')");
}
}

@ -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");
}
}

Loading…
Cancel
Save