diff options
author | Joas Schilling <nickvergessen@gmx.de> | 2014-05-03 16:39:31 +0200 |
---|---|---|
committer | Joas Schilling <nickvergessen@gmx.de> | 2014-05-03 16:39:31 +0200 |
commit | b60108dc78af581fe5327fce4037731555203320 (patch) | |
tree | c0e6807e2a3f106e1ecaf5309d94e02e7716d18d /phpBB/memberlist.php | |
parent | 4e529fda036b5aa3611da30277487907b83b55ac (diff) | |
parent | a62b672530f1134af98f27d5318ceeae38b65f05 (diff) | |
download | forums-b60108dc78af581fe5327fce4037731555203320.tar forums-b60108dc78af581fe5327fce4037731555203320.tar.gz forums-b60108dc78af581fe5327fce4037731555203320.tar.bz2 forums-b60108dc78af581fe5327fce4037731555203320.tar.xz forums-b60108dc78af581fe5327fce4037731555203320.zip |
Merge pull request #2267 from prototech/ticket/10737
[ticket/10737] Add live member search.
* prototech/ticket/10737:
[ticket/10737] Remove loading indicator.
[ticket/10737] Enforce allow_live_searches setting in memberlist.php.
[ticket/10737] Add config setting to disable live searches.
[ticket/10737] Add loading indicator and alert box code to simple_footer.html.
[ticket/10737] Load core.js and ajax.js in simple_footer.html.
[ticket/10737] Set the username as the input value instead of redirecting.
[ticket/10737] Drop subsilver2 changes.
[ticket/10737] Add a more generic live search implementation.
[ticket/10737] Clean up memberlist.php.
[ticket/10737] Use dropdown for search results container.
[ticket/10737] Adding delayed keyup and removing target_blank.
[ticket/10737] Using UTF-8 aware alternatives in PHP code.
[ticket/10737] Removing obsolete code.
[ticket/10737] Avoid hard-coding table row and use case-insensitive search.
[ticket/10737] Removing unnecessary/obsolete code.
[ticket/10737] Using JQuery events and JSON response.
[ticket/10737] Code fixes in AJAX search feature
[ticket/10737] Improvements over last commit
[ticket/10737] Adding username suggestions in "Find a member" using AJAX
Diffstat (limited to 'phpBB/memberlist.php')
-rw-r--r-- | phpBB/memberlist.php | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index 82143d44cb..f859960183 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'); } @@ -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')) @@ -990,6 +997,35 @@ switch ($mode) break; + case 'livesearch': + + $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(); + + while ($row = $db->sql_fetchrow($result)) + { + $user_list[] = array( + 'user_id' => (int) $row['user_id'], + '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); + $json_response = new \phpbb\json_response(); + $json_response->send(array( + 'keyword' => $username_chars, + 'results' => $user_list, + )); + + break; + case 'group': default: // The basic memberlist @@ -1627,6 +1663,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' => ($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'), |