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
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;
36 if($mode === "community")
37 $extra_sql = " AND `community`";
41 $results = q("SELECT `contact`.`id` AS `cid`, `gcontact`.`url`, `gcontact`.`name`, `gcontact`.`nick`, `gcontact`.`photo`,
42 `gcontact`.`network`, `gcontact`.`keywords`, `gcontact`.`addr`, `gcontact`.`community`
44 LEFT JOIN `contact` ON `contact`.`nurl` = `gcontact`.`nurl`
45 AND `contact`.`uid` = %d AND NOT `contact`.`blocked`
46 AND NOT `contact`.`pending` AND `contact`.`rel` IN ('%s', '%s')
47 WHERE (`contact`.`id` > 0 OR (NOT `gcontact`.`hide` AND `gcontact`.`network` IN ('%s', '%s', '%s') AND
48 ((`gcontact`.`last_contact` >= `gcontact`.`last_failure`) OR (`gcontact`.`updated` >= `gcontact`.`last_failure`)))) AND
49 (`gcontact`.`name` REGEXP '%s' OR `gcontact`.`nick` REGEXP '%s') $extra_sql
50 GROUP BY `gcontact`.`nurl`
51 ORDER BY `gcontact`.`updated` DESC ",
52 intval(local_user()), dbesc(CONTACT_IS_SHARING), dbesc(CONTACT_IS_FRIEND),
53 dbesc(NETWORK_DFRN), dbesc($ostatus), dbesc($diaspora),
54 dbesc(escape_tags($search)), dbesc(escape_tags($search)));