From dad60045b60d7a622bb23d34d808fc1d03a91b90 Mon Sep 17 00:00:00 2001 From: Suhaib Khan Date: Thu, 6 Feb 2014 18:32:59 +0530 Subject: [PATCH 01/19] [ticket/10737] Adding username suggestions in "Find a member" using AJAX PHPBB3-10737 --- phpBB/memberlist.php | 44 +++++++++++++++++-- .../prosilver/template/memberlist_search.html | 37 +++++++++++++++- phpBB/styles/prosilver/theme/common.css | 11 +++++ .../template/memberlist_search.html | 37 +++++++++++++++- phpBB/styles/subsilver2/theme/stylesheet.css | 8 ++++ 5 files changed, 132 insertions(+), 5 deletions(-) diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index 8fceb4ac5b..1c786c0a1a 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -40,7 +40,7 @@ if ($mode == 'leaders') } // Check our mode... -if (!in_array($mode, array('', 'group', 'viewprofile', 'email', 'contact', 'searchuser', 'team'))) +if (!in_array($mode, array('', 'group', 'viewprofile', 'email', 'contact', 'searchuser', 'team', 'livesearch'))) { trigger_error('NO_MODE'); } @@ -980,7 +980,44 @@ switch ($mode) ); break; - + + case 'livesearch': + $q=request_var('q',''); + $hint=""; + // Get us some users :D + $sql = "SELECT u.user_id + FROM " . USERS_TABLE . " u + WHERE u.user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ")"; + + $result = $db->sql_query($sql); + $user_list = array(); + while ($row = $db->sql_fetchrow($result)) + { + $user_list[] = (int) $row['user_id']; + } + $db->sql_freeresult($result); + $sql = 'SELECT * + FROM ' . USERS_TABLE . ' + WHERE ' . $db->sql_in_set('user_id', $user_list); + $result = $db->sql_query($sql); + $i=1; + while ($row = $db->sql_fetchrow($result)) + { $j=($i%2)+1; + if(stripos($row['username'],$q)===0) + { + $hint.="" . + $row['username'] . ""; + $i++; + } + else + $hint.=""; + } + echo $hint; + exit(); + break; + case 'group': default: // The basic memberlist @@ -1456,7 +1493,8 @@ switch ($mode) 'S_JOINED_TIME_OPTIONS' => $s_find_join_time, 'S_ACTIVE_TIME_OPTIONS' => $s_find_active_time, 'S_GROUP_SELECT' => $s_group_select, - 'S_USER_SEARCH_ACTION' => append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=searchuser&form=$form&field=$field")) + 'S_USER_SEARCH_ACTION' => append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=searchuser&form=$form&field=$field"), + 'S_LIVE_SEARCH_ACTION' => append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=livesearch", $is_amp = false)) ); } diff --git a/phpBB/styles/prosilver/template/memberlist_search.html b/phpBB/styles/prosilver/template/memberlist_search.html index ee89b103b5..c46b94f102 100644 --- a/phpBB/styles/prosilver/template/memberlist_search.html +++ b/phpBB/styles/prosilver/template/memberlist_search.html @@ -1,3 +1,38 @@ + +

{L_FIND_USERNAME}

@@ -9,7 +44,7 @@
-
+
diff --git a/phpBB/styles/prosilver/theme/common.css b/phpBB/styles/prosilver/theme/common.css index 3d5a0a433d..c8eb5da9a6 100644 --- a/phpBB/styles/prosilver/theme/common.css +++ b/phpBB/styles/prosilver/theme/common.css @@ -940,6 +940,17 @@ li.pagination ul { z-index: 51; } +/* Live search box */ +#livesearch { + width: 30%; + margin: 0px; + position: absolute; + background-color: #12A3EB; + box-shadow: 1px 2px 5px rgb(175,167,167); + z-index: 999; + overflow: auto; +} + /* Miscellaneous styles ---------------------------------------- */ #forum-permissions { diff --git a/phpBB/styles/subsilver2/template/memberlist_search.html b/phpBB/styles/subsilver2/template/memberlist_search.html index aa6b61fe22..af320d4bd8 100644 --- a/phpBB/styles/subsilver2/template/memberlist_search.html +++ b/phpBB/styles/subsilver2/template/memberlist_search.html @@ -64,6 +64,41 @@ + + @@ -75,7 +110,7 @@ - + diff --git a/phpBB/styles/subsilver2/theme/stylesheet.css b/phpBB/styles/subsilver2/theme/stylesheet.css index 0bffc33f37..ef18e22ccb 100644 --- a/phpBB/styles/subsilver2/theme/stylesheet.css +++ b/phpBB/styles/subsilver2/theme/stylesheet.css @@ -703,6 +703,14 @@ pre { font-weight: bold; } +#livesearch { + width: 35%; + margin: 0px; + position: absolute; + box-shadow: 1px 2px 5px rgb(175,167,167); + z-index: 999; + overflow: auto; +} /* Former imageset */ span.imageset { From bc67377400ad11470fb1975af1e07b136f07a24d Mon Sep 17 00:00:00 2001 From: Suhaib Khan Date: Thu, 6 Feb 2014 22:18:48 +0530 Subject: [PATCH 02/19] [ticket/10737] Improvements over last commit PHPBB3-10737 --- phpBB/memberlist.php | 40 ++++++------------- .../prosilver/template/memberlist_search.html | 28 ++++--------- .../template/memberlist_search.html | 28 ++++--------- 3 files changed, 28 insertions(+), 68 deletions(-) diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index 1c786c0a1a..c2a995da4c 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -982,37 +982,21 @@ switch ($mode) break; case 'livesearch': - $q=request_var('q',''); + $q=request_var('q', '', true); $hint=""; - // Get us some users :D - $sql = "SELECT u.user_id - FROM " . USERS_TABLE . " u - WHERE u.user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ")"; - - $result = $db->sql_query($sql); - $user_list = array(); - while ($row = $db->sql_fetchrow($result)) - { - $user_list[] = (int) $row['user_id']; - } - $db->sql_freeresult($result); - $sql = 'SELECT * - FROM ' . USERS_TABLE . ' - WHERE ' . $db->sql_in_set('user_id', $user_list); + $sql = "SELECT username, user_id + FROM " . USERS_TABLE . " u + WHERE username LIKE '".$q."%' AND u.user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ")"; $result = $db->sql_query($sql); $i=1; - while ($row = $db->sql_fetchrow($result)) - { $j=($i%2)+1; - if(stripos($row['username'],$q)===0) - { - $hint.=""; - $i++; - } - else - $hint.=""; + while ($i<=10 && $row = $db->sql_fetchrow($result)) + { + $j=($i%2)+1; + $hint.=""; + $i++; } echo $hint; exit(); diff --git a/phpBB/styles/prosilver/template/memberlist_search.html b/phpBB/styles/prosilver/template/memberlist_search.html index c46b94f102..4e28c26d3a 100644 --- a/phpBB/styles/prosilver/template/memberlist_search.html +++ b/phpBB/styles/prosilver/template/memberlist_search.html @@ -1,30 +1,18 @@ @@ -32,7 +30,7 @@
-
{L_USERNAME}{L_COLON}
{L_EMAIL}{L_COLON}
" . - $row['username'] . "
" . + $row['username'] . "
+
diff --git a/phpBB/styles/subsilver2/template/memberlist_search.html b/phpBB/styles/subsilver2/template/memberlist_search.html index 868d515a9f..ba72e4ee8d 100644 --- a/phpBB/styles/subsilver2/template/memberlist_search.html +++ b/phpBB/styles/subsilver2/template/memberlist_search.html @@ -65,25 +65,23 @@ @@ -98,7 +96,7 @@ {L_USERNAME}{L_COLON} -
+
{L_EMAIL}{L_COLON} From dd07efcac7f4e9eed20b3c65047019aff694a9d7 Mon Sep 17 00:00:00 2001 From: Suhaib Khan Date: Fri, 21 Feb 2014 13:01:22 +0530 Subject: [PATCH 04/19] [ticket/10737] Using JQuery events and JSON response. PHPBB3-10737 --- phpBB/assets/javascript/core.js | 26 +++++++++++++++++++ phpBB/memberlist.php | 11 ++++---- .../prosilver/template/memberlist_search.html | 23 +--------------- .../template/memberlist_search.html | 23 +--------------- 4 files changed, 33 insertions(+), 50 deletions(-) diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js index ac866f7c78..c2291c7001 100644 --- a/phpBB/assets/javascript/core.js +++ b/phpBB/assets/javascript/core.js @@ -512,6 +512,32 @@ phpbb.timezonePreselectSelect = function(forceSelector) { } }; +// Listen live search box events +$('.liveinput').keyup(function() { + var str = this.value; + var j = 0; + if (str.length < 3) { + $("#livesearch").innerHTML=""; + return; + } + + $.ajax({ + url:'memberlist.php?mode=livesearch&'+"&q="+str, + success:function(result) { + $.each(result, function(idx, elem) { + j = (idx%2)+1; + $("#livesearch").append("" + elem.name + ""); + }) + } + }); +}); + +$('.liveinput').blur(function() { + setTimeout(function () { + document.getElementById("livesearch").innerHTML=""; + }, 500); +}); + // Toggle notification list $('#notification_list_button').click(function(e) { $('#notification_list').toggle(); diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index d2ba27559c..748b2548c9 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -983,7 +983,6 @@ switch ($mode) case 'livesearch': $username_chars = $request->variable('q', '', true); - $hint = ""; $sql = 'SELECT username, user_id FROM ' . USERS_TABLE . ' @@ -991,17 +990,17 @@ switch ($mode) AND username ' . $db->sql_like_expression($username_chars . $db->any_char); $result = $db->sql_query_limit($sql, 10); + $user_list = array(); $i = 1; while ($row = $db->sql_fetchrow($result)) { $j = ($i%2)+1; - $hint.= "" . - $row['username'] . ""; + $user_list[] = array("id" => $row['user_id'], "name" => $row['username']); $i++; } - echo $hint; + + $json_response = new \phpbb\json_response(); + echo $json_response->send($user_list); exit(); break; diff --git a/phpBB/styles/prosilver/template/memberlist_search.html b/phpBB/styles/prosilver/template/memberlist_search.html index 59b7b0a5a7..15f44bf2e5 100644 --- a/phpBB/styles/prosilver/template/memberlist_search.html +++ b/phpBB/styles/prosilver/template/memberlist_search.html @@ -1,24 +1,3 @@ - -

{L_FIND_USERNAME}

@@ -30,7 +9,7 @@
-
+
diff --git a/phpBB/styles/subsilver2/template/memberlist_search.html b/phpBB/styles/subsilver2/template/memberlist_search.html index ba72e4ee8d..5ebff93320 100644 --- a/phpBB/styles/subsilver2/template/memberlist_search.html +++ b/phpBB/styles/subsilver2/template/memberlist_search.html @@ -64,27 +64,6 @@ - - @@ -96,7 +75,7 @@ - + From e644c67dcf4a505759533c42e0c511fab93028ae Mon Sep 17 00:00:00 2001 From: Suhaib Khan Date: Fri, 21 Feb 2014 14:04:48 +0530 Subject: [PATCH 05/19] [ticket/10737] Removing unnecessary/obsolete code. PHPBB3-10737 --- phpBB/memberlist.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index 748b2548c9..67e168e7bb 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -1479,8 +1479,7 @@ switch ($mode) 'S_JOINED_TIME_OPTIONS' => $s_find_join_time, 'S_ACTIVE_TIME_OPTIONS' => $s_find_active_time, 'S_GROUP_SELECT' => $s_group_select, - 'S_USER_SEARCH_ACTION' => append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=searchuser&form=$form&field=$field"), - 'S_LIVE_SEARCH_ACTION' => append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=livesearch", $is_amp = false)) + 'S_USER_SEARCH_ACTION' => append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=searchuser&form=$form&field=$field")) ); } From aa23cf64cae6710f556c8d43528d28cff6d6a775 Mon Sep 17 00:00:00 2001 From: Suhaib Khan Date: Sun, 23 Feb 2014 00:22:52 +0530 Subject: [PATCH 06/19] [ticket/10737] Avoid hard-coding table row and use case-insensitive search. PHPBB3-10737 --- phpBB/assets/javascript/core.js | 28 ++++++++++++------- phpBB/memberlist.php | 3 +- .../prosilver/template/memberlist_search.html | 8 +++++- .../template/memberlist_search.html | 9 +++++- phpBB/styles/subsilver2/theme/stylesheet.css | 1 + 5 files changed, 36 insertions(+), 13 deletions(-) diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js index c2291c7001..82c78ae715 100644 --- a/phpBB/assets/javascript/core.js +++ b/phpBB/assets/javascript/core.js @@ -515,26 +515,34 @@ phpbb.timezonePreselectSelect = function(forceSelector) { // Listen live search box events $('.liveinput').keyup(function() { var str = this.value; - var j = 0; if (str.length < 3) { - $("#livesearch").innerHTML=""; - return; - } - + return; + } + var link, name; + var clone = $("#user-search-row-tpl").clone(); + $("#livesearch").html(""); + clone.appendTo("#livesearch"); $.ajax({ url:'memberlist.php?mode=livesearch&'+"&q="+str, success:function(result) { $.each(result, function(idx, elem) { - j = (idx%2)+1; - $("#livesearch").append(""); - }) - } + link = "memberlist.php?mode=viewprofile&u=" + elem.id; + name = elem.name; + clone = $("#user-search-row-tpl").clone(); + clone.find(".user-search-link").attr("href", link); + clone.find(".user-search-name").html(name); + clone.attr("style", ""); + clone.appendTo("#livesearch"); + }); + } }); }); $('.liveinput').blur(function() { setTimeout(function () { - document.getElementById("livesearch").innerHTML=""; + var clone = $("#user-search-row-tpl").clone(); + $("#livesearch").html(""); + clone.appendTo("#livesearch"); }, 500); }); diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index 67e168e7bb..7cea4a59d7 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -983,11 +983,12 @@ switch ($mode) case 'livesearch': $username_chars = $request->variable('q', '', true); + $username_chars = strtolower($username_chars); $sql = 'SELECT username, user_id FROM ' . USERS_TABLE . ' WHERE ' . $db->sql_in_set('user_type', array(USER_NORMAL, USER_FOUNDER)) . ' - AND username ' . $db->sql_like_expression($username_chars . $db->any_char); + AND LOWER(username) ' . $db->sql_like_expression($username_chars . $db->any_char); $result = $db->sql_query_limit($sql, 10); $user_list = array(); diff --git a/phpBB/styles/prosilver/template/memberlist_search.html b/phpBB/styles/prosilver/template/memberlist_search.html index 15f44bf2e5..e407aed616 100644 --- a/phpBB/styles/prosilver/template/memberlist_search.html +++ b/phpBB/styles/prosilver/template/memberlist_search.html @@ -9,7 +9,13 @@
-
{L_USERNAME}{L_COLON}
{L_EMAIL}{L_COLON}
" + elem.name + "
+
+ + + + +
+
diff --git a/phpBB/styles/subsilver2/template/memberlist_search.html b/phpBB/styles/subsilver2/template/memberlist_search.html index 5ebff93320..1ee4abccd4 100644 --- a/phpBB/styles/subsilver2/template/memberlist_search.html +++ b/phpBB/styles/subsilver2/template/memberlist_search.html @@ -75,7 +75,14 @@ {L_USERNAME}{L_COLON} -
+ + + + + + +
+ {L_EMAIL}{L_COLON} diff --git a/phpBB/styles/subsilver2/theme/stylesheet.css b/phpBB/styles/subsilver2/theme/stylesheet.css index ef18e22ccb..7e112aeb11 100644 --- a/phpBB/styles/subsilver2/theme/stylesheet.css +++ b/phpBB/styles/subsilver2/theme/stylesheet.css @@ -708,6 +708,7 @@ pre { margin: 0px; position: absolute; box-shadow: 1px 2px 5px rgb(175,167,167); + border-spacing: 0px; z-index: 999; overflow: auto; } From a74216527c42b9bcef876ab1df93185dc7f18889 Mon Sep 17 00:00:00 2001 From: Suhaib Khan Date: Mon, 24 Feb 2014 00:37:41 +0530 Subject: [PATCH 07/19] [ticket/10737] Removing obsolete code. PHPBB3-10737 --- phpBB/assets/javascript/core.js | 4 ++-- phpBB/memberlist.php | 8 ++------ phpBB/styles/prosilver/template/memberlist_search.html | 4 ++-- phpBB/styles/subsilver2/template/memberlist_search.html | 4 ++-- 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js index 82c78ae715..e5f4bd824d 100644 --- a/phpBB/assets/javascript/core.js +++ b/phpBB/assets/javascript/core.js @@ -513,7 +513,7 @@ phpbb.timezonePreselectSelect = function(forceSelector) { }; // Listen live search box events -$('.liveinput').keyup(function() { +$('.live-search-input').keyup(function() { var str = this.value; if (str.length < 3) { return; @@ -538,7 +538,7 @@ $('.liveinput').keyup(function() { }); }); -$('.liveinput').blur(function() { +$('.live-search-input').blur(function() { setTimeout(function () { var clone = $("#user-search-row-tpl").clone(); $("#livesearch").html(""); diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index 7cea4a59d7..e6f1640691 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -992,17 +992,13 @@ switch ($mode) $result = $db->sql_query_limit($sql, 10); $user_list = array(); - $i = 1; while ($row = $db->sql_fetchrow($result)) { - $j = ($i%2)+1; $user_list[] = array("id" => $row['user_id'], "name" => $row['username']); - $i++; } - + $db->sql_freeresult($result); $json_response = new \phpbb\json_response(); - echo $json_response->send($user_list); - exit(); + $json_response->send($user_list); break; case 'group': diff --git a/phpBB/styles/prosilver/template/memberlist_search.html b/phpBB/styles/prosilver/template/memberlist_search.html index e407aed616..a63e38b184 100644 --- a/phpBB/styles/prosilver/template/memberlist_search.html +++ b/phpBB/styles/prosilver/template/memberlist_search.html @@ -9,10 +9,10 @@
-
+
- +
diff --git a/phpBB/styles/subsilver2/template/memberlist_search.html b/phpBB/styles/subsilver2/template/memberlist_search.html index 1ee4abccd4..bdb5422b55 100644 --- a/phpBB/styles/subsilver2/template/memberlist_search.html +++ b/phpBB/styles/subsilver2/template/memberlist_search.html @@ -76,10 +76,10 @@ {L_USERNAME}{L_COLON} - + - +
From 6ef4e4e7907b1ab4c50b53e62b50c014813594f7 Mon Sep 17 00:00:00 2001 From: Suhaib Khan Date: Wed, 26 Feb 2014 14:43:38 +0530 Subject: [PATCH 08/19] [ticket/10737] Using UTF-8 aware alternatives in PHP code. PHPBB3-10737 --- phpBB/memberlist.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index e6f1640691..0b10c123a1 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -983,18 +983,18 @@ switch ($mode) case 'livesearch': $username_chars = $request->variable('q', '', true); - $username_chars = strtolower($username_chars); + $username_chars = utf8_strtolower($username_chars); $sql = 'SELECT username, user_id FROM ' . USERS_TABLE . ' WHERE ' . $db->sql_in_set('user_type', array(USER_NORMAL, USER_FOUNDER)) . ' - AND LOWER(username) ' . $db->sql_like_expression($username_chars . $db->any_char); + AND username_clean ' . $db->sql_like_expression(utf8_clean_string($username_chars) . $db->any_char); $result = $db->sql_query_limit($sql, 10); $user_list = array(); while ($row = $db->sql_fetchrow($result)) { - $user_list[] = array("id" => $row['user_id'], "name" => $row['username']); + $user_list[] = array('id' => $row['user_id'], 'name' => $row['username']); } $db->sql_freeresult($result); $json_response = new \phpbb\json_response(); From a60d9a7f86653cbb4c37a424e5fcc55c2318deda Mon Sep 17 00:00:00 2001 From: Suhaib Khan Date: Mon, 10 Mar 2014 19:06:42 +0530 Subject: [PATCH 09/19] [ticket/10737] Adding delayed keyup and removing target_blank. PHPBB3-10737 --- phpBB/assets/javascript/core.js | 63 +++++++++++-------- .../prosilver/template/memberlist_search.html | 2 +- .../template/memberlist_search.html | 2 +- 3 files changed, 39 insertions(+), 28 deletions(-) diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js index e5f4bd824d..6034f81a6e 100644 --- a/phpBB/assets/javascript/core.js +++ b/phpBB/assets/javascript/core.js @@ -513,37 +513,48 @@ phpbb.timezonePreselectSelect = function(forceSelector) { }; // Listen live search box events +var delay = (function(){ + var timer = 0; + return function(callback, ms){ + clearTimeout (timer); + timer = setTimeout(callback, ms); + }; +})(); + $('.live-search-input').keyup(function() { var str = this.value; - if (str.length < 3) { - return; - } - var link, name; - var clone = $("#user-search-row-tpl").clone(); - $("#livesearch").html(""); - clone.appendTo("#livesearch"); - $.ajax({ - url:'memberlist.php?mode=livesearch&'+"&q="+str, - success:function(result) { - $.each(result, function(idx, elem) { - link = "memberlist.php?mode=viewprofile&u=" + elem.id; - name = elem.name; - clone = $("#user-search-row-tpl").clone(); - clone.find(".user-search-link").attr("href", link); - clone.find(".user-search-name").html(name); - clone.attr("style", ""); - clone.appendTo("#livesearch"); - }); + delay(function(){ + if (str.length < 3) { + return; } - }); + var link, name; + var clone = $("#user-search-row-tpl").clone(); + $("#livesearch").html(""); + clone.appendTo("#livesearch"); + $.ajax({ + url:'memberlist.php?mode=livesearch&'+"&q="+str, + success:function(result) { + $.each(result, function(idx, elem) { + link = "memberlist.php?mode=viewprofile&u=" + elem.id; + name = elem.name; + clone = $("#user-search-row-tpl").clone(); + clone.find(".user-search-link").attr("href", link); + clone.find(".user-search-name").html(name); + clone.attr("style", ""); + clone.appendTo("#livesearch"); + }); + } + }); + }, 2000 ); }); -$('.live-search-input').blur(function() { - setTimeout(function () { - var clone = $("#user-search-row-tpl").clone(); - $("#livesearch").html(""); - clone.appendTo("#livesearch"); - }, 500); +$(document).click(function(event) { + var target = $( event.target ); + if(!target.is("#livesearch, #livesearch *, .live-search-input")) { + var clone = $("#user-search-row-tpl").clone(); + $("#livesearch").html(""); + clone.appendTo("#livesearch"); + } }); // Toggle notification list diff --git a/phpBB/styles/prosilver/template/memberlist_search.html b/phpBB/styles/prosilver/template/memberlist_search.html index a63e38b184..0efa91cc95 100644 --- a/phpBB/styles/prosilver/template/memberlist_search.html +++ b/phpBB/styles/prosilver/template/memberlist_search.html @@ -12,7 +12,7 @@
- +
diff --git a/phpBB/styles/subsilver2/template/memberlist_search.html b/phpBB/styles/subsilver2/template/memberlist_search.html index bdb5422b55..ea0b562b41 100644 --- a/phpBB/styles/subsilver2/template/memberlist_search.html +++ b/phpBB/styles/subsilver2/template/memberlist_search.html @@ -79,7 +79,7 @@ - +
From 652f787abd937fe8254edc1a7f9f2fd6d7114c09 Mon Sep 17 00:00:00 2001 From: Cesar G Date: Tue, 8 Apr 2014 03:53:08 -0700 Subject: [PATCH 10/19] [ticket/10737] Use dropdown for search results container. PHPBB3-10737 --- .../prosilver/template/memberlist_search.html | 19 ++++++++++++------- phpBB/styles/prosilver/theme/common.css | 15 ++++----------- phpBB/styles/prosilver/theme/forms.css | 2 +- 3 files changed, 17 insertions(+), 19 deletions(-) diff --git a/phpBB/styles/prosilver/template/memberlist_search.html b/phpBB/styles/prosilver/template/memberlist_search.html index 0efa91cc95..90d730ee5c 100644 --- a/phpBB/styles/prosilver/template/memberlist_search.html +++ b/phpBB/styles/prosilver/template/memberlist_search.html @@ -7,14 +7,19 @@

{L_FIND_USERNAME_EXPLAIN}

-
+
-
- - - - -
+
+ + +
diff --git a/phpBB/styles/prosilver/theme/common.css b/phpBB/styles/prosilver/theme/common.css index c8eb5da9a6..e4da028855 100644 --- a/phpBB/styles/prosilver/theme/common.css +++ b/phpBB/styles/prosilver/theme/common.css @@ -472,6 +472,10 @@ ul.linklist.bulletin li.no-bulletin:before { padding: 9px 0 0; } +.dropdown.live-search { + top: auto; +} + .dropdown-container.topic-tools { float: left; } @@ -940,17 +944,6 @@ li.pagination ul { z-index: 51; } -/* Live search box */ -#livesearch { - width: 30%; - margin: 0px; - position: absolute; - background-color: #12A3EB; - box-shadow: 1px 2px 5px rgb(175,167,167); - z-index: 999; - overflow: auto; -} - /* Miscellaneous styles ---------------------------------------- */ #forum-permissions { diff --git a/phpBB/styles/prosilver/theme/forms.css b/phpBB/styles/prosilver/theme/forms.css index 88f2bd65c5..0c0a3e5ca9 100644 --- a/phpBB/styles/prosilver/theme/forms.css +++ b/phpBB/styles/prosilver/theme/forms.css @@ -96,7 +96,7 @@ fieldset.fields1 div { } /* Set it back to 0px for the reCaptcha divs: PHPBB3-9587 */ -fieldset.fields1 #recaptcha_widget_div div { +fieldset.fields1 #recaptcha_widget_div div, fieldset.fields1 .live-search div { margin-bottom: 0; } From 1a51ceeabe73423b919266027cc8e86ad47a52e1 Mon Sep 17 00:00:00 2001 From: Cesar G Date: Tue, 8 Apr 2014 03:54:10 -0700 Subject: [PATCH 11/19] [ticket/10737] Clean up memberlist.php. PHPBB3-10737 --- phpBB/memberlist.php | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index 0b10c123a1..3cc92b5fe0 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -980,27 +980,35 @@ switch ($mode) ); break; - + case 'livesearch': - $username_chars = $request->variable('q', '', true); - $username_chars = utf8_strtolower($username_chars); - - $sql = 'SELECT username, user_id + + $username_chars = $request->variable('username', '', true); + + $sql = 'SELECT username, user_id, user_colour FROM ' . USERS_TABLE . ' WHERE ' . $db->sql_in_set('user_type', array(USER_NORMAL, USER_FOUNDER)) . ' AND username_clean ' . $db->sql_like_expression(utf8_clean_string($username_chars) . $db->any_char); $result = $db->sql_query_limit($sql, 10); - - $user_list = array(); + $user_list = array(); + while ($row = $db->sql_fetchrow($result)) - { - $user_list[] = array('id' => $row['user_id'], 'name' => $row['username']); + { + $user_list[] = array( + 'user_id' => (int) $row['user_id'], + 'username' => $row['username'], + 'result' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), + ); } $db->sql_freeresult($result); $json_response = new \phpbb\json_response(); - $json_response->send($user_list); + $json_response->send(array( + 'keyword' => $username_chars, + 'results' => $user_list, + )); + break; - + case 'group': default: // The basic memberlist @@ -1638,6 +1646,7 @@ switch ($mode) 'U_FIND_MEMBER' => ($config['load_search'] || $auth->acl_get('a_')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser' . (($start) ? "&start=$start" : '') . (!empty($params) ? '&' . implode('&', $params) : '')) : '', 'U_HIDE_FIND_MEMBER' => ($mode == 'searchuser' || ($mode == '' && $submit)) ? $u_hide_find_member : '', + 'U_LIVE_SEARCH' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=livesearch'), 'U_SORT_USERNAME' => $sort_url . '&sk=a&sd=' . (($sort_key == 'a' && $sort_dir == 'a') ? 'd' : 'a'), 'U_SORT_JOINED' => $sort_url . '&sk=c&sd=' . (($sort_key == 'c' && $sort_dir == 'a') ? 'd' : 'a'), 'U_SORT_POSTS' => $sort_url . '&sk=d&sd=' . (($sort_key == 'd' && $sort_dir == 'a') ? 'd' : 'a'), From 2fbae2bb41f63e35f0e7c3a650c78bfa138faf7b Mon Sep 17 00:00:00 2001 From: Cesar G Date: Tue, 8 Apr 2014 03:54:56 -0700 Subject: [PATCH 12/19] [ticket/10737] Add a more generic live search implementation. PHPBB3-10737 --- phpBB/assets/javascript/core.js | 393 ++++++++++++++++++++---- phpBB/styles/prosilver/template/ajax.js | 4 + 2 files changed, 335 insertions(+), 62 deletions(-) diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js index 6034f81a6e..f9cc3f7a91 100644 --- a/phpBB/assets/javascript/core.js +++ b/phpBB/assets/javascript/core.js @@ -248,7 +248,16 @@ phpbb.ajaxify = function(options) { callback = options.callback, overlay = (typeof options.overlay !== 'undefined') ? options.overlay : true, isForm = elements.is('form'), - eventName = isForm ? 'submit' : 'click'; + isText = elements.is('input[type="text"], textarea'), + eventName; + + if (isForm) { + eventName = 'submit'; + } else if (isText) { + eventName = 'keyup'; + } else { + eventName = 'click'; + } elements.bind(eventName, function(event) { var action, method, data, submit, that = this, $this = $(this); @@ -348,6 +357,7 @@ phpbb.ajaxify = function(options) { // If the element is a form, POST must be used and some extra data must // be taken from the form. var runFilter = (typeof options.filter === 'function'); + var data = {}; if (isForm) { action = $this.attr('action').replace('&', '&'); @@ -361,33 +371,41 @@ phpbb.ajaxify = function(options) { value: submit.val() }); } + } else if (isText) { + var name = ($this.attr('data-name') !== undefined) ? $this.attr('data-name') : this['name']; + action = $this.attr('data-url').replace('&', '&'); + data[name] = this.value; + method = 'POST'; } else { action = this.href; data = null; method = 'GET'; } + var sendRequest = function() { + if (overlay && (typeof $this.attr('data-overlay') === 'undefined' || $this.attr('data-overlay') === 'true')) { + phpbb.loadingIndicator(); + } + + var request = $.ajax({ + url: action, + type: method, + data: data, + success: returnHandler, + error: errorHandler + }); + request.always(function() { + loadingIndicator.fadeOut(phpbb.alertTime); + }); + }; + // If filter function returns false, cancel the AJAX functionality, // and return true (meaning that the HTTP request will be sent normally). - if (runFilter && !options.filter.call(this, data)) { + if (runFilter && !options.filter.call(this, data, event, sendRequest)) { return; } - if (overlay && (typeof $this.attr('data-overlay') === 'undefined' || $this.attr('data-overlay') === 'true')) { - phpbb.loadingIndicator(); - } - - var request = $.ajax({ - url: action, - type: method, - data: data, - success: returnHandler, - error: errorHandler - }); - request.always(function() { - loadingIndicator.fadeOut(phpbb.alertTime); - }); - + sendRequest(); event.preventDefault(); }); @@ -403,6 +421,278 @@ phpbb.ajaxify = function(options) { return this; }; +phpbb.search = {cache: {data: []}, tpl: [], container: []}; + +/** + * Get cached search data. + * + * @param string id Search ID. + * @return bool|object. Cached data object. Returns false if no data exists. + */ +phpbb.search.cache.get = function(id) { + if (this.data[id]) { + return this.data[id]; + } + return false; +}; + +/** + * Set search cache data value. + * + * @param string id Search ID. + * @param string key Data key. + * @param string value Data value. + * + * @return undefined + */ +phpbb.search.cache.set = function(id, key, value) { + if (!this.data[id]) { + this.data[id] = {results: []}; + } + this.data[id][key] = value; +}; + +/** + * Cache search result. + * + * @param string id Search ID. + * @param string keyword Keyword. + * @param array results Search results. + * + * @return undefined + */ +phpbb.search.cache.setResults = function(id, keyword, value) { + this.data[id]['results'][keyword] = value; +}; + +/** + * Trim spaces from keyword and lower its case. + * + * @param string keyword Search keyword to clean. + * @return string Cleaned string. + */ +phpbb.search.cleanKeyword = function(keyword) { + return $.trim(keyword).toLowerCase(); +}; + +/** + * Get clean version of search keyword. If textarea supports several keywords + * (one per line), it fetches the current keyword based on the caret position. + * + * @param jQuery el Search input|textarea. + * @param string keyword Input|textarea value. + * @param bool multiline Whether textarea supports multiple search keywords. + * + * @return string Clean string. + */ +phpbb.search.getKeyword = function(el, keyword, multiline) { + if (multiline) { + var line = phpbb.search.getKeywordLine(el); + keyword = keyword.split("\n").splice(line, 1); + } + return phpbb.search.cleanKeyword(keyword); +}; + +/** + * Get the textarea line number on which the keyword resides - for textareas + * that support multiple keywords (one per line). + * + * @param jQuery el Search textarea. + * @return int + */ +phpbb.search.getKeywordLine = function (el) { + return el.val().substr(0, el.get(0).selectionStart).split("\n").length - 1; +}; + +/** + * Set the value on the input|textarea. If textarea supports multiple + * keywords, only the active keyword is replaced. + * + * @param jQuery el Search input|textarea. + * @param string value Value to set. + * @param bool multiline Whether textarea supports multiple search keywords. + * + * @return undefined + */ +phpbb.search.setValue = function(el, value, multiline) { + if (multiline) { + var line = phpbb.search.getKeywordLine(el), + lines = el.val().split("\n"); + lines[line] = value; + value = lines.join("\n"); + } + el.val(value); +}; + +/** + * Sets the onclick event to set the value on the input|textarea to the selected search result. + * + * @param jQuery el Search input|textarea. + * @param object value Result object. + * @param object container jQuery object for the search container. + * + * @return undefined + */ +phpbb.search.setValueOnClick = function(el, value, row, container) { + row.click(function() { + phpbb.search.setValue(el, value.result, el.attr('data-multiline')); + container.hide(); + }); +}; + +/** + * Runs before the AJAX search request is sent and determines whether + * there is a need to contact the server. If there are cached results + * already, those are displayed instead. Executes the AJAX request function + * itself due to the need to use a timeout to limit the number of requests. + * + * @param array data Data to be sent to the server. + * @param object event Onkeyup event object. + * @param function sendRequest Function to execute AJAX request. + * + * @return bool Returns false. + */ +phpbb.search.filter = function(data, event, sendRequest) { + var el = $(this), + dataName = (el.attr('data-name') !== undefined) ? el.attr('data-name') : el.attr('name'), + minLength = parseInt(el.attr('data-min-length')), + searchID = el.attr('data-results'), + keyword = phpbb.search.getKeyword(el, data[dataName], el.attr('data-multiline')), + cache = phpbb.search.cache.get(searchID), + proceed = true; + data[dataName] = keyword; + + if (cache['timeout']) { + clearTimeout(cache['timeout']); + } + + var timeout = setTimeout(function() { + // Check min length and existence of cache. + if (minLength > keyword.length) { + proceed = false; + } else if (cache['last_search']) { + // Has the keyword actually changed? + if (cache['last_search'] === keyword) { + proceed = false; + } else { + // Do we already have results for this? + if (cache['results'][keyword]) { + var response = {keyword: keyword, results: cache['results'][keyword]}; + phpbb.search.handleResponse(response, el, true); + proceed = false; + } + + // If the previous search didn't yield results and the string only had characters added to it, + // then we won't bother sending a request. + if (keyword.indexOf(cache['last_search']) === 0 && cache['results'][cache['last_search']].length === 0) { + phpbb.search.cache.set(searchID, 'last_search', keyword); + phpbb.search.cache.setResults(searchID, keyword, []); + proceed = false; + } + } + } + + if (proceed) { + sendRequest.call(this); + } + }, 350); + phpbb.search.cache.set(searchID, 'timeout', timeout); + + return false; +}; + +/** + * Handle search result response. + * + * @param object res Data received from server. + * @param jQuery el Search input|textarea. + * @param bool fromCache Whether the results are from the cache. + * @param function callback Optional callback to run when assigning each search result. + * + * @return undefined + */ +phpbb.search.handleResponse = function(res, el, fromCache, callback) { + if (typeof res !== 'object') { + return; + } + + var searchID = el.attr('data-results'), + container = $(searchID); + + if (this.cache.get(searchID)['callback']) { + callback = this.cache.get(searchID)['callback']; + } else if (typeof callback === 'function') { + this.cache.set(searchID, 'callback', callback); + } + + if (!fromCache) { + this.cache.setResults(searchID, res.keyword, res.results); + } + + this.cache.set(searchID, 'last_search', res.keyword); + this.showResults(res.results, el, container, callback); +}; + +/** + * Show search results. + * + * @param array results Search results. + * @param jQuery el Search input|textarea. + * @param jQuery container Search results container element. + * @param function callback Optional callback to run when assigning each search result. + * + * @return undefined + */ +phpbb.search.showResults = function(results, el, container, callback) { + var resultContainer = $('.search-results', container); + this.clearResults(resultContainer); + + if (!results.length) { + container.hide(); + return; + } + + var searchID = container.attr('id'), + tpl, + row; + + if (!this.tpl[searchID]) { + tpl = $('.search-result-tpl', container); + this.tpl[searchID] = tpl.clone().removeClass('search-result-tpl'); + tpl.remove(); + } + tpl = this.tpl[searchID]; + + $.each(results, function(i, item) { + row = tpl.clone(); + row.find('.search-result').html(item.result); + + if (callback === 'function') { + callback.call(this, el, item, row, container); + } + row.appendTo(resultContainer).show(); + }); + container.show(); +}; + +/** + * Clear search results. + * + * @param jQuery container Search results container. + * @return undefined + */ +phpbb.search.clearResults = function(container) { + container.children(':not(.search-result-tpl)').remove(); +}; + +$('#phpbb').click(function(e) { + var target = $(e.target); + + if (!target.is('.live-search') && !target.parents().is('.live-search')) { + $('.live-search').hide(); + } +}); + /** * Hide the optgroups that are not the selected timezone * @@ -512,51 +802,6 @@ phpbb.timezonePreselectSelect = function(forceSelector) { } }; -// Listen live search box events -var delay = (function(){ - var timer = 0; - return function(callback, ms){ - clearTimeout (timer); - timer = setTimeout(callback, ms); - }; -})(); - -$('.live-search-input').keyup(function() { - var str = this.value; - delay(function(){ - if (str.length < 3) { - return; - } - var link, name; - var clone = $("#user-search-row-tpl").clone(); - $("#livesearch").html(""); - clone.appendTo("#livesearch"); - $.ajax({ - url:'memberlist.php?mode=livesearch&'+"&q="+str, - success:function(result) { - $.each(result, function(idx, elem) { - link = "memberlist.php?mode=viewprofile&u=" + elem.id; - name = elem.name; - clone = $("#user-search-row-tpl").clone(); - clone.find(".user-search-link").attr("href", link); - clone.find(".user-search-name").html(name); - clone.attr("style", ""); - clone.appendTo("#livesearch"); - }); - } - }); - }, 2000 ); -}); - -$(document).click(function(event) { - var target = $( event.target ); - if(!target.is("#livesearch, #livesearch *, .live-search-input")) { - var clone = $("#user-search-row-tpl").clone(); - $("#livesearch").html(""); - clone.appendTo("#livesearch"); - } -}); - // Toggle notification list $('#notification_list_button').click(function(e) { $('#notification_list').toggle(); @@ -587,6 +832,12 @@ phpbb.addAjaxCallback = function(id, callback) { return this; }; +/** + * This callback handles live member searches. + */ +phpbb.addAjaxCallback('member_search', function(res) { + phpbb.search.handleResponse(res, $(this), false); +}); /** * This callback alternates text - it replaces the current text with the text in @@ -1147,6 +1398,24 @@ phpbb.toggleDisplay = function(id, action, type) { $('#' + id).css('display', ((action === 1) ? type : 'none')); } +/** +* Get function from name. +* Based on http://stackoverflow.com/a/359910 +* +* @param string functionName Function to get. +* @return function +*/ +phpbb.getFunctionByName = function (functionName) { + var namespaces = functionName.split('.'), + func = namespaces.pop(), + context = window; + + for (var i = 0; i < namespaces.length; i++) { + context = context[namespaces[i]]; + } + return context[func]; +}; + /** * Apply code editor to all textarea elements with data-bbcode attribute */ diff --git a/phpBB/styles/prosilver/template/ajax.js b/phpBB/styles/prosilver/template/ajax.js index 4df38f4275..78ec5c0cb7 100644 --- a/phpBB/styles/prosilver/template/ajax.js +++ b/phpBB/styles/prosilver/template/ajax.js @@ -315,13 +315,17 @@ $('.poll_view_results a').click(function(e) { $('[data-ajax]').each(function() { var $this = $(this), ajax = $this.attr('data-ajax'), + filter = $this.attr('data-filter'), fn; if (ajax !== 'false') { fn = (ajax !== 'true') ? ajax : null; + filter = (filter !== undefined) ? phpbb.getFunctionByName(filter) : null; + phpbb.ajaxify({ selector: this, refresh: $this.attr('data-refresh') !== undefined, + filter: filter, callback: fn }); } From 333a18d8466d0299415520ca0436bfe6c005a747 Mon Sep 17 00:00:00 2001 From: Cesar G Date: Tue, 8 Apr 2014 04:03:40 -0700 Subject: [PATCH 13/19] [ticket/10737] Drop subsilver2 changes. PHPBB3-10737 --- phpBB/styles/subsilver2/template/memberlist_search.html | 9 +-------- phpBB/styles/subsilver2/theme/stylesheet.css | 9 --------- 2 files changed, 1 insertion(+), 17 deletions(-) diff --git a/phpBB/styles/subsilver2/template/memberlist_search.html b/phpBB/styles/subsilver2/template/memberlist_search.html index ea0b562b41..aa6b61fe22 100644 --- a/phpBB/styles/subsilver2/template/memberlist_search.html +++ b/phpBB/styles/subsilver2/template/memberlist_search.html @@ -75,14 +75,7 @@ {L_USERNAME}{L_COLON} - - - - - - -
- + {L_EMAIL}{L_COLON} diff --git a/phpBB/styles/subsilver2/theme/stylesheet.css b/phpBB/styles/subsilver2/theme/stylesheet.css index 7e112aeb11..0bffc33f37 100644 --- a/phpBB/styles/subsilver2/theme/stylesheet.css +++ b/phpBB/styles/subsilver2/theme/stylesheet.css @@ -703,15 +703,6 @@ pre { font-weight: bold; } -#livesearch { - width: 35%; - margin: 0px; - position: absolute; - box-shadow: 1px 2px 5px rgb(175,167,167); - border-spacing: 0px; - z-index: 999; - overflow: auto; -} /* Former imageset */ span.imageset { From 3fec8dff2cc22bc56a6d909be6df8742ab145c6f Mon Sep 17 00:00:00 2001 From: Cesar G Date: Tue, 8 Apr 2014 05:33:24 -0700 Subject: [PATCH 14/19] [ticket/10737] Set the username as the input value instead of redirecting. PHPBB3-10737 --- phpBB/assets/javascript/core.js | 8 ++++---- phpBB/memberlist.php | 5 +++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js index f9cc3f7a91..4a16cfd73e 100644 --- a/phpBB/assets/javascript/core.js +++ b/phpBB/assets/javascript/core.js @@ -665,11 +665,11 @@ phpbb.search.showResults = function(results, el, container, callback) { $.each(results, function(i, item) { row = tpl.clone(); - row.find('.search-result').html(item.result); + row.find('.search-result').html(item.display); - if (callback === 'function') { + if (typeof callback === 'function') { callback.call(this, el, item, row, container); - } + } row.appendTo(resultContainer).show(); }); container.show(); @@ -836,7 +836,7 @@ phpbb.addAjaxCallback = function(id, callback) { * This callback handles live member searches. */ phpbb.addAjaxCallback('member_search', function(res) { - phpbb.search.handleResponse(res, $(this), false); + phpbb.search.handleResponse(res, $(this), false, phpbb.getFunctionByName('phpbb.search.setValueOnClick')); }); /** diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index 3cc92b5fe0..4103855f43 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -996,8 +996,9 @@ switch ($mode) { $user_list[] = array( 'user_id' => (int) $row['user_id'], - 'username' => $row['username'], - 'result' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), + 'result' => $row['username'], + 'username_full' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), + 'display' => get_username_string('no_profile', $row['user_id'], $row['username'], $row['user_colour']), ); } $db->sql_freeresult($result); From 6cb84402fd435f191506c564a3afe70d565f7917 Mon Sep 17 00:00:00 2001 From: Cesar G Date: Tue, 8 Apr 2014 05:43:58 -0700 Subject: [PATCH 15/19] [ticket/10737] Load core.js and ajax.js in simple_footer.html. PHPBB3-10737 --- phpBB/styles/prosilver/template/simple_footer.html | 2 ++ 1 file changed, 2 insertions(+) diff --git a/phpBB/styles/prosilver/template/simple_footer.html b/phpBB/styles/prosilver/template/simple_footer.html index 10edece3cd..f50664d7cb 100644 --- a/phpBB/styles/prosilver/template/simple_footer.html +++ b/phpBB/styles/prosilver/template/simple_footer.html @@ -8,7 +8,9 @@ + + From 683e8c0c17726205501333aea117e4394fc34ef4 Mon Sep 17 00:00:00 2001 From: Cesar G Date: Fri, 11 Apr 2014 18:53:20 -0700 Subject: [PATCH 16/19] [ticket/10737] Add loading indicator and alert box code to simple_footer.html. PHPBB3-10737 --- phpBB/styles/prosilver/template/simple_footer.html | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/phpBB/styles/prosilver/template/simple_footer.html b/phpBB/styles/prosilver/template/simple_footer.html index f50664d7cb..02e24ab796 100644 --- a/phpBB/styles/prosilver/template/simple_footer.html +++ b/phpBB/styles/prosilver/template/simple_footer.html @@ -4,6 +4,20 @@
{TRANSLATION_INFO}
{DEBUG_OUTPUT} + +
+
 
+
+
+ +
+ +

+
+
+ +
+
From 607698c8844b1f08aef1aca63cd8d981783ef92a Mon Sep 17 00:00:00 2001 From: Cesar G Date: Fri, 11 Apr 2014 19:23:31 -0700 Subject: [PATCH 17/19] [ticket/10737] Add config setting to disable live searches. PHPBB3-10737 --- phpBB/includes/acp/acp_board.php | 1 + phpBB/install/schemas/schema_data.sql | 1 + phpBB/language/en/acp/board.php | 2 ++ phpBB/memberlist.php | 2 +- .../data/v310/live_searches_config.php | 25 +++++++++++++++++++ .../prosilver/template/memberlist_search.html | 5 ++-- 6 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 phpBB/phpbb/db/migration/data/v310/live_searches_config.php diff --git a/phpBB/includes/acp/acp_board.php b/phpBB/includes/acp/acp_board.php index 2c0eb95cd5..52739718be 100644 --- a/phpBB/includes/acp/acp_board.php +++ b/phpBB/includes/acp/acp_board.php @@ -345,6 +345,7 @@ class acp_board 'load_user_activity' => array('lang' => 'LOAD_USER_ACTIVITY', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 'load_tplcompile' => array('lang' => 'RECOMPILE_STYLES', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 'allow_cdn' => array('lang' => 'ALLOW_CDN', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), + 'allow_live_searches' => array('lang' => 'ALLOW_LIVE_SEARCHES', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 'legend3' => 'CUSTOM_PROFILE_FIELDS', 'load_cpf_memberlist' => array('lang' => 'LOAD_CPF_MEMBERLIST', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), diff --git a/phpBB/install/schemas/schema_data.sql b/phpBB/install/schemas/schema_data.sql index bc76bf55b9..f483200349 100644 --- a/phpBB/install/schemas/schema_data.sql +++ b/phpBB/install/schemas/schema_data.sql @@ -21,6 +21,7 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_cdn', '0'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_emailreuse', '0'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_password_reset', '1'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_forum_notify', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_live_searches', '1'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_mass_pm', '1'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_name_chars', 'USERNAME_CHARS_ANY'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_namechange', '0'); diff --git a/phpBB/language/en/acp/board.php b/phpBB/language/en/acp/board.php index 1d2c979e0c..5488bead17 100644 --- a/phpBB/language/en/acp/board.php +++ b/phpBB/language/en/acp/board.php @@ -356,6 +356,8 @@ $lang = array_merge($lang, array( 'ALLOW_CDN' => 'Allow usage of third party content delivery networks', 'ALLOW_CDN_EXPLAIN' => 'If this setting is enabled, some files will be served from external third party servers instead of your server. This reduces the network bandwidth required by your server, but may present a privacy issue for some board administrators. In a default phpBB installation, this includes loading “jQuery” and the font “Open Sans” from Google’s content delivery network.', + 'ALLOW_LIVE_SEARCHES' => 'Allow live searches', + 'ALLOW_LIVE_SEARCHES_EXPLAIN' => 'If this setting is enabled, users are provided with keyword suggestions as they type in certain fields throughout the board.', 'CUSTOM_PROFILE_FIELDS' => 'Custom profile fields', 'LIMIT_LOAD' => 'Limit system load', 'LIMIT_LOAD_EXPLAIN' => 'If the system’s 1-minute load average exceeds this value the board will automatically go offline. A value of 1.0 equals ~100% utilisation of one processor. This only functions on UNIX based servers and where this information is accessible. The value here resets itself to 0 if phpBB was unable to get the load limit.', diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index 4103855f43..acda40c8fb 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -1647,7 +1647,7 @@ switch ($mode) 'U_FIND_MEMBER' => ($config['load_search'] || $auth->acl_get('a_')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser' . (($start) ? "&start=$start" : '') . (!empty($params) ? '&' . implode('&', $params) : '')) : '', 'U_HIDE_FIND_MEMBER' => ($mode == 'searchuser' || ($mode == '' && $submit)) ? $u_hide_find_member : '', - 'U_LIVE_SEARCH' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=livesearch'), + 'U_LIVE_SEARCH' => ($config['allow_live_searches']) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=livesearch') : false, 'U_SORT_USERNAME' => $sort_url . '&sk=a&sd=' . (($sort_key == 'a' && $sort_dir == 'a') ? 'd' : 'a'), 'U_SORT_JOINED' => $sort_url . '&sk=c&sd=' . (($sort_key == 'c' && $sort_dir == 'a') ? 'd' : 'a'), 'U_SORT_POSTS' => $sort_url . '&sk=d&sd=' . (($sort_key == 'd' && $sort_dir == 'a') ? 'd' : 'a'), diff --git a/phpBB/phpbb/db/migration/data/v310/live_searches_config.php b/phpBB/phpbb/db/migration/data/v310/live_searches_config.php new file mode 100644 index 0000000000..8b147c954c --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v310/live_searches_config.php @@ -0,0 +1,25 @@ +config['allow_live_searches']); + } + + public function update_data() + { + return array( + array('config.add', array('allow_live_searches', '1')), + ); + } +} diff --git a/phpBB/styles/prosilver/template/memberlist_search.html b/phpBB/styles/prosilver/template/memberlist_search.html index 90d730ee5c..0975ae947c 100644 --- a/phpBB/styles/prosilver/template/memberlist_search.html +++ b/phpBB/styles/prosilver/template/memberlist_search.html @@ -10,8 +10,8 @@
- - + autocomplete="off" data-filter="phpbb.search.filter" data-ajax="member_search" data-min-length="3" data-url="{U_LIVE_SEARCH}" data-results="#user-search" /> + +
From f2e74354a34561940c3203f24816af2496b95b0b Mon Sep 17 00:00:00 2001 From: Cesar G Date: Sat, 12 Apr 2014 04:26:51 -0700 Subject: [PATCH 18/19] [ticket/10737] Enforce allow_live_searches setting in memberlist.php. PHPBB3-10737 --- phpBB/language/en/common.php | 1 + phpBB/memberlist.php | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/phpBB/language/en/common.php b/phpBB/language/en/common.php index 677b228cc6..030559eeb5 100644 --- a/phpBB/language/en/common.php +++ b/phpBB/language/en/common.php @@ -348,6 +348,7 @@ $lang = array_merge($lang, array( 'LDAP_NO_SERVER_CONNECTION' => 'Could not connect to LDAP server.', 'LDAP_SEARCH_FAILED' => 'An error occurred while searching the LDAP directory.', 'LEGEND' => 'Legend', + 'LIVE_SEARCHES_NOT_ALLOWED' => 'Live searches are not allowed.', 'LOADING' => 'Loading', 'LOCATION' => 'Location', 'LOCK_POST' => 'Lock post', diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index acda40c8fb..3d9f4aa028 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -50,6 +50,13 @@ switch ($mode) case 'email': break; + case 'livesearch': + if (!$config['allow_live_searches']) + { + trigger_error('LIVE_SEARCHES_NOT_ALLOWED'); + } + // No break + default: // Can this user view profiles/memberlist? if (!$auth->acl_gets('u_viewprofile', 'a_user', 'a_useradd', 'a_userdel')) From a62b672530f1134af98f27d5318ceeae38b65f05 Mon Sep 17 00:00:00 2001 From: Cesar G Date: Wed, 23 Apr 2014 09:14:42 -0700 Subject: [PATCH 19/19] [ticket/10737] Remove loading indicator. PHPBB3-10737 --- phpBB/styles/prosilver/template/memberlist_search.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/styles/prosilver/template/memberlist_search.html b/phpBB/styles/prosilver/template/memberlist_search.html index 0975ae947c..f4439b6934 100644 --- a/phpBB/styles/prosilver/template/memberlist_search.html +++ b/phpBB/styles/prosilver/template/memberlist_search.html @@ -10,7 +10,7 @@
- autocomplete="off" data-filter="phpbb.search.filter" data-ajax="member_search" data-min-length="3" data-url="{U_LIVE_SEARCH}" data-results="#user-search" /> + autocomplete="off" data-filter="phpbb.search.filter" data-ajax="member_search" data-min-length="3" data-url="{U_LIVE_SEARCH}" data-results="#user-search" data-overlay="false" />