]> git.wh0rd.org Git - tt-rss.git/commitdiff
user prefs: add search, misc code cleanup
authorAndrew Dolgov <fox@bah.spb.su>
Sat, 17 May 2008 03:32:36 +0000 (04:32 +0100)
committerAndrew Dolgov <fox@bah.spb.su>
Sat, 17 May 2008 03:32:36 +0000 (04:32 +0100)
modules/pref-filters.php
modules/pref-labels.php
modules/pref-users.php
prefs.js

index fcd04de7330db922d02a451137127857742a3a61..7975e1297db8d3e3dc11db8de51ff28a3b9df91f 100644 (file)
        
                                ++$lnum;
                        }
-       
-                       if ($lnum == 0) {
-                               print "<tr><td colspan=\"4\" align=\"center\">";
-                               if (!$filter_search) {
-                                       print __('No filters defined.');
-                               } else {
-                                       print __('No matching filters found.');
-                               }
-                                       
-                               print "</td></tr>";
-                       }
-       
+
                        print "</table>";
 
                        print "<p id=\"filterOpToolbar\">";
 
                        print "</p>";
 
-
-/*                     print "<div class=\"insensitive\" style=\"float : right\">
-                               First matching filter is used, filtering is performed
-                               when importing articles from the feed.</div>"; */
-
                } else {
 
                        print "<p>";
-
                        if (!$filter_search) {
                                print __('No filters defined.');
                        } else {
                                print __('No matching filters found.');
                        }
-
                        print "</p>";
 
                }
index 617952270ce1af420f14f41d3ed45588dfb12bde..ce326bf01f53194807e23ab9350aa086cdbefacb 100644 (file)
        
                                ++$lnum;
                        }
-       
-                       if ($lnum == 0) {
-                               print "<tr><td colspan=\"4\" align=\"center\">".__('No labels defined.')."</td></tr>";
-                       }
-       
+
                        print "</table>";
        
                        print "<p id=\"labelOpToolbar\">";
                                onclick=\"javascript:removeSelectedLabels()\" value=\"".__('Remove')."\">";
 
                } else {
-                       print "<p>".__('No labels defined.')."</p>";
+                       print "<p>";
+                       if (!$label_search) {
+                               print __('No labels defined.');
+                       } else {
+                               print __('No matching labels found.');
+                       }
+                       print "</p>";
+
                }
        }
 ?>
index 6abd4ca4b794736b7a63b1a67c0685d11bf11b6b..467f3e106480b32f677ea838f5deaa43414ea40a 100644 (file)
 
                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 "<div class=\"feedEditSearch\">
+                       <input id=\"user_search\" size=\"20\" type=\"search\"
+                               onfocus=\"javascript:disableHotkeys();\" 
+                               onblur=\"javascript:enableHotkeys();\"
+                               onchange=\"javascript:updateUsersList()\" value=\"$user_search\">
+                       <input type=\"submit\" class=\"button\" 
+                               onclick=\"javascript:updateUsersList()\" value=\"".__('Search')."\">
+                       </div>";
+
                $sort = db_escape_string($_GET["sort"]);
 
                if (!$sort || $sort == "undefined") {
                        id=\"user_add_btn\" disabled=\"true\"
                        onclick=\"javascript:addUser()\" value=\"".__('Create user')."\"></div>";
 
+               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 "<div id=\"infoBoxShadow\"><div id=\"infoBox\">PLACEHOLDER</div></div>";
 
                print "<p><table width=\"100%\" cellspacing=\"0\" 
                        <input type=\"submit\" class=\"button\" disabled=\"true\"
                                onclick=\"javascript:resetSelectedUserPass()\" value=\"".__('Reset password')."\">";
 
+               } else {
+                       print "<p>";
+                       if (!$user_search) {
+                               print __('No users defined.');
+                       } else {
+                               print __('No matching users found.');
+                       }
+                       print "</p>";
+
+               }
+
        }
 ?>
index d1f3fc075b06a1d584d19fc6516eacf2e9eab55d..58d83f0523fe2f0d30d0ae4953954099afacc761 100644 (file)
--- 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);