X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Facl_selectors.php;h=71a42478ba92c06b80c02f6f3d332af6382deba4;hb=6ef69ad2dac6938643c8995dcbf39b63a7f235e2;hp=19197981e023681f1f0793cb0d4eeb38007a4af6;hpb=c42922f25f34f7d34fa50bc743680169542ac4a5;p=friendica.git diff --git a/include/acl_selectors.php b/include/acl_selectors.php index 19197981e0..71a42478ba 100644 --- a/include/acl_selectors.php +++ b/include/acl_selectors.php @@ -1,13 +1,15 @@ $g['photo'], + "photo" => 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), ); } } @@ -569,25 +577,6 @@ function acl_lookup(&$a, $out_type = 'json') { $r = array(); - if($type == 'm' || $type == 'a') { - $x = array(); - $x['query'] = $search; - $x['photos'] = array(); - $x['links'] = array(); - $x['suggestions'] = array(); - $x['data'] = array(); - if(count($r)) { - foreach($r as $g) { - $x['photos'][] = proxy_url($g['micro'], false, PROXY_SIZE_MICRO); - $x['links'][] = $g['url']; - $x['suggestions'][] = htmlentities($g['name']); - $x['data'][] = intval($g['id']); - } - } - echo json_encode($x); - killme(); - } - if(count($r)) { foreach($r as $g){ $contacts[] = array( @@ -598,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), ); } } @@ -611,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 ", @@ -652,29 +637,47 @@ 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'); @@ -683,41 +686,26 @@ function navbar_complete(&$a) { return; } - $local = get_config('system','poco_local_search'); - $local = true; + // 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(); - $star = false; - $address = false; - if(substr($search,0,1) === '@') $search = substr($search,1); - if(substr($search,0,1) === '*') { - $star = true; - $search = substr($search,1); - } - - if(strpos($search,'@') !== false) { - $address = true; - } - - if($local) { - require_once("include/dir_fns.php"); - $x = dirsearch_autocomplete($search); + if($localsearch) { + $x = DirSearch::global_search_by_name($search, $mode); return $x; } - if(! $local) { - require_once("include/dir_fns.php"); - $url = $directory['url'] . '/dirsearch'; - - + 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']) { @@ -729,4 +717,4 @@ function navbar_complete(&$a) { } } return; -} \ No newline at end of file +}