diff options
-rw-r--r-- | admin/user/index.php | 15 | ||||
-rw-r--r-- | engine/lib/users.php | 29 | ||||
-rw-r--r-- | views/default/admin/user.php | 2 |
3 files changed, 41 insertions, 5 deletions
diff --git a/admin/user/index.php b/admin/user/index.php index 947904a0c..027b71b4c 100644 --- a/admin/user/index.php +++ b/admin/user/index.php @@ -17,9 +17,20 @@ // Make sure only valid admin users can see this
admin_gatekeeper();
-
+ // Are we performing a search + $search = get_input('search'); + $limit = get_input('limit', 10); + $offset = get_input('offset', 0); + + if ($search){ + $entities = search_for_user($search, $limit, $offset, "",false); + $count = search_for_user($search, $limit, $offset, "",true); + + $result = elgg_view_entity_list($entities, $count, $offset, $limit); + } else + $result = list_entities_from_metadata("", $tag, "user", "");
// Display main admin menu
- page_draw(elgg_echo("admin:user"),elgg_view_layout("one_column", elgg_view("admin/user")));
+ page_draw(elgg_echo("admin:user"),elgg_view_layout("one_column", elgg_view("admin/user", array('list' => $result))));
?>
\ No newline at end of file diff --git a/engine/lib/users.php b/engine/lib/users.php index 50e9d11ea..4445f485f 100644 --- a/engine/lib/users.php +++ b/engine/lib/users.php @@ -691,17 +691,40 @@ * 2) If $criteria matches greater than 50% of results NO RESULTS ARE RETURNED! * * @param string $criteria The partial or full name or username. + * @param int $limit Limit of the search. + * @param int $offset Offset. + * @param string $order_by The order. + * @param boolean $count Whether to return the count of results or just the results. */ - function search_for_user($criteria) + function search_for_user($criteria, $limit = 10, $offset = 0, $order_by = "", $count = false) { global $CONFIG; $criteria = sanitise_string($criteria); + $limit = (int)$limit; + $offset = (int)$offset; + $order_by = sanitise_string($order_by); + $access = get_access_sql_suffix("e"); - $query = "select e.* 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"; + if ($order_by == "") $order_by = "e.time_created desc"; + + if ($count) { + $query = "SELECT count(e.guid) as total "; + } 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"; - return get_data($query, "entity_row_to_elggstar"); + if (!$count) { + $query .= " order by $order_by limit $offset, $limit"; // Add order and limit + return get_data($query, "entity_row_to_elggstar"); + } else { + if ($count = get_data_row($query)) { + return $count->total; + } + } + return false; } /**
diff --git a/views/default/admin/user.php b/views/default/admin/user.php index 6994851c6..5cfc4adff 100644 --- a/views/default/admin/user.php +++ b/views/default/admin/user.php @@ -16,4 +16,6 @@ echo elgg_view("admin/user_opt/search"); + if ($vars['list']) echo $vars['list']; + ?>
\ No newline at end of file |