aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/users.php
diff options
context:
space:
mode:
authormarcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-06-18 15:07:40 +0000
committermarcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-06-18 15:07:40 +0000
commit036fec5442590dfb61d88afa5b9154c48037cb17 (patch)
treec75c4b41ee1860bf44f94dd7572a1bd6cbbbb114 /engine/lib/users.php
parente06d5db3f81d9357329e643b1e3c170d7d47324e (diff)
downloadelgg-036fec5442590dfb61d88afa5b9154c48037cb17.tar.gz
elgg-036fec5442590dfb61d88afa5b9154c48037cb17.tar.bz2
Further fixes to #41 with admin panel support
git-svn-id: https://code.elgg.org/elgg/trunk@968 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib/users.php')
-rw-r--r--engine/lib/users.php29
1 files changed, 26 insertions, 3 deletions
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;
}
/**