]> git.mxchange.org Git - friendica.git/blob - mod/qsearch.php
fix account_type
[friendica.git] / mod / qsearch.php
1 <?php
2
3 function qsearch_init(&$a) {
4
5         if(! local_user())
6                 killme();
7
8         $limit = (get_config('system','qsearch_limit') ? intval(get_config('system','qsearch_limit')) : 100);
9
10         $search = ((x($_GET,'s')) ? notags(trim(urldecode($_GET['s']))) : '');
11
12         if(! strlen($search))
13                 killme();
14
15
16         if($search)
17                 $search = dbesc($search);
18
19         $results = array();
20
21         $r = q("SELECT * FROM `group` WHERE `name` REGEXP '$search' AND `deleted` = 0 AND `uid` = %d LIMIT 0, %d ",
22                 intval(local_user()),
23                 intval($limit)
24         );
25
26         if(count($r)) {
27
28                 foreach($r as $rr)
29                         $results[] = array( 0, (int) $rr['id'], $rr['name'], '', '');
30         }
31
32         $sql_extra = ((strlen($search)) ? " AND (`name` REGEXP '$search' OR `nick` REGEXP '$search') " : "");
33
34
35         $r = q("SELECT * FROM `contact` WHERE `uid` = %d $sql_extra ORDER BY `name` ASC LIMIT 0, %d ",
36                 intval(local_user()),
37                 intval($limit)
38         );
39
40
41         if(count($r)) {
42
43                 foreach($r as $rr)
44                         $results[] = array( (int) $rr['id'], 0, $rr['name'],$rr['url'],$rr['photo']);
45         }
46
47         echo json_encode((object) $results);
48         killme();
49 }
50