1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-21 16:01:40 +02:00

[ticket/10737] Adding username suggestions in "Find a member" using AJAX

PHPBB3-10737
This commit is contained in:
Suhaib Khan
2014-02-06 18:32:59 +05:30
committed by Cesar G
parent 5b6a675399
commit dad60045b6
5 changed files with 132 additions and 5 deletions

View File

@@ -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.="<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.="";
}
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&amp;form=$form&amp;field=$field"))
'S_USER_SEARCH_ACTION' => append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=searchuser&amp;form=$form&amp;field=$field"),
'S_LIVE_SEARCH_ACTION' => append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=livesearch", $is_amp = false))
);
}