Skip to content

Commit

Permalink
[ticket/10737] Improvements over last commit
Browse files Browse the repository at this point in the history
PHPBB3-10737
  • Loading branch information
Suhaib Khan committed Mar 9, 2014
1 parent 633d91a commit a63f792
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 69 deletions.
42 changes: 13 additions & 29 deletions phpBB/memberlist.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
$topic_id = request_var('t', 0);

// Check our mode...
if (!in_array($mode, array('', 'group', 'viewprofile', 'email', 'contact', 'searchuser', 'leaders','livesearch')))
if (!in_array($mode, array('', 'group', 'viewprofile', 'email', 'contact', 'searchuser', 'leaders', 'livesearch')))
{
trigger_error('NO_MODE');
}
Expand Down Expand Up @@ -991,37 +991,21 @@
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.="<tr class='bg".$j." row".$j."'><td><a href='" .
$phpbb_root_path."memberlist.$phpEx". "?mode=viewprofile&u=" . $row['user_id'] .
"' target='_blank'>" .
$row['username'] . "</a></td></tr>";
$i++;
}
else
$hint.="";
while ($i<=10 && $row = $db->sql_fetchrow($result))
{
$j=($i%2)+1;
$hint.="<tr class='bg".$j." row".$j."'><td><a href='" .
$phpbb_root_path."memberlist.$phpEx". "?mode=viewprofile&u=" . $row['user_id'] .
"' target='_blank'>" .
$row['username'] . "</a></td></tr>";
$i++;
}
echo $hint;
exit();
Expand Down
28 changes: 8 additions & 20 deletions phpBB/styles/prosilver/template/memberlist_search.html
Original file line number Diff line number Diff line change
@@ -1,30 +1,18 @@
<script>
function showHint(str)
{
if (str.length==0)
if (str.length<3)
{
document.getElementById("livesearch").innerHTML="";
document.getElementById("livesearch").style.border="0px";
return;
}
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("livesearch").innerHTML=xmlhttp.responseText;
document.getElementById("livesearch").style.border="0px";
}
}
xmlhttp.open("GET",'{S_LIVE_SEARCH_ACTION}'+"&q="+str,true);
xmlhttp.send();

$.ajax({
url:'{S_LIVE_SEARCH_ACTION}'+"&q="+str,
success:function(result){
$("#livesearch").html(result);
}
});
}

function clearSearch()
Expand Down
28 changes: 8 additions & 20 deletions phpBB/styles/subsilver2/template/memberlist_search.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,30 +67,18 @@
<script>
function showHint(str)
{
if (str.length==0)
if (str.length<3)
{
document.getElementById("livesearch").innerHTML="";
document.getElementById("livesearch").style.border="0px";
return;
}
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("livesearch").innerHTML=xmlhttp.responseText;
document.getElementById("livesearch").style.border="0px";
}
}
xmlhttp.open("GET",'{S_LIVE_SEARCH_ACTION}'+"&q="+str,true);
xmlhttp.send();

$.ajax({
url:'{S_LIVE_SEARCH_ACTION}'+"&q="+str,
success:function(result){
$("#livesearch").html(result);
}
});
}

function clearSearch()
Expand Down

0 comments on commit a63f792

Please sign in to comment.