diff options
| author | Suhaib Khan <suhebjerk@gmail.com> | 2014-02-06 18:32:59 +0530 |
|---|---|---|
| committer | Cesar G <prototech91@gmail.com> | 2014-04-23 09:11:39 -0700 |
| commit | dad60045b60d7a622bb23d34d808fc1d03a91b90 (patch) | |
| tree | bbbbba74bf2e494896ad3e9bdcecdb6a3cdf403a /phpBB/memberlist.php | |
| parent | 5b6a6753992ae03e7bd36e7530a1a4e0e14fb57b (diff) | |
| download | forums-dad60045b60d7a622bb23d34d808fc1d03a91b90.tar forums-dad60045b60d7a622bb23d34d808fc1d03a91b90.tar.gz forums-dad60045b60d7a622bb23d34d808fc1d03a91b90.tar.bz2 forums-dad60045b60d7a622bb23d34d808fc1d03a91b90.tar.xz forums-dad60045b60d7a622bb23d34d808fc1d03a91b90.zip | |
[ticket/10737] Adding username suggestions in "Find a member" using AJAX
PHPBB3-10737
Diffstat (limited to 'phpBB/memberlist.php')
| -rw-r--r-- | phpBB/memberlist.php | 44 |
1 files changed, 41 insertions, 3 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.="<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&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)) ); } |
