diff --git a/backend.php b/backend.php index 941c789a5..a3ba821d1 100644 --- a/backend.php +++ b/backend.php @@ -2094,6 +2094,90 @@ $subop = $_GET["subop"]; $quiet = $_GET["quiet"]; + if ($subop == "edit") { + + $filter_id = db_escape_string($_GET["id"]); + + $result = db_query($link, + "SELECT * FROM ttrss_filters WHERE id = '$filter_id'"); + + $reg_exp = htmlspecialchars(db_unescape_string(db_fetch_result($result, 0, "reg_exp"))); + $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"); + + print "
Filter editor
"; + print "
"; + + print "
"; + + print ""; + print ""; + print ""; + +// print "
Note: filter will only apply to new articles.
"; + + $result = db_query($link, "SELECT id,description + FROM ttrss_filter_types ORDER BY description"); + + $filter_types = array(); + + while ($line = db_fetch_assoc($result)) { + //array_push($filter_types, $line["description"]); + $filter_types[$line["id"]] = $line["description"]; + } + + print ""; + + print " + "; + print ""; + + print ""; + + print "
Match: "; + + print_select_hash("filter_type", $filter_type, $filter_types); + + print "
Feed:"; + + print_feed_select($link, "feed_id", $feed_id); + + print "
Action:"; + + print "
"; + + print "
"; + + print "
"; + + print " "; + + print ""; + + print "
"; + + return; + } + + if ($subop == "editSave") { $reg_exp = db_escape_string(trim($_GET["reg_exp"])); @@ -2134,7 +2218,7 @@ if (!WEB_DEMO_MODE) { $regexp = db_escape_string(trim($_GET["reg_exp"])); - $match_id = db_escape_string(trim($_GET["match_id"])); + $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"]); @@ -2148,7 +2232,7 @@ "INSERT INTO ttrss_filters (reg_exp,filter_type,owner_uid,feed_id, action_id) VALUES - ('$regexp', '$match_id','".$_SESSION["uid"]."', + ('$regexp', '$filter_type','".$_SESSION["uid"]."', $feed_id, '$action_id')"); } } @@ -2226,81 +2310,26 @@ print ""; - $line["regexp"] = htmlspecialchars($line["reg_exp"]); + $line["reg_exp"] = htmlspecialchars(db_unescape_string($line["reg_exp"])); if (!$line["feed_title"]) $line["feed_title"] = "All feeds"; - - if (!$edit_filter_id || $subop != "edit") { - print ""; - print "" . - $line["reg_exp"] . ""; + print "" . + $line["reg_exp"] . ""; - print "" . - $line["feed_title"] . ""; + print "" . + $line["feed_title"] . ""; - print "" . - $line["filter_type_descr"] . ""; + print "" . + $line["filter_type_descr"] . ""; - print "" . - $line["action_description"] . ""; - - } else if ($filter_id != $edit_filter_id) { - - if (!$line["description"]) $line["description"] = "[No description]"; - - print ""; - - print "".$line["reg_exp"].""; - print "".$line["feed_title"].""; - print "".$line["filter_type_descr"].""; - print "".$line["action_description"].""; - - } else { - - print ""; - - print ""; - print ""; - print ""; - - print ""; - - print ""; - - print ""; - print_feed_select($link, "feed_id", $line["feed_id"], "class=\"iedit\""); - print ""; - - print ""; - print_select_hash("filter_type", $line["filter_type"], $filter_types, - "class=\"iedit\""); - print ""; - - print ""; - print ""; - - print ""; - } + print "" . + $line["action_description"] . ""; print ""; @@ -2766,7 +2795,7 @@ onkeyup=\"toggleSubmitNotEmpty(this, 'infobox_submit')\" name=\"reg_exp\" size=\"30\"> "; - print_select_hash("match_id", 1, $filter_types); + print_select_hash("filter_type", 1, $filter_types); print ""; print "Feed:"; diff --git a/functions.php b/functions.php index 73ef85774..0c1a959a7 100644 --- a/functions.php +++ b/functions.php @@ -1601,7 +1601,7 @@ $is_selected = ""; } printf("", - $line["id"], db_unescape_string($line["title"])); + $line["id"], htmlspecialchars(db_unescape_string($line["title"]))); } print ""; @@ -1630,7 +1630,7 @@ $is_selected = ""; } printf("", - $line["id"], $line["title"]); + $line["id"], htmlspecialchars(db_unescape_string($line["title"]))); } print ""; diff --git a/prefs.js b/prefs.js index f9ec1a5b5..d7a616f37 100644 --- a/prefs.js +++ b/prefs.js @@ -1,7 +1,6 @@ var xmlhttp = false; var active_feed_cat = false; -var active_filter = false; var active_label = false; var active_tab = false; var feed_to_expand = false; @@ -54,22 +53,7 @@ function feedlist_callback() { function filterlist_callback() { var container = document.getElementById('prefContent'); if (xmlhttp.readyState == 4) { - container.innerHTML=xmlhttp.responseText; - - if (active_filter) { - var row = document.getElementById("FILRR-" + active_filter); - if (row) { - if (!row.className.match("Selected")) { - row.className = row.className + "Selected"; - } - } - var checkbox = document.getElementById("FICHK-" + active_filter); - - if (checkbox) { - checkbox.checked = true; - } - } notify(""); } } @@ -354,13 +338,12 @@ function editFilter(id) { return } - active_filter = id; + selectTableRowsByIdPrefix('prefFilterList', 'FILRR-', 'FICHK-', false); + selectTableRowById('FILRR-'+id, 'FICHK-'+id, true); - xmlhttp.open("GET", "backend.php?op=pref-filters&subop=edit&id=" + - param_escape(id), true); - xmlhttp.onreadystatechange=filterlist_callback; + xmlhttp.open("GET", "backend.php?op=pref-filters&subop=edit&id=" + param_escape(id), true); + xmlhttp.onreadystatechange=infobox_callback; xmlhttp.send(null); - } function editFeed(feed) { @@ -713,7 +696,6 @@ function userEditCancel() { } selectPrefRows('user', false); // cleanup feed selection - closeInfoBox(); } @@ -723,15 +705,9 @@ function filterEditCancel() { printLockingError(); return } - - active_filter = false; - -// notify("Operation cancelled."); - - xmlhttp.open("GET", "backend.php?op=pref-filters", true); - xmlhttp.onreadystatechange=filterlist_callback; - xmlhttp.send(null); - + + selectPrefRows('filter', false); // cleanup feed selection + closeInfoBox(); } function labelEditSave() { @@ -809,10 +785,10 @@ function filterEditSave() { notify("Saving filter..."); - active_filter = false; - var query = Form.serialize("filter_edit_form"); + closeInfoBox(); + xmlhttp.open("GET", "backend.php?" + query, true); xmlhttp.onreadystatechange=filterlist_callback; xmlhttp.send(null); @@ -1137,7 +1113,6 @@ function selectTab(id, noupdate) { // clean up all current selections, just in case active_feed_cat = false; - active_filter = false; active_label = false; if (id == "feedConfig") {