From a5bd7bf051e2d547fc0aed78ba231588d44291ce Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sat, 17 May 2008 04:32:36 +0100 Subject: [PATCH] user prefs: add search, misc code cleanup --- modules/pref-filters.php | 20 +------------------- modules/pref-labels.php | 15 +++++++++------ modules/pref-users.php | 39 +++++++++++++++++++++++++++++++++++++++ prefs.js | 7 ++++++- 4 files changed, 55 insertions(+), 26 deletions(-) diff --git a/modules/pref-filters.php b/modules/pref-filters.php index fcd04de7..7975e129 100644 --- a/modules/pref-filters.php +++ b/modules/pref-filters.php @@ -396,18 +396,7 @@ ++$lnum; } - - if ($lnum == 0) { - print ""; - if (!$filter_search) { - print __('No filters defined.'); - } else { - print __('No matching filters found.'); - } - - print ""; - } - + print ""; print "

"; @@ -419,21 +408,14 @@ print "

"; - -/* print "
- First matching filter is used, filtering is performed - when importing articles from the feed.
"; */ - } else { print "

"; - if (!$filter_search) { print __('No filters defined.'); } else { print __('No matching filters found.'); } - print "

"; } diff --git a/modules/pref-labels.php b/modules/pref-labels.php index 61795227..ce326bf0 100644 --- a/modules/pref-labels.php +++ b/modules/pref-labels.php @@ -314,11 +314,7 @@ ++$lnum; } - - if ($lnum == 0) { - print "".__('No labels defined.').""; - } - + print ""; print "

"; @@ -329,7 +325,14 @@ onclick=\"javascript:removeSelectedLabels()\" value=\"".__('Remove')."\">"; } else { - print "

".__('No labels defined.')."

"; + print "

"; + if (!$label_search) { + print __('No labels defined.'); + } else { + print __('No matching labels found.'); + } + print "

"; + } } ?> diff --git a/modules/pref-users.php b/modules/pref-users.php index 6abd4ca4..467f3e10 100644 --- a/modules/pref-users.php +++ b/modules/pref-users.php @@ -184,6 +184,23 @@ set_pref($link, "_PREFS_ACTIVE_TAB", "userConfig"); + $user_search = db_escape_string($_GET["search"]); + + if (array_key_exists("search", $_GET)) { + $_SESSION["prefs_user_search"] = $user_search; + } else { + $user_search = $_SESSION["prefs_user_search"]; + } + + print "
+ + +
"; + $sort = db_escape_string($_GET["sort"]); if (!$sort || $sort == "undefined") { @@ -200,13 +217,24 @@ id=\"user_add_btn\" disabled=\"true\" onclick=\"javascript:addUser()\" value=\"".__('Create user')."\">"; + if ($user_search) { + $user_search_query = "UPPER(login) LIKE UPPER('%$user_search%') AND"; + } else { + $user_search_query = ""; + } + $result = db_query($link, "SELECT id,login,access_level,email, ".SUBSTRING_FOR_DATE."(last_login,1,16) as last_login FROM ttrss_users + WHERE + $user_search_query + id > 0 ORDER BY $sort"); + if (db_num_rows($result) > 0) { + // print "
PLACEHOLDER
"; print "

"; + } else { + print "

"; + if (!$user_search) { + print __('No users defined.'); + } else { + print __('No matching users found.'); + } + print "

"; + + } + } ?> diff --git a/prefs.js b/prefs.js index d1f3fc07..58d83f05 100644 --- a/prefs.js +++ b/prefs.js @@ -285,8 +285,13 @@ function updateUsersList(sort_key) { return } + var user_search = document.getElementById("user_search"); + var search = ""; + if (user_search) { search = user_search.value; } + xmlhttp.open("GET", "backend.php?op=pref-users&sort=" - + param_escape(sort_key), true); + + param_escape(sort_key) + + "&search=" + param_escape(search), true); xmlhttp.onreadystatechange=userlist_callback; xmlhttp.send(null); -- 2.39.5