Saved searches on the matrix/network page just got a lot more interesting. Hint: it's all about autocomplete
This commit is contained in:
parent
1f965f1b70
commit
f3d351621d
@ -64,7 +64,6 @@ function network_init(&$a) {
|
||||
}
|
||||
}
|
||||
|
||||
$group_id = ((x($_GET,'gid')) ? intval($_GET['gid']) : 0);
|
||||
|
||||
require_once('include/group.php');
|
||||
require_once('include/contact_widgets.php');
|
||||
@ -74,8 +73,10 @@ function network_init(&$a) {
|
||||
$a->page['aside'] = '';
|
||||
|
||||
$search = ((x($_GET,'search')) ? $_GET['search'] : '');
|
||||
|
||||
|
||||
if(x($_GET,'save')) {
|
||||
|
||||
if(x($_GET,'save') && $search) {
|
||||
$r = q("select * from `term` where `uid` = %d and `type` = %d and `term` = '%s' limit 1",
|
||||
intval(local_user()),
|
||||
intval(TERM_SAVEDSEARCH),
|
||||
@ -104,6 +105,28 @@ function network_init(&$a) {
|
||||
$a->page['aside'] .= saved_searches($search);
|
||||
$a->page['aside'] .= fileas_widget($a->get_baseurl(true) . '/network',(x($_GET, 'file') ? $_GET['file'] : ''));
|
||||
|
||||
|
||||
if($search) {
|
||||
if(strpos($search,'@') === 0) {
|
||||
$r = q("select abook_id from abook left join xchan on abook_xchan = xchan_hash where xchan_name = '%s' and abook_channel = %d limit 1",
|
||||
dbesc(substr($search,1)),
|
||||
intval(local_user())
|
||||
);
|
||||
if($r) {
|
||||
$_GET['cid'] = $r[0]['abook_id'];
|
||||
$search = $_GET['search'] = '';
|
||||
}
|
||||
}
|
||||
elseif(strpos($search,'#') === 0) {
|
||||
$search = $_GET['search'] = substr($search,1);
|
||||
}
|
||||
}
|
||||
|
||||
$group_id = ((x($_GET,'gid')) ? intval($_GET['gid']) : 0);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
function saved_searches($search) {
|
||||
@ -149,7 +172,7 @@ function saved_searches($search) {
|
||||
$o = replace_macros($tpl, array(
|
||||
'$title' => t('Saved Searches'),
|
||||
'$add' => t('add'),
|
||||
'$searchbox' => search($search,'netsearch-box',$srchurl,true),
|
||||
'$searchbox' => search('','netsearch-box',$srchurl,true),
|
||||
'$saved' => $saved,
|
||||
));
|
||||
|
||||
|
@ -27,42 +27,25 @@ function search_ac_init(&$a){
|
||||
// Priority to people searches
|
||||
|
||||
if ($search) {
|
||||
$people_sql_extra = protect_sprintf(" AND `name` LIKE '%". dbesc($search) . "%' ");
|
||||
$people_sql_extra = protect_sprintf(" AND `xchan_name` LIKE '%". dbesc($search) . "%' ");
|
||||
$tag_sql_extra = protect_sprintf(" AND term LIKE '%". dbesc($search) . "%' ");
|
||||
}
|
||||
// FIXME - this is whacked
|
||||
// $r = q("SELECT `id`, `name`, `micro`, `url` FROM `contact`
|
||||
// WHERE `uid` = %d AND `pending` = 0
|
||||
// $people_sql_extra
|
||||
// ORDER BY `name` ASC ",
|
||||
// intval(local_user())
|
||||
// );
|
||||
|
||||
// if($r) {
|
||||
// foreach($r as $g) {
|
||||
// $x['photos'][] = $g['micro'];
|
||||
// $x['links'][] = $g['url'];
|
||||
// $x['suggestions'][] = '@' . $g['name'];
|
||||
// $x['data'][] = intval($g['id']);
|
||||
// }
|
||||
// }
|
||||
// FIXME - extend search to non-connnections if you couldn't find any connections with that name, use poco or directory
|
||||
// else {
|
||||
//
|
||||
// $r = q("SELECT `id`, `name`, `photo`, `url` FROM `gcontact` where 1
|
||||
// $people_sql_extra
|
||||
// ORDER BY `name` ASC "
|
||||
// );
|
||||
|
||||
// if(count($r)) {
|
||||
// foreach($r as $g) {
|
||||
// $x['photos'][] = $g['photo'];
|
||||
// $x['links'][] = $g['url'];
|
||||
// $x['suggestions'][] = '@' . $g['name'];
|
||||
// $x['data'][] = intval($g['id']);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
$r = q("SELECT `abook_id`, `xchan_name`, `xchan_photo_s`, `xchan_url` FROM `abook` left join xchan on abook_xchan = xchan_hash WHERE abook_channel = %d
|
||||
$people_sql_extra
|
||||
ORDER BY `xchan_name` ASC ",
|
||||
intval(local_user())
|
||||
);
|
||||
|
||||
if($r) {
|
||||
foreach($r as $g) {
|
||||
$x['photos'][] = $g['xchan_photo_s'];
|
||||
$x['links'][] = $g['xchan_url'];
|
||||
$x['suggestions'][] = '@' . $g['xchan_name'];
|
||||
$x['data'][] = 'cid=' . intval($g['abook_id']);
|
||||
}
|
||||
}
|
||||
|
||||
$r = q("select distinct term, tid, url from term where type = %d $tag_sql_extra group by term order by term asc",
|
||||
intval(TERM_HASHTAG)
|
||||
|
Reference in New Issue
Block a user