From 4c9d0490c6a8c724d04c246cd5ba3cf75ec80259 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 26 Aug 2012 12:36:08 +0400 Subject: rework filter dialog to make feed/category selection easier --- classes/pref/filters.php | 89 +++++++++++++++++++++++------------------------- 1 file changed, 42 insertions(+), 47 deletions(-) (limited to 'classes/pref/filters.php') diff --git a/classes/pref/filters.php b/classes/pref/filters.php index 9cd59e96f..1a6c49071 100644 --- a/classes/pref/filters.php +++ b/classes/pref/filters.php @@ -225,8 +225,8 @@ class Pref_Filters extends Handler_Protected { $reg_exp = htmlspecialchars(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"); - $cat_id = db_fetch_result($result, 0, "cat_id"); + $feed_id = (int) db_fetch_result($result, 0, "feed_id"); + $cat_id = (int) db_fetch_result($result, 0, "cat_id"); $action_id = db_fetch_result($result, 0, "action_id"); $action_param = db_fetch_result($result, 0, "action_param"); $filter_param = db_fetch_result($result, 0, "filter_param"); @@ -289,21 +289,11 @@ class Pref_Filters extends Handler_Protected { print __("in") . " "; - $hidden = $cat_filter ? "style='display:none'" : ""; - - print ""; - print_feed_select($this->link, "feed_id", $feed_id, - 'dojoType="dijit.form.FilteringSelect"'); - print ""; - - $hidden = $cat_filter ? "" : "style='display:none'"; - - print ""; - print_feed_cat_select($this->link, "cat_id", $cat_id, + print ""; + print_feed_select($this->link, "feed_id", ($cat_filter) ? "CAT:$cat_id" : $feed_id, 'dojoType="dijit.form.FilteringSelect"'); print ""; - print ""; print "
".__("Perform Action")."
"; @@ -369,14 +359,14 @@ class Pref_Filters extends Handler_Protected { print "
"; - if ($cat_filter) { - $checked = "checked=\"1\""; - } else { - $checked = ""; - } +# if ($cat_filter) { +# $checked = "checked=\"1\""; +# } else { +# $checked = ""; +# } - print " -
"; +# print " +#
"; print ""; print ""; @@ -412,23 +402,25 @@ class Pref_Filters extends Handler_Protected { $action_param_label = db_escape_string($_REQUEST["action_param_label"]); $enabled = checkbox_to_sql_bool(db_escape_string($_REQUEST["enabled"])); $inverse = checkbox_to_sql_bool(db_escape_string($_REQUEST["inverse"])); - $cat_filter = checkbox_to_sql_bool(db_escape_string($_REQUEST["cat_filter"])); - $cat_id = db_escape_string($_REQUEST['cat_id']); # for the time being, no other filters use params anyway... $filter_param = db_escape_string($_REQUEST["filter_date_modifier"]); - if (!$feed_id) { - $feed_id = 'NULL'; + if (strpos($feed_id, "CAT:") === 0) { + $cat_filter = true; + $cat_id = (int) substr($feed_id, 4); + $feed_id = "NULL"; } else { - $feed_id = sprintf("'%s'", db_escape_string($feed_id)); + $cat_filter = false; + $feed_id = (int) $feed_id; + $cat_id = "NULL"; } - if (!$cat_id) { - $cat_id = 'NULL'; - } else { - $cat_id = sprintf("'%d'", db_escape_string($cat_id)); - } + $raw_feed_id = (int) $feed_id; + $raw_cat_id = (int) $cat_id; + + if (!$feed_id) $feed_id = "NULL"; + if (!$cat_id) $feed_id = "NULL"; /* When processing 'assign label' filters, action_param_label dropbox * overrides action_param */ @@ -450,7 +442,7 @@ class Pref_Filters extends Handler_Protected { filter_type = '$filter_type', enabled = $enabled, inverse = $inverse, - cat_filter = $cat_filter, + cat_filter = ".bool_to_sql_bool($cat_filter).", action_param = '$action_param', filter_param = '$filter_param' WHERE id = '$filter_id' AND owner_uid = " . $_SESSION["uid"]); @@ -458,8 +450,7 @@ class Pref_Filters extends Handler_Protected { $this->filter_test($filter_type, $reg_exp, $action_id, $action_param, $filter_param, sql_bool_to_bool($inverse), - (int) $_REQUEST["feed_id"], (int) $_REQUEST['cat_id'], - sql_bool_to_bool($cat_filter)); + $raw_feed_id, $raw_cat_id, $cat_filter); print "
"; print "