From a64e1b87620bbb1d8e785532786cc63b31047c36 Mon Sep 17 00:00:00 2001 From: ben Date: Fri, 4 Jul 2008 11:50:06 +0000 Subject: First pass on user search git-svn-id: https://code.elgg.org/elgg/trunk@1288 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/users.php | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'engine/lib') diff --git a/engine/lib/users.php b/engine/lib/users.php index 20a974430..cec5c87c7 100644 --- a/engine/lib/users.php +++ b/engine/lib/users.php @@ -735,7 +735,10 @@ } else { $query = "SELECT e.* "; } - $query .= "from {$CONFIG->dbprefix}entities e join {$CONFIG->dbprefix}users_entity u on e.guid=u.guid where match(u.name,u.username) against ('$criteria') and $access"; + $query .= "from {$CONFIG->dbprefix}entities e join {$CONFIG->dbprefix}users_entity u on e.guid=u.guid where "; + // $query .= " match(u.name,u.username) against ('$criteria') "; + $query .= "(u.name like \"%{$criteria}%\" or u.username like \"%{$criteria}%\")"; + $query .= " and $access"; if (!$count) { $query .= " order by $order_by limit $offset, $limit"; // Add order and limit @@ -970,6 +973,31 @@ //register_action("user/language"); register_plugin_hook('usersettings:save','user','users_settings_save'); + register_plugin_hook('search','all','search_list_users_by_name'); + + } + + /** + * Returns a formatted list of users suitable for injecting into search. + * + */ + function search_list_users_by_name($hook, $user, $returnvalue, $tag) { + + // Change this to set the number of users that display on the search page + $threshold = 4; + + if ($users = search_for_user($tag,$threshold)) { + + $countusers = search_for_user($tag,0,0,"",true); + + $return = elgg_view('user/search/startblurb',array('count' => $countusers, 'tag' => $tag)); + foreach($users as $user) { + $return .= elgg_view_entity($user); + } + $return .= elgg_view('user/search/finishblurb',array('count' => $countusers, 'threshold' => $threshold, 'tag' => $tag)); + return $return; + + } } -- cgit v1.2.3