@@ 504-539 (lines=36) @@ | ||
501 | * @return mixed |
|
502 | * @deprecated 1.7 |
|
503 | */ |
|
504 | function search_for_group($criteria, $limit = 10, $offset = 0, $order_by = "", $count = false) { |
|
505 | elgg_deprecated_notice('search_for_group() was deprecated by new search plugin.', 1.7); |
|
506 | global $CONFIG; |
|
507 | ||
508 | $criteria = sanitise_string($criteria); |
|
509 | $limit = (int)$limit; |
|
510 | $offset = (int)$offset; |
|
511 | $order_by = sanitise_string($order_by); |
|
512 | ||
513 | $access = _elgg_get_access_where_sql(); |
|
514 | ||
515 | if ($order_by == "") { |
|
516 | $order_by = "e.time_created desc"; |
|
517 | } |
|
518 | ||
519 | if ($count) { |
|
520 | $query = "SELECT count(e.guid) as total "; |
|
521 | } else { |
|
522 | $query = "SELECT e.* "; |
|
523 | } |
|
524 | $query .= "from {$CONFIG->dbprefix}entities e" |
|
525 | . " JOIN {$CONFIG->dbprefix}groups_entity g on e.guid=g.guid where "; |
|
526 | ||
527 | $query .= "(g.name like \"%{$criteria}%\" or g.description like \"%{$criteria}%\")"; |
|
528 | $query .= " and $access"; |
|
529 | ||
530 | if (!$count) { |
|
531 | $query .= " order by $order_by limit $offset, $limit"; // Add order and limit |
|
532 | return get_data($query, "entity_row_to_elggstar"); |
|
533 | } else { |
|
534 | if ($count = get_data_row($query)) { |
|
535 | return $count->total; |
|
536 | } |
|
537 | } |
|
538 | return false; |
|
539 | } |
|
540 | ||
541 | /** |
|
542 | * Returns a formatted list of groups suitable for injecting into search. |
|
@@ 977-1012 (lines=36) @@ | ||
974 | * @return mixed |
|
975 | * @deprecated 1.7 |
|
976 | */ |
|
977 | function search_for_user($criteria, $limit = 10, $offset = 0, $order_by = "", $count = false) { |
|
978 | elgg_deprecated_notice('search_for_user() was deprecated by new search.', 1.7); |
|
979 | global $CONFIG; |
|
980 | ||
981 | $criteria = sanitise_string($criteria); |
|
982 | $limit = (int)$limit; |
|
983 | $offset = (int)$offset; |
|
984 | $order_by = sanitise_string($order_by); |
|
985 | ||
986 | $access = _elgg_get_access_where_sql(); |
|
987 | ||
988 | if ($order_by == "") { |
|
989 | $order_by = "e.time_created desc"; |
|
990 | } |
|
991 | ||
992 | if ($count) { |
|
993 | $query = "SELECT count(e.guid) as total "; |
|
994 | } else { |
|
995 | $query = "SELECT e.* "; |
|
996 | } |
|
997 | $query .= "from {$CONFIG->dbprefix}entities e |
|
998 | join {$CONFIG->dbprefix}users_entity u on e.guid=u.guid where "; |
|
999 | ||
1000 | $query .= "(u.name like \"%{$criteria}%\" or u.username like \"%{$criteria}%\")"; |
|
1001 | $query .= " and $access"; |
|
1002 | ||
1003 | if (!$count) { |
|
1004 | $query .= " order by $order_by limit $offset, $limit"; |
|
1005 | return get_data($query, "entity_row_to_elggstar"); |
|
1006 | } else { |
|
1007 | if ($count = get_data_row($query)) { |
|
1008 | return $count->total; |
|
1009 | } |
|
1010 | } |
|
1011 | return false; |
|
1012 | } |
|
1013 | ||
1014 | /** |
|
1015 | * Displays a list of user objects that have been searched for. |