]> git.mxchange.org Git - friendica.git/blobdiff - mod/acl.php
Ensure *toArray returns an array
[friendica.git] / mod / acl.php
index 86eafe29028db053ed55d380db8869fa982ffb15..3649b03a39b7451642ffe3ad487364b8275799d4 100644 (file)
@@ -5,7 +5,7 @@
 use Friendica\App;
 use Friendica\Content\Widget;
 use Friendica\Core\ACL;
-use Friendica\Core\Addon;
+use Friendica\Core\Hook;
 use Friendica\Core\Logger;
 use Friendica\Core\Protocol;
 use Friendica\Database\DBA;
@@ -14,8 +14,6 @@ use Friendica\Model\Item;
 use Friendica\Util\Proxy as ProxyUtils;
 use Friendica\Util\Strings;
 
-require_once 'include/dba.php';
-
 function acl_content(App $a)
 {
        if (!local_user()) {
@@ -36,7 +34,7 @@ function acl_content(App $a)
                $search = $_REQUEST['query'];
        }
 
-       Logger::log("Searching for ".$search." - type ".$type." conversation ".$conv_id, Logger::DEBUG);
+       Logger::info('ACL {action} - {subaction}', ['module' => 'acl', 'action' => 'content', 'subaction' => 'search', 'search' => $search, 'type' => $type, 'conversation' => $conv_id]);
 
        if ($search != '') {
                $sql_extra = "AND `name` LIKE '%%" . DBA::escape($search) . "%%'";
@@ -49,7 +47,7 @@ function acl_content(App $a)
        // count groups and contacts
        $group_count = 0;
        if ($type == '' || $type == 'g') {
-               $r = q("SELECT COUNT(*) AS g FROM `group` WHERE `deleted` = 0 AND `uid` = %d $sql_extra",
+               $r = q("SELECT COUNT(*) AS g FROM `group` WHERE NOT `deleted` AND `uid` = %d $sql_extra",
                        intval(local_user())
                );
                $group_count = (int) $r[0]['g'];
@@ -61,9 +59,8 @@ function acl_content(App $a)
        if ($type == '' || $type == 'c') {
                // autocomplete for editor mentions
                $r = q("SELECT COUNT(*) AS c FROM `contact`
-                               WHERE `uid` = %d AND NOT `self`
+                               WHERE `uid` = %d AND NOT `self` AND NOT `deleted`
                                AND NOT `blocked` AND NOT `pending` AND NOT `archive`
-                               AND `success_update` >= `failure_update`
                                AND `notify` != '' $sql_extra2",
                        intval(local_user())
                );
@@ -71,10 +68,9 @@ function acl_content(App $a)
        } elseif ($type == 'f') {
                // autocomplete for editor mentions of forums
                $r = q("SELECT COUNT(*) AS c FROM `contact`
-                               WHERE `uid` = %d AND NOT `self`
+                               WHERE `uid` = %d AND NOT `self` AND NOT `deleted`
                                AND NOT `blocked` AND NOT `pending` AND NOT `archive`
                                AND (`forum` OR `prv`)
-                               AND `success_update` >= `failure_update`
                                AND `notify` != '' $sql_extra2",
                        intval(local_user())
                );
@@ -82,9 +78,8 @@ function acl_content(App $a)
        } elseif ($type == 'm') {
                // autocomplete for Private Messages
                $r = q("SELECT COUNT(*) AS c FROM `contact`
-                               WHERE `uid` = %d AND NOT `self`
+                               WHERE `uid` = %d AND NOT `self` AND NOT `deleted`
                                AND NOT `blocked` AND NOT `pending` AND NOT `archive`
-                               AND `success_update` >= `failure_update`
                                AND `network` IN ('%s', '%s', '%s') $sql_extra2",
                        intval(local_user()),
                        DBA::escape(Protocol::ACTIVITYPUB),
@@ -96,7 +91,7 @@ function acl_content(App $a)
                // autocomplete for Contacts
                $r = q("SELECT COUNT(*) AS c FROM `contact`
                                WHERE `uid` = %d AND NOT `self`
-                               AND NOT `pending` $sql_extra2",
+                               AND NOT `pending` AND NOT `deleted` $sql_extra2",
                        intval(local_user())
                );
                $contact_count = (int) $r[0]['c'];
@@ -142,8 +137,8 @@ function acl_content(App $a)
        $r = [];
        if ($type == '') {
                $r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag`, `addr`, `forum`, `prv`, (`prv` OR `forum`) AS `frm` FROM `contact`
-                               WHERE `uid` = %d AND NOT `self` AND NOT `blocked` AND NOT `pending` AND NOT `archive` AND `notify` != ''
-                               AND `success_update` >= `failure_update` AND NOT (`network` IN ('%s', '%s'))
+                               WHERE `uid` = %d AND NOT `self` AND NOT `deleted` AND NOT `blocked` AND NOT `pending` AND NOT `archive` AND `notify` != ''
+                               AND NOT (`network` IN ('%s', '%s'))
                                $sql_extra2
                                ORDER BY `name` ASC ",
                        intval(local_user()),
@@ -152,8 +147,8 @@ function acl_content(App $a)
                );
        } elseif ($type == 'c') {
                $r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag`, `addr`, `forum`, `prv` FROM `contact`
-                               WHERE `uid` = %d AND NOT `self` AND NOT `blocked` AND NOT `pending` AND NOT `archive` AND `notify` != ''
-                               AND `success_update` >= `failure_update` AND NOT (`network` IN ('%s'))
+                               WHERE `uid` = %d AND NOT `self` AND NOT `deleted` AND NOT `blocked` AND NOT `pending` AND NOT `archive` AND `notify` != ''
+                               AND NOT (`network` IN ('%s'))
                                $sql_extra2
                                ORDER BY `name` ASC ",
                        intval(local_user()),
@@ -161,8 +156,8 @@ function acl_content(App $a)
                );
        } elseif ($type == 'f') {
                $r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag`, `addr`, `forum`, `prv` FROM `contact`
-                               WHERE `uid` = %d AND NOT `self` AND NOT `blocked` AND NOT `pending` AND NOT `archive` AND `notify` != ''
-                               AND `success_update` >= `failure_update` AND NOT (`network` IN ('%s'))
+                               WHERE `uid` = %d AND NOT `self` AND NOT `deleted` AND NOT `blocked` AND NOT `pending` AND NOT `archive` AND `notify` != ''
+                               AND NOT (`network` IN ('%s'))
                                AND (`forum` OR `prv`)
                                $sql_extra2
                                ORDER BY `name` ASC ",
@@ -171,8 +166,8 @@ function acl_content(App $a)
                );
        } elseif ($type == 'm') {
                $r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag`, `addr` FROM `contact`
-                               WHERE `uid` = %d AND NOT `self` AND NOT `blocked` AND NOT `pending` AND NOT `archive`
-                               AND `success_update` >= `failure_update` AND `network` IN ('%s', '%s', '%s')
+                               WHERE `uid` = %d AND NOT `self` AND NOT `deleted` AND NOT `blocked` AND NOT `pending` AND NOT `archive`
+                               AND `network` IN ('%s', '%s', '%s')
                                $sql_extra2
                                ORDER BY `name` ASC ",
                        intval(local_user()),
@@ -182,7 +177,7 @@ function acl_content(App $a)
                );
        } elseif ($type == 'a') {
                $r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag`, `addr`, `forum`, `prv` FROM `contact`
-                               WHERE `uid` = %d AND `pending` = 0 AND `success_update` >= `failure_update`
+                               WHERE `uid` = %d AND NOT `deleted` AND NOT `pending` AND NOT `archive`
                                $sql_extra2
                                ORDER BY `name` ASC ",
                        intval(local_user())
@@ -307,7 +302,7 @@ function acl_content(App $a)
                'search'   => $search,
        ];
 
-       Addon::callHooks('acl_lookup_end', $results);
+       Hook::callAll('acl_lookup_end', $results);
 
        $o = [
                'tot'   => $results['tot'],