4 * @file include/dir.php
9 * @brief This class handels directory related functions
14 * @brief Search global contact table by nick or name
16 * @param string $search Name or nick
17 * @param string $mode Search mode
20 public static function global_search_by_name($search, $mode = '') {
23 // check supported networks
24 if (get_config('system','diaspora_enabled'))
25 $diaspora = NETWORK_DIASPORA;
27 $diaspora = NETWORK_DFRN;
29 if (!get_config('system','ostatus_disabled'))
30 $ostatus = NETWORK_OSTATUS;
32 $ostatus = NETWORK_DFRN;
35 if($mode === "community")
36 $extra_sql = " AND `community`";
40 $results = q("SELECT `contact`.`id` AS `cid`, `gcontact`.`url`, `gcontact`.`name`, `gcontact`.`nick`, `gcontact`.`photo`,
41 `gcontact`.`network`, `gcontact`.`keywords`, `gcontact`.`addr`, `gcontact`.`community`
43 LEFT JOIN `contact` ON `contact`.`nurl` = `gcontact`.`nurl`
44 AND `contact`.`uid` = %d AND NOT `contact`.`blocked`
45 AND NOT `contact`.`pending` AND `contact`.`rel` IN ('%s', '%s')
46 WHERE (`contact`.`id` > 0 OR (NOT `gcontact`.`hide` AND `gcontact`.`network` IN ('%s', '%s', '%s') AND
47 ((`gcontact`.`last_contact` >= `gcontact`.`last_failure`) OR (`gcontact`.`updated` >= `gcontact`.`last_failure`)))) AND
48 (`gcontact`.`name` REGEXP '%s' OR `gcontact`.`nick` REGEXP '%s') $extra_sql
49 GROUP BY `gcontact`.`nurl`
50 ORDER BY `gcontact`.`updated` DESC ",
51 intval(local_user()), dbesc(CONTACT_IS_SHARING), dbesc(CONTACT_IS_FRIEND),
52 dbesc(NETWORK_DFRN), dbesc($ostatus), dbesc($diaspora),
53 dbesc(escape_tags($search)), dbesc(escape_tags($search)));