]> git.mxchange.org Git - friendica.git/blobdiff - include/acl_selectors.php
used more App::get_baseurl() instead of get_app()->get_baseurl().
[friendica.git] / include / acl_selectors.php
index 76f0e0b79609caf74d9c1a68bd11f0bea209b654..dc86ba03455f31f61190235c136bfb5ca1650194 100644 (file)
@@ -33,8 +33,8 @@ function group_select($selname,$selclass,$preselected = false,$size = 4) {
 
        call_hooks($a->module . '_pre_' . $selname, $arr);
 
-       if(count($r)) {
-               foreach($r as $rr) {
+       if (dbm::is_result($r)) {
+               foreach ($r as $rr) {
                        if((is_array($preselected)) && in_array($rr['id'], $preselected))
                                $selected = " selected=\"selected\" ";
                        else
@@ -144,8 +144,8 @@ function contact_selector($selname, $selclass, $preselected = false, $options) {
 
        call_hooks($a->module . '_pre_' . $selname, $arr);
 
-       if(count($r)) {
-               foreach($r as $rr) {
+       if (dbm::is_result($r)) {
+               foreach ($r as $rr) {
                        if((is_array($preselected)) && in_array($rr['id'], $preselected))
                                $selected = " selected=\"selected\" ";
                        else
@@ -220,17 +220,21 @@ function contact_select($selname, $selclass, $preselected = false, $size = 4, $p
 
        $receiverlist = array();
 
-       if(count($r)) {
-               foreach($r as $rr) {
-                       if((is_array($preselected)) && in_array($rr['id'], $preselected))
+       if (dbm::is_result($r)) {
+               foreach ($r as $rr) {
+                       if ((is_array($preselected)) && in_array($rr['id'], $preselected)) {
                                $selected = " selected=\"selected\" ";
-                       else
+                       }
+                       else {
                                $selected = '';
+                       }
 
-                       if($privmail)
+                       if ($privmail) {
                                $trimmed = GetProfileUsername($rr['url'], $rr['name'], false);
-                       else
+                       }
+                       else {
                                $trimmed = mb_substr($rr['name'],0,20);
+                       }
 
                        $receiverlist[] = $trimmed;
 
@@ -260,7 +264,7 @@ function prune_deadguys($arr) {
                return $arr;
        $str = dbesc(implode(',',$arr));
        $r = q("SELECT `id` FROM `contact` WHERE `id` IN ( " . $str . ") AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0 ");
-       if($r) {
+       if ($r) {
                $ret = array();
                foreach($r as $rr)
                        $ret[] = intval($rr['id']);
@@ -314,7 +318,7 @@ function populate_acl($user = null, $show_jotnets = false) {
                        $r = q("SELECT `pubmail` FROM `mailacct` WHERE `uid` = %d AND `server` != '' LIMIT 1",
                                intval(local_user())
                        );
-                       if(count($r)) {
+                       if (dbm::is_result($r)) {
                                $mail_enabled = true;
                                if(intval($r[0]['pubmail']))
                                        $pubmail_enabled = true;
@@ -392,8 +396,9 @@ function construct_acl_data(&$a, $user) {
 
 function acl_lookup(&$a, $out_type = 'json') {
 
-       if(!local_user())
-               return "";
+       if (!local_user()) {
+               return '';
+       }
 
        $start  =       (x($_REQUEST,'start')           ? $_REQUEST['start']            : 0);
        $count  =       (x($_REQUEST,'count')           ? $_REQUEST['count']            : 100);
@@ -481,11 +486,11 @@ function acl_lookup(&$a, $out_type = 'json') {
        if ($type=='' || $type=='g'){
 
                $r = q("SELECT `group`.`id`, `group`.`name`, GROUP_CONCAT(DISTINCT `group_member`.`contact-id` SEPARATOR ',') AS uids
-                               FROM `group`,`group_member`
-                               WHERE `group`.`deleted` = 0 AND `group`.`uid` = %d
-                                       AND `group_member`.`gid`=`group`.`id`
+                               FROM `group`
+                               INNER JOIN `group_member` ON `group_member`.`gid`=`group`.`id` AND `group_member`.`uid` = `group`.`uid`
+                               WHERE NOT `group`.`deleted` AND `group`.`uid` = %d
                                        $sql_extra
-                               GROUP BY `group`.`id`
+                               GROUP BY `group`.`name`
                                ORDER BY `group`.`name`
                                LIMIT %d,%d",
                        intval(local_user()),
@@ -553,7 +558,7 @@ function acl_lookup(&$a, $out_type = 'json') {
                // autocomplete for global contact search (e.g. navbar search)
                $r = navbar_complete($a);
                $contacts = array();
-               if($r) {
+               if ($r) {
                        foreach($r as $g) {
                                $contacts[] = array(
                                        "photo"    => proxy_url($g['photo'], false, PROXY_SIZE_MICRO),
@@ -577,7 +582,7 @@ function acl_lookup(&$a, $out_type = 'json') {
                $r = array();
 
 
-       if(count($r)) {
+       if (dbm::is_result($r)) {
                foreach($r as $g){
                        $contacts[] = array(
                                "type"  => "c",
@@ -612,7 +617,7 @@ function acl_lookup(&$a, $out_type = 'json') {
                                dbesc($search),
                                implode("','", $known_contacts)
                );
-               if (is_array($r) && count($r)){
+               if (dbm::is_result($r)){
                        foreach($r as $row) {
                                // nickname..
                                $up = parse_url($row['author-link']);