From: Andrew Dolgov Date: Mon, 21 Nov 2005 13:49:15 +0000 (+0100) Subject: per-feed filters X-Git-Tag: schema_feature_freeze_for_1.1~146 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=ead60402dd05a65f06e2d0fb5b59462df9c6c388;p=tt-rss.git per-feed filters --- diff --git a/backend.php b/backend.php index f1a3f75c..2bc775bd 100644 --- a/backend.php +++ b/backend.php @@ -1165,10 +1165,18 @@ $descr = db_escape_string($_GET["d"]); $match = db_escape_string($_GET["m"]); $filter_id = db_escape_string($_GET["id"]); + $feed_id = db_escape_string($_GET["fid"]); + + if (!$feed_id) { + $feed_id = 'NULL'; + } else { + $feed_id = sprintf("'%s'", db_escape_string($feed_id)); + } $result = db_query($link, "UPDATE ttrss_filters SET reg_exp = '$regexp', description = '$descr', + feed_id = $feed_id, filter_type = (SELECT id FROM ttrss_filter_types WHERE description = '$match') WHERE id = '$filter_id'"); @@ -1193,11 +1201,18 @@ $regexp = db_escape_string(trim($_GET["regexp"])); $match = db_escape_string(trim($_GET["match"])); + $feed_id = db_escape_string($_GET["fid"]); + + if (!$feed_id) { + $feed_id = 'NULL'; + } else { + $feed_id = sprintf("'%s'", db_escape_string($feed_id)); + } $result = db_query($link, - "INSERT INTO ttrss_filters (reg_exp,filter_type,owner_uid) VALUES + "INSERT INTO ttrss_filters (reg_exp,filter_type,owner_uid,feed_id) VALUES ('$regexp', (SELECT id FROM ttrss_filter_types WHERE - description = '$match'),'".$_SESSION["uid"]."')"); + description = '$match'),'".$_SESSION["uid"]."', $feed_id)"); } } @@ -1213,29 +1228,49 @@ print "
"; - print_select("fadd_match", "Title", $filter_types); + print_select("fadd_match", "Title", $filter_types); + + print " "; print" Add filter
"; $result = db_query($link, "SELECT - id,reg_exp,description, - (SELECT name FROM ttrss_filter_types WHERE - id = filter_type) as filter_type_name, - (SELECT description FROM ttrss_filter_types - WHERE id = filter_type) as filter_type_descr + ttrss_filters.id AS id,reg_exp, + ttrss_filters.description AS description, + ttrss_filter_types.name AS filter_type_name, + ttrss_filter_types.description AS filter_type_descr, + feed_id, + (SELECT title FROM ttrss_feeds WHERE id = feed_id) AS feed_title FROM - ttrss_filters + ttrss_filters,ttrss_filter_types WHERE - owner_uid = ".$_SESSION["uid"]." + filter_type = ttrss_filter_types.id AND + ttrss_filters.owner_uid = ".$_SESSION["uid"]." ORDER by reg_exp"); print "

"; print " - - "; + + + "; $lnum = 0; @@ -1255,6 +1290,8 @@ $line["regexp"] = htmlspecialchars($line["reg_exp"]); $line["description"] = htmlspecialchars($line["description"]); + if (!$line["feed_title"]) $line["feed_title"] = "All feeds"; + if (!$edit_filter_id || $subop != "edit") { if (!$line["description"]) $line["description"] = "[No description]"; @@ -1268,7 +1305,11 @@ print ""; - print ""; + print ""; + + print ""; } else if ($filter_id != $edit_filter_id) { @@ -1280,6 +1321,7 @@ print ""; print ""; print ""; + print ""; } else { @@ -1294,9 +1336,34 @@ print ""; - + + print ""; } - print ""; diff --git a/functions.php b/functions.php index f1c56e98..b9f33f2f 100644 --- a/functions.php +++ b/functions.php @@ -217,7 +217,9 @@ $result = db_query($link, "SELECT reg_exp, (SELECT name FROM ttrss_filter_types WHERE id = filter_type) as name - FROM ttrss_filters WHERE owner_uid = $owner_uid"); + FROM ttrss_filters WHERE + owner_uid = $owner_uid AND + (feed_id IS NULL OR feed_id = '$feed')"); while ($line = db_fetch_assoc($result)) { if (!$filters[$line["name"]]) $filters[$line["name"]] = array(); diff --git a/prefs.js b/prefs.js index 4f3786fc..aa1e6aee 100644 --- a/prefs.js +++ b/prefs.js @@ -247,6 +247,7 @@ function addFilter() { var regexp = document.getElementById("fadd_regexp"); var match = document.getElementById("fadd_match"); + var feed = document.getElementById("fadd_feed"); if (regexp.value.length == 0) { notify("Missing filter expression."); @@ -255,8 +256,11 @@ function addFilter() { var v_match = match[match.selectedIndex].text; + var feed_id = feed[feed.selectedIndex].id; + xmlhttp.open("GET", "backend.php?op=pref-filters&subop=add®exp=" + - param_escape(regexp.value) + "&match=" + v_match, true); + param_escape(regexp.value) + "&match=" + v_match + + "&fid=" + param_escape(feed_id), true); xmlhttp.onreadystatechange=filterlist_callback; xmlhttp.send(null); @@ -794,9 +798,12 @@ function filterEditSave() { var regexp = document.getElementById("iedit_regexp").value; var descr = document.getElementById("iedit_descr").value; var match = document.getElementById("iedit_match"); - + var v_match = match[match.selectedIndex].text; + var feed = document.getElementById("iedit_feed"); + var feed_id = feed[feed.selectedIndex].id; + // notify("Saving filter " + filter + ": " + regexp + ", " + descr + ", " + match); if (regexp.length == 0) { @@ -808,7 +815,7 @@ function filterEditSave() { xmlhttp.open("GET", "backend.php?op=pref-filters&subop=editSave&id=" + filter + "&r=" + param_escape(regexp) + "&d=" + param_escape(descr) + - "&m=" + param_escape(v_match), true); + "&m=" + param_escape(v_match) + "&fid=" + param_escape(feed_id), true); notify(""); diff --git a/tt-rss.css b/tt-rss.css index cf9aeea3..1a91a5e2 100644 --- a/tt-rss.css +++ b/tt-rss.css @@ -245,7 +245,7 @@ a:hover { } #iedit_title, #iedit_link, #iedit_regexp, #iedit_descr, #iedit_expr, #iedit_updintl, -#iedit_purgintl, #iedit_ulogin, #iedit_ulevel { +#iedit_purgintl, #iedit_ulogin, #iedit_ulevel, #iedit_match, #iedit_feed { width : 100%; padding-left : 2px; }
SelectFilter expressionDescriptionMatch
SelectFilter expressionDescriptionMatchFeed
" . $line["description"] . "".$line["filter_type_descr"]."" . + $line["filter_type_descr"] . "" . + $line["feed_title"] . "".$line["reg_exp"]."".$line["description"]."".$line["filter_type_descr"]."".$line["feed_title"].""; print_select("iedit_match", $line["filter_type_descr"], $filter_types); print ""; + + print ""; + + print "