X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=include%2Facl_selectors.php;h=71a42478ba92c06b80c02f6f3d332af6382deba4;hb=31ad26aae2856fdf7921c53abb8ae525792a05d4;hp=69181b7359bcb1ab68af4e84892782156771bf8c;hpb=fe5705e5473c358359e6c78d596d4ad3d866cc26;p=friendica.git diff --git a/include/acl_selectors.php b/include/acl_selectors.php index 69181b7359..71a42478ba 100644 --- a/include/acl_selectors.php +++ b/include/acl_selectors.php @@ -1,13 +1,15 @@ proxy_url($g['photo'], false, PROXY_SIZE_MICRO), + "name" => $g['name'], + "nick" => (x($g['addr']) ? $g['addr'] : $g['url']), + "network" => $g['network'], + "link" => $g['url'], + "forum" => (x($g['community']) ? 1 : 0), + ); } } - echo json_encode($x); + $o = array( + 'start' => $start, + 'count' => $count, + 'items' => $contacts, + ); + echo json_encode($o); killme(); } + else + $r = array(); + if(count($r)) { foreach($r as $g){ @@ -578,7 +587,7 @@ function acl_lookup(&$a, $out_type = 'json') { "network" => $g['network'], "link" => $g['url'], "nick" => htmlentities(($g['attag']) ? $g['attag'] : $g['nick']), - "forum" => $g['forum'] + "forum" => ((x($g['forum']) || x($g['prv'])) ? 1 : 0), ); } } @@ -591,14 +600,10 @@ function acl_lookup(&$a, $out_type = 'json') { function _contact_link($i){ return dbesc($i['link']); } $known_contacts = array_map(_contact_link, $contacts); $unknow_contacts=array(); - $r = q("select - `author-avatar`,`author-name`,`author-link` - from item where parent=%d - and ( - `author-name` LIKE '%%%s%%' OR - `author-link` LIKE '%%%s%%' - ) and - `author-link` NOT IN ('%s') + $r = q("SELECT `author-avatar`,`author-name`,`author-link` + FROM `item` WHERE `parent` = %d + AND (`author-name` LIKE '%%%s%%' OR `author-link` LIKE '%%%s%%') + AND `author-link` NOT IN ('%s') GROUP BY `author-link` ORDER BY `author-name` ASC ", @@ -632,26 +637,84 @@ function acl_lookup(&$a, $out_type = 'json') { $tot += count($unknow_contacts); } + $results = array( + "tot" => $tot, + "start" => $start, + "count" => $count, + "groups" => $groups, + "contacts" => $contacts, + "items" => $items, + "type" => $type, + "search" => $search, + ); + + call_hooks('acl_lookup_end', $results); + if($out_type === 'html') { $o = array( - 'tot' => $tot, - 'start' => $start, - 'count' => $count, - 'groups' => $groups, - 'contacts' => $contacts, + 'tot' => $results["tot"], + 'start' => $results["start"], + 'count' => $results["count"], + 'groups' => $results["groups"], + 'contacts' => $results["contacts"], ); return $o; } $o = array( - 'tot' => $tot, - 'start' => $start, - 'count' => $count, - 'items' => $items, + 'tot' => $results["tot"], + 'start' => $results["start"], + 'count' => $results["count"], + 'items' => $results["items"], ); echo json_encode($o); killme(); } +/** + * @brief Searching for global contacts for autocompletion + * + * @param App $a + * @return array with the search results + */ +function navbar_complete(&$a) { + +// logger('navbar_complete'); + + if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) { + return; + } + + // check if searching in the local global contact table is enabled + $localsearch = get_config('system','poco_local_search'); + + $search = $prefix.notags(trim($_REQUEST['search'])); + $mode = $_REQUEST['smode']; + // don't search if search term has less than 2 characters + if(! $search || mb_strlen($search) < 2) + return array(); + + if(substr($search,0,1) === '@') + $search = substr($search,1); + + if($localsearch) { + $x = DirSearch::global_search_by_name($search, $mode); + return $x; + } + + if(! $localsearch) { + $p = (($a->pager['page'] != 1) ? '&p=' . $a->pager['page'] : ''); + + $x = z_fetch_url(get_server().'/lsearch?f=' . $p . '&search=' . urlencode($search)); + if($x['success']) { + $t = 0; + $j = json_decode($x['body'],true); + if($j && $j['results']) { + return $j['results']; + } + } + } + return; +}