]> git.mxchange.org Git - friendica.git/blobdiff - mod/acl.php
only show remove category to item owner
[friendica.git] / mod / acl.php
index 0fea6f7fc20d06ca3da216ba209409fd4f7e4aeb..88f150d7a02e02f8669617d2cbfb34183d0838e2 100644 (file)
@@ -7,15 +7,17 @@ function acl_init(&$a){
                return "";
 
 
-       $start = (x($_POST,'start')?$_POST['start']:0);
-       $count = (x($_POST,'count')?$_POST['count']:100);
-       $search = (x($_POST,'search')?$_POST['search']:"");
-       $type = (x($_POST,'type')?$_POST['type']:"");
+       $start = (x($_REQUEST,'start')?$_REQUEST['start']:0);
+       $count = (x($_REQUEST,'count')?$_REQUEST['count']:100);
+       $search = (x($_REQUEST,'search')?$_REQUEST['search']:"");
+       $type = (x($_REQUEST,'type')?$_REQUEST['type']:"");
        
 
        if ($search!=""){
                $sql_extra = "AND `name` LIKE '%%".dbesc($search)."%%'";
                $sql_extra2 = "AND (`attag` LIKE '%%".dbesc($search)."%%' OR `name` LIKE '%%".dbesc($search)."%%' OR `nick` LIKE '%%".dbesc($search)."%%')";
+       } else {
+               $sql_extra = $sql_extra2 = "";
        }
        
        // count groups and contacts
@@ -31,11 +33,27 @@ function acl_init(&$a){
        if ($type=='' || $type=='c'){
                $r = q("SELECT COUNT(`id`) AS c FROM `contact` 
                                WHERE `uid` = %d AND `self` = 0 
-                               AND `blocked` = 0 AND `pending` = 0 
-                               AND `notify` != '' $sql_extra" ,
+                               AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0
+                               AND `notify` != '' $sql_extra2" ,
                        intval(local_user())
                );
                $contact_count = (int)$r[0]['c'];
+       } 
+       elseif ($type == 'm') {
+
+               // autocomplete for Private Messages
+
+               $r = q("SELECT COUNT(`id`) AS c FROM `contact` 
+                               WHERE `uid` = %d AND `self` = 0 
+                               AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0 
+                               AND `network` IN ('%s','%s','%s') $sql_extra2" ,
+                       intval(local_user()),
+                       dbesc(NETWORK_DFRN),
+                       dbesc(NETWORK_ZOT),
+                       dbesc(NETWORK_DIASPORA)
+               );
+               $contact_count = (int)$r[0]['c'];
+
        } else {
                $contact_count = 0;
        }
@@ -64,7 +82,7 @@ function acl_init(&$a){
 //             logger('acl: group: ' . $g['name'] . ' members: ' . $g['uids']);                
                        $groups[] = array(
                                "type"  => "g",
-                               "photo" => "images/default-group-mm.png",
+                               "photo" => "images/twopeople.png",
                                "name"  => $g['name'],
                                "id"    => intval($g['id']),
                                "uids"  => array_map("intval", explode(",",$g['uids'])),
@@ -75,12 +93,29 @@ function acl_init(&$a){
        
        if ($type=='' || $type=='c'){
        
-               $r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url` FROM `contact` 
-                       WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 AND `pending` = 0 AND `notify` != ''
+               $r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag` FROM `contact` 
+                       WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0 AND `notify` != ''
                        $sql_extra2
                        ORDER BY `name` ASC ",
                        intval(local_user())
                );
+       }
+       elseif($type == 'm') {
+               $r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag` FROM `contact` 
+                       WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0
+                       AND `network` IN ('%s','%s','%s')
+                       $sql_extra2
+                       ORDER BY `name` ASC ",
+                       intval(local_user()),
+                       dbesc(NETWORK_DFRN),
+                       dbesc(NETWORK_ZOT),
+                       dbesc(NETWORK_DIASPORA)
+               );
+       }
+       else
+               $r = array();
+
+       if(count($r)) {
                foreach($r as $g){
                        $contacts[] = array(
                                "type"  => "c",
@@ -91,11 +126,9 @@ function acl_init(&$a){
                                "link" => $g['url'],
                                "nick" => ($g['attag']) ? $g['attag'] : $g['nick'],
                        );
-               }
-                       
+               }                       
        }
-       
-       
+               
        $items = array_merge($groups, $contacts);
        
        $o = array(