diff options
author | redmatrix <mike@macgirvin.com> | 2016-09-28 20:55:15 -0700 |
---|---|---|
committer | redmatrix <mike@macgirvin.com> | 2016-09-28 20:55:15 -0700 |
commit | 5b6c2c32bff6c68ed5a35acf46f932aec6dad01d (patch) | |
tree | a715d586de0a256e82b58a9b0e560334eba1648e /Zotlabs/Module | |
parent | 245c2d4eed17a7c34c2b6d63f3db65b0f573b1f3 (diff) | |
download | volse-hubzilla-5b6c2c32bff6c68ed5a35acf46f932aec6dad01d.tar.gz volse-hubzilla-5b6c2c32bff6c68ed5a35acf46f932aec6dad01d.tar.bz2 volse-hubzilla-5b6c2c32bff6c68ed5a35acf46f932aec6dad01d.zip |
Bring the saved search feature in line with the spec, and publish the feature spec.
Diffstat (limited to 'Zotlabs/Module')
-rw-r--r-- | Zotlabs/Module/Search_ac.php | 95 |
1 files changed, 57 insertions, 38 deletions
diff --git a/Zotlabs/Module/Search_ac.php b/Zotlabs/Module/Search_ac.php index a3bc18054..24b724c5d 100644 --- a/Zotlabs/Module/Search_ac.php +++ b/Zotlabs/Module/Search_ac.php @@ -18,49 +18,68 @@ class Search_ac extends \Zotlabs\Web\Controller { $search = $_REQUEST['query']; } + $do_people = true; + $do_tags = true; + + if(substr($search,0,1) === '@') { + $do_tags = false; + $search = substr($search,1); + } + + if(substr($search,0,1) === '#') { + $do_people = false; + $search = substr($search,1); + } + // Priority to people searches if ($search) { - $people_sql_extra = protect_sprintf(" AND `xchan_name` LIKE '%". dbesc($search) . "%' "); - $tag_sql_extra = protect_sprintf(" AND term LIKE '%". dbesc($search) . "%' "); + $people_sql_extra = protect_sprintf(" AND xchan_name LIKE '%" . dbesc($search) . "%' "); + $tag_sql_extra = protect_sprintf(" AND term LIKE '%" . dbesc($search) . "%' "); } - - - $r = q("SELECT `abook_id`, `xchan_name`, `xchan_photo_s`, `xchan_url`, `xchan_addr` FROM `abook` left join xchan on abook_xchan = xchan_hash WHERE abook_channel = %d - $people_sql_extra - ORDER BY `xchan_name` ASC ", - intval(local_channel()) - ); - - $results = array(); - if($r) { - foreach($r as $g) { - $results[] = array( - "photo" => $g['xchan_photo_s'], - "name" => '@'.$g['xchan_name'], - "id" => $g['abook_id'], - "link" => $g['xchan_url'], - "label" => '', - "nick" => '', - ); + + $results = []; + + if($do_people) { + $r = q("SELECT abook_id, xchan_name, xchan_photo_s, xchan_url, xchan_addr FROM abook + left join xchan on abook_xchan = xchan_hash WHERE abook_channel = %d + $people_sql_extra + ORDER BY xchan_name ASC ", + intval(local_channel()) + ); + + if($r) { + foreach($r as $g) { + $results[] = [ + 'photo' => $g['xchan_photo_s'], + 'name' => '@' . $g['xchan_name'], + 'id' => $g['abook_id'], + 'link' => $g['xchan_url'], + 'label' => '', + 'nick' => '', + ]; + } } } - - $r = q("select distinct term, tid, url from term where ttype in ( %d, %d ) $tag_sql_extra group by term order by term asc", - intval(TERM_HASHTAG), - intval(TERM_COMMUNITYTAG) - ); - - if(count($r)) { - foreach($r as $g) { - $results[] = array( - "photo" => z_root() . '/images/hashtag.png', - "name" => '#'.$g['term'], - "id" => $g['tid'], - "link" => $g['url'], - "label" => '', - "nick" => '', - ); + + if($do_tags) { + $r = q("select distinct term, tid, url from term + where ttype in ( %d, %d ) $tag_sql_extra group by term order by term asc", + intval(TERM_HASHTAG), + intval(TERM_COMMUNITYTAG) + ); + + if($r) { + foreach($r as $g) { + $results[] = [ + 'photo' => z_root() . '/images/hashtag.png', + 'name' => '#' . $g['term'], + 'id' => $g['tid'], + 'link' => $g['url'], + 'label' => '', + 'nick' => '', + ]; + } } } @@ -72,7 +91,7 @@ class Search_ac extends \Zotlabs\Web\Controller { ); echo json_encode($o); - logger('search_ac: ' . print_r($x,true),LOGGER_ALL,LOG_INFO); + logger('search_ac: ' . print_r($x,true),LOGGER_DATA,LOG_INFO); killme(); } |