1
1
Fork 0

contacts search autocomplete

This commit is contained in:
friendica 2012-06-05 20:33:11 -07:00
parent 5389efffa9
commit 49732114d7
2 changed files with 43 additions and 2 deletions

View file

@ -1,5 +1,6 @@
<?php <?php
/* ACL selector json backend */ /* ACL selector json backend */
require_once("include/acl_selectors.php"); require_once("include/acl_selectors.php");
function acl_init(&$a){ function acl_init(&$a){
@ -16,6 +17,7 @@ function acl_init(&$a){
// For use with jquery.autocomplete for private mail completion // For use with jquery.autocomplete for private mail completion
if(x($_REQUEST,'query') && strlen($_REQUEST['query'])) { if(x($_REQUEST,'query') && strlen($_REQUEST['query'])) {
if(! $type)
$type = 'm'; $type = 'm';
$search = $_REQUEST['query']; $search = $_REQUEST['query'];
} }
@ -62,6 +64,18 @@ function acl_init(&$a){
); );
$contact_count = (int)$r[0]['c']; $contact_count = (int)$r[0]['c'];
}
elseif ($type == 'a') {
// autocomplete for Contacts
$r = q("SELECT COUNT(`id`) AS c FROM `contact`
WHERE `uid` = %d AND `self` = 0
AND `pending` = 0 $sql_extra2" ,
intval(local_user())
);
$contact_count = (int)$r[0]['c'];
} else { } else {
$contact_count = 0; $contact_count = 0;
} }
@ -120,11 +134,19 @@ function acl_init(&$a){
dbesc(NETWORK_DIASPORA) dbesc(NETWORK_DIASPORA)
); );
} }
elseif($type == 'a') {
$r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag` FROM `contact`
WHERE `uid` = %d AND `pending` = 0
$sql_extra2
ORDER BY `name` ASC ",
intval(local_user())
);
}
else else
$r = array(); $r = array();
if($type == 'm') { if($type == 'm' || $type == 'a') {
$x = array(); $x = array();
$x['query'] = $search; $x['query'] = $search;
$x['photos'] = array(); $x['photos'] = array();

View file

@ -43,6 +43,25 @@ function contacts_init(&$a) {
$a->page['aside'] .= findpeople_widget(); $a->page['aside'] .= findpeople_widget();
$a->page['aside'] .= networks_widget('contacts',$_GET['nets']); $a->page['aside'] .= networks_widget('contacts',$_GET['nets']);
$base = $a->get_baseurl();
$a->page['htmlhead'] .= '<script src="' . $a->get_baseurl(true) . '/library/jquery_ac/friendica.complete.js" ></script>';
$a->page['htmlhead'] .= <<< EOT
<script>$(document).ready(function() {
var a;
a = $("#contacts-search").autocomplete({
serviceUrl: '$base/acl',
width: 350,
});
a.setOptions({ params: { type: 'a' }});
});
</script>
EOT;
} }
function contacts_post(&$a) { function contacts_post(&$a) {