]> git.mxchange.org Git - friendica.git/blobdiff - include/acl_selectors.php
Issue 3326: We are now completely working with utf8mb4
[friendica.git] / include / acl_selectors.php
index 4c0b610d4615c879792bebd8c7fa88f5e19b48d6..f4b644d68fb0201a322db05d497f324fe31f74df 100644 (file)
@@ -135,7 +135,7 @@ function contact_selector($selname, $selclass, $preselected = false, $options) {
                $o .= "<select name=\"{$selname}[]\" id=\"$selclass\" class=\"$selclass\" multiple=\"multiple\" size=\"" . $x['size'] . "$\" $tabindex >\r\n";
 
        $r = q("SELECT `id`, `name`, `url`, `network` FROM `contact`
-               WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0 AND `notify` != ''
+               WHERE `uid` = %d AND NOT `self` AND NOT `blocked` AND NOT `pending` AND NOT `archive` AND `notify` != ''
                $sql_extra
                ORDER BY `name` ASC ",
                intval(local_user())
@@ -210,7 +210,7 @@ function contact_select($selname, $selclass, $preselected = false, $size = 4, $p
                $o .= "<select name=\"{$selname}[]\" id=\"$selclass\" class=\"$selclass\" multiple=\"multiple\" size=\"$size\" $tabindex >\r\n";
 
        $r = q("SELECT `id`, `name`, `url`, `network` FROM `contact`
-               WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0 AND `notify` != ''
+               WHERE `uid` = %d AND NOT `self` AND NOT `blocked` AND NOT `pending` AND NOT `archive` AND `notify` != ''
                $sql_extra
                ORDER BY `name` ASC ",
                intval(local_user())
@@ -272,7 +272,7 @@ function prune_deadguys($arr) {
 
        $r = q("SELECT `id` FROM `contact` WHERE `id` IN ( " . $str . ") AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0 ");
 
-       if ($r) {
+       if (dbm::is_result($r)) {
                $ret = array();
                foreach ($r as $rr) {
                        $ret[] = intval($rr['id']);
@@ -372,7 +372,7 @@ function populate_acl($user = null, $show_jotnets = false) {
 
 }
 
-function construct_acl_data(&$a, $user) {
+function construct_acl_data(App $a, $user) {
 
        // Get group and contact information for html ACL selector
        $acl_data = acl_lookup($a, 'html');
@@ -404,7 +404,7 @@ function construct_acl_data(&$a, $user) {
 
 }
 
-function acl_lookup(&$a, $out_type = 'json') {
+function acl_lookup(App $a, $out_type = 'json') {
 
        if (!local_user()) {
                return '';
@@ -449,8 +449,8 @@ function acl_lookup(&$a, $out_type = 'json') {
        // autocomplete for editor mentions
        if ($type=='' || $type=='c'){
                $r = q("SELECT COUNT(*) AS c FROM `contact`
-                               WHERE `uid` = %d AND `self` = 0
-                               AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0
+                               WHERE `uid` = %d AND NOT `self`
+                               AND NOT `blocked` AND NOT `pending` AND NOT `archive`
                                AND `notify` != '' $sql_extra2" ,
                        intval(local_user())
                );
@@ -461,8 +461,8 @@ function acl_lookup(&$a, $out_type = 'json') {
                // autocomplete for Private Messages
 
                $r = q("SELECT COUNT(*) AS c FROM `contact`
-                               WHERE `uid` = %d AND `self` = 0
-                               AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0
+                               WHERE `uid` = %d AND NOT `self`
+                               AND NOT `blocked` AND NOT `pending` AND NOT `archive`
                                AND `network` IN ('%s','%s','%s') $sql_extra2" ,
                        intval(local_user()),
                        dbesc(NETWORK_DFRN),
@@ -477,8 +477,8 @@ function acl_lookup(&$a, $out_type = 'json') {
                // autocomplete for Contacts
 
                $r = q("SELECT COUNT(*) AS c FROM `contact`
-                               WHERE `uid` = %d AND `self` = 0
-                               AND `pending` = 0 $sql_extra2" ,
+                               WHERE `uid` = %d AND NOT `self`
+                               AND NOT `pending` $sql_extra2" ,
                        intval(local_user())
                );
                $contact_count = (int)$r[0]['c'];
@@ -495,6 +495,8 @@ function acl_lookup(&$a, $out_type = 'json') {
 
        if ($type=='' || $type=='g'){
 
+               /// @todo We should cache this query.
+               // This can be done when we can delete cache entries via wildcard
                $r = q("SELECT `group`.`id`, `group`.`name`, GROUP_CONCAT(DISTINCT `group_member`.`contact-id` SEPARATOR ',') AS uids
                                FROM `group`
                                INNER JOIN `group_member` ON `group_member`.`gid`=`group`.`id` AND `group_member`.`uid` = `group`.`uid`
@@ -525,7 +527,7 @@ function acl_lookup(&$a, $out_type = 'json') {
        if ($type==''){
 
                $r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag`, `forum`, `prv` FROM `contact`
-                       WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0 AND `notify` != ''
+                       WHERE `uid` = %d AND NOT `self` AND NOT `blocked` AND NOT `pending` AND NOT `archive` AND `notify` != ''
                        AND NOT (`network` IN ('%s', '%s'))
                        $sql_extra2
                        ORDER BY `name` ASC ",
@@ -536,7 +538,7 @@ function acl_lookup(&$a, $out_type = 'json') {
        elseif ($type=='c'){
 
                $r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag`, `forum`, `prv` FROM `contact`
-                       WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0 AND `notify` != ''
+                       WHERE `uid` = %d AND NOT `self` AND NOT `blocked` AND NOT `pending` AND NOT `archive` AND `notify` != ''
                        AND NOT (`network` IN ('%s'))
                        $sql_extra2
                        ORDER BY `name` ASC ",
@@ -546,7 +548,7 @@ function acl_lookup(&$a, $out_type = 'json') {
        }
        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
+                       WHERE `uid` = %d AND NOT `self` AND NOT `blocked` AND NOT `pending` AND NOT `archive`
                        AND `network` IN ('%s','%s','%s')
                        $sql_extra2
                        ORDER BY `name` ASC ",
@@ -585,9 +587,9 @@ function acl_lookup(&$a, $out_type = 'json') {
                );
                echo json_encode($o);
                killme();
-       }
-       else
+       } else {
                $r = array();
+       }
 
 
        if (dbm::is_result($r)) {
@@ -687,11 +689,11 @@ function acl_lookup(&$a, $out_type = 'json') {
 }
 /**
  * @brief Searching for global contacts for autocompletion
- * 
+ *
  * @param App $a
  * @return array with the search results
  */
-function navbar_complete(App &$a) {
+function navbar_complete(App $a) {
 
 //     logger('navbar_complete');