diff options
-rw-r--r-- | Zotlabs/Module/Connections.php | 14 | ||||
-rw-r--r-- | view/js/mod_connections.js | 4 | ||||
-rw-r--r-- | view/tpl/connections.tpl | 1 |
3 files changed, 14 insertions, 5 deletions
diff --git a/Zotlabs/Module/Connections.php b/Zotlabs/Module/Connections.php index ea30b9b9e..e0f463c76 100644 --- a/Zotlabs/Module/Connections.php +++ b/Zotlabs/Module/Connections.php @@ -145,6 +145,7 @@ class Connections extends \Zotlabs\Web\Controller { } $search = ((x($_REQUEST,'search')) ? notags(trim($_REQUEST['search'])) : ''); + $search_xchan = ((x($_REQUEST,'search_xchan')) ? notags(trim($_REQUEST['search_xchan'])) : ''); $tabs = array( /* @@ -233,10 +234,15 @@ class Connections extends \Zotlabs\Web\Controller { if($search) { $search_hdr = $search; - $search_txt = dbesc(protect_sprintf(preg_quote($search))); - $searching = true; + $search_txt = (($search_xchan) ? urldecode($search_xchan) : preg_quote($search)); + + if ($search_xchan) { + $sql_extra .= " AND xchan_hash = '" . protect_sprintf(dbesc($search_txt)) . "' "; + } + else { + $sql_extra .= " AND xchan_name LIKE '%%" . protect_sprintf(dbesc($search_txt)) . "%%' "; + } } - $sql_extra .= (($searching) ? protect_sprintf(" AND xchan_name like '%$search_txt%' ") : ""); if(isset($_REQUEST['gid']) && $_REQUEST['gid']) { $sql_extra .= " and xchan_hash in ( select xchan from pgrp_member where gid = " . intval($_REQUEST['gid']) . " and uid = " . intval(local_channel()) . " ) "; @@ -396,7 +402,7 @@ class Connections extends \Zotlabs\Web\Controller { '$search' => $search_hdr, '$label' => t('Search'), '$role_label' => t('Contact role'), - '$desc' => t('Search your connections'), + '$desc' => $search ?? t('Search your connections'), '$finding' => (($searching) ? t('Contact search') . ": '" . $search . "'" : ""), '$submit' => t('Find'), '$edit' => t('Edit'), diff --git a/view/js/mod_connections.js b/view/js/mod_connections.js index 848e9ed9f..cb3ecc922 100644 --- a/view/js/mod_connections.js +++ b/view/js/mod_connections.js @@ -1,5 +1,7 @@ $(document).ready(function() { - $("#contacts-search").contact_autocomplete(baseurl + '/acl', 'a', true); + $("#contacts-search").name_autocomplete(baseurl + '/acl', 'a', true, function(data) { + $("#contacts-search-xchan").val(data.xid); + }); $(".autotime").timeago(); }); diff --git a/view/tpl/connections.tpl b/view/tpl/connections.tpl index 5fec38a84..5fb6b0007 100644 --- a/view/tpl/connections.tpl +++ b/view/tpl/connections.tpl @@ -22,6 +22,7 @@ <form action="{{$cmd}}" method="get" name="contacts-search-form"> <div class="input-group mb-3"> <input type="text" name="search" id="contacts-search" class="form-control" onfocus="this.select();" value="{{$search}}" placeholder="{{$desc}}" /> + <input type="hidden" name="search_xchan" id="contacts-search-xchan" value=""/> <button id="contacts-search-submit" class="btn btn-primary" type="submit"><i class="fa fa-fw fa-search"></i></button> </div> </form> |