]> git.mxchange.org Git - friendica.git/commitdiff
contacts search autocomplete
authorfriendica <info@friendica.com>
Wed, 6 Jun 2012 03:33:11 +0000 (20:33 -0700)
committerfriendica <info@friendica.com>
Wed, 6 Jun 2012 03:33:11 +0000 (20:33 -0700)
mod/acl.php
mod/contacts.php

index 1e8898ab6f103f4fc2516a50bf2b91a3c83f106c..f3e46efa5610bc952a57aa240b86c384f73dd34d 100644 (file)
@@ -1,5 +1,6 @@
 <?php
 /* ACL selector json backend */
+
 require_once("include/acl_selectors.php");
 
 function acl_init(&$a){
@@ -16,7 +17,8 @@ function acl_init(&$a){
        // For use with jquery.autocomplete for private mail completion
 
        if(x($_REQUEST,'query') && strlen($_REQUEST['query'])) {
-               $type = 'm';
+               if(! $type)
+                       $type = 'm';
                $search = $_REQUEST['query'];
        }
 
@@ -62,6 +64,18 @@ function acl_init(&$a){
                );
                $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 {
                $contact_count = 0;
        }
@@ -120,11 +134,19 @@ function acl_init(&$a){
                        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
                $r = array();
 
 
-       if($type == 'm') {
+       if($type == 'm' || $type == 'a') {
                $x = array();
                $x['query'] = $search;
                $x['photos'] = array();
index 769239fe0cd81c62c5fd41cb1841978044fa1fbe..f5125a7fe6ed3bf721fb921d468a7a0fd0c561a3 100644 (file)
@@ -43,6 +43,25 @@ function contacts_init(&$a) {
        $a->page['aside'] .= findpeople_widget();
 
        $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) {