4 * @file include/dir_fns.php
5 * @brief Functions for directory
9 * @brief Search global contact table by nick or name
11 * @param string $search
14 function dirsearch_global_by_name($search) {
17 // check supported networks
18 if (get_config('system','diaspora_enabled'))
19 $diaspora = NETWORK_DIASPORA;
21 $diaspora = NETWORK_DFRN;
23 if (!get_config('system','ostatus_disabled'))
24 $ostatus = NETWORK_OSTATUS;
26 $ostatus = NETWORK_DFRN;
28 $results = q("SELECT `contact`.`id` AS `cid`, `gcontact`.`url`, `gcontact`.`name`, `gcontact`.`nick`, `gcontact`.`photo`,
29 `gcontact`.`network`, `gcontact`.`keywords`, `gcontact`.`addr`
31 LEFT JOIN `contact` ON `contact`.`nurl` = `gcontact`.`nurl`
32 AND `contact`.`uid` = %d AND NOT `contact`.`blocked`
33 AND NOT `contact`.`pending` AND `contact`.`rel` IN ('%s', '%s')
34 WHERE (`contact`.`id` > 0 OR (NOT `gcontact`.`hide` AND `gcontact`.`network` IN ('%s', '%s', '%s') AND
35 ((`gcontact`.`last_contact` >= `gcontact`.`last_failure`) OR (`gcontact`.`updated` >= `gcontact`.`last_failure`)))) AND
36 (`gcontact`.`url` REGEXP '%s' OR `gcontact`.`name` REGEXP '%s' OR `gcontact`.`nick` REGEXP '%s'
38 GROUP BY `gcontact`.`nurl`
39 ORDER BY `gcontact`.`updated` DESC ",
40 intval(local_user()), dbesc(CONTACT_IS_SHARING), dbesc(CONTACT_IS_FRIEND),
41 dbesc(NETWORK_DFRN), dbesc($ostatus), dbesc($diaspora),
42 dbesc(escape_tags($search)), dbesc(escape_tags($search)), dbesc(escape_tags($search)));