4 * @file include/DirSearch.php
5 * @brief This file includes the DirSearch class with directory related functions
10 * @brief This class handels directory related functions
15 * @brief Search global contact table by nick or name
17 * @param string $search Name or nick
18 * @param string $mode Search mode (e.g. "community")
19 * @return array with search results
21 public static function global_search_by_name($search, $mode = '') {
24 // check supported networks
25 if (get_config('system','diaspora_enabled'))
26 $diaspora = NETWORK_DIASPORA;
28 $diaspora = NETWORK_DFRN;
30 if (!get_config('system','ostatus_disabled'))
31 $ostatus = NETWORK_OSTATUS;
33 $ostatus = NETWORK_DFRN;
35 // check if we search only communities or every contact
36 if($mode === "community")
37 $extra_sql = " AND `community`";
43 $results = q("SELECT `contact`.`id` AS `cid`, `gcontact`.`url`, `gcontact`.`name`, `gcontact`.`nick`, `gcontact`.`photo`,
44 `gcontact`.`network`, `gcontact`.`keywords`, `gcontact`.`addr`, `gcontact`.`community`
46 LEFT JOIN `contact` ON `contact`.`nurl` = `gcontact`.`nurl`
47 AND `contact`.`uid` = %d AND NOT `contact`.`blocked`
48 AND NOT `contact`.`pending` AND `contact`.`rel` IN ('%s', '%s')
49 WHERE (`contact`.`id` > 0 OR (NOT `gcontact`.`hide` AND `gcontact`.`network` IN ('%s', '%s', '%s') AND
50 ((`gcontact`.`last_contact` >= `gcontact`.`last_failure`) OR (`gcontact`.`updated` >= `gcontact`.`last_failure`)))) AND
51 (`gcontact`.`addr` LIKE '%s' OR `gcontact`.`name` LIKE '%s' OR `gcontact`.`nick` LIKE '%s') $extra_sql
52 GROUP BY `gcontact`.`nurl`
53 ORDER BY `gcontact`.`nurl` DESC
55 intval(local_user()), dbesc(CONTACT_IS_SHARING), dbesc(CONTACT_IS_FRIEND),
56 dbesc(NETWORK_DFRN), dbesc($ostatus), dbesc($diaspora),
57 dbesc(escape_tags($search)), dbesc(escape_tags($search)), dbesc(escape_tags($search)));