+ // 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'];
+ }
+ }
+ }
+
+ /// @TODO Not needed here?
+ return;
+}