]> git.mxchange.org Git - friendica.git/blobdiff - src/Core/ACL.php
Merge pull request #10953 from annando/bott-shrinked
[friendica.git] / src / Core / ACL.php
index 5f69d78b683921cccca5c75a9d3a3340d1bd700e..347e8278f9eca5d3d1b2ab762e756fb382a9660c 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2020, Friendica
+ * @copyright Copyright (C) 2010-2021, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
@@ -26,12 +26,24 @@ use Friendica\Database\DBA;
 use Friendica\DI;
 use Friendica\Model\Contact;
 use Friendica\Model\Group;
+use Friendica\Model\User;
 
 /**
  * Handle ACL management and display
  */
 class ACL
 {
+       /**
+        * Returns the default lock state for the given user id
+        * @param int $uid 
+        * @return bool "true" if the default settings are non public
+        */
+       public static function getLockstateForUserId(int $uid)
+       {
+               $user = User::getById($uid, ['allow_cid', 'allow_gid', 'deny_cid', 'deny_gid']);
+               return !empty($user['allow_cid']) || !empty($user['allow_gid']) || !empty($user['deny_cid']) || !empty($user['deny_gid']);
+       }
+
        /**
         * Returns a select input tag for private message recipient
         *
@@ -50,8 +62,6 @@ class ACL
                $page->registerStylesheet(Theme::getPathForFile('js/friendica-tagsinput/friendica-tagsinput.css'));
                $page->registerStylesheet(Theme::getPathForFile('js/friendica-tagsinput/friendica-tagsinput-typeahead.css'));
 
-               // When used for private messages, we limit correspondence to mutual DFRN/Friendica friends and the selector
-               // to one recipient. By default our selector allows multiple selects amongst all contacts.
                $condition = [
                        'uid' => local_user(),
                        'self' => false,
@@ -60,7 +70,7 @@ class ACL
                        'archive' => false,
                        'deleted' => false,
                        'rel' => [Contact::FOLLOWER, Contact::SHARING, Contact::FRIEND],
-                       'network' => Protocol::FEDERATED,
+                       'network' => Protocol::SUPPORT_PRIVATE,
                ];
 
                $contacts = Contact::selectToArray(
@@ -144,6 +154,7 @@ class ACL
                                'archive' => false,
                                'deleted' => false,
                                'pending' => false,
+                               'network' => Protocol::FEDERATED,
                                'rel' => [Contact::FOLLOWER, Contact::FRIEND]
                        ], $condition),
                        $params
@@ -156,7 +167,7 @@ class ACL
 
                $acl_forums = Contact::selectToArray($fields,
                        ['uid' => $user_id, 'self' => false, 'blocked' => false, 'archive' => false, 'deleted' => false,
-                       'pending' => false, 'contact-type' => Contact::TYPE_COMMUNITY], $params
+                       'network' => Protocol::FEDERATED, 'pending' => false, 'contact-type' => Contact::TYPE_COMMUNITY], $params
                );
 
                $acl_contacts = array_merge($acl_forums, $acl_contacts);
@@ -209,7 +220,7 @@ class ACL
         * Return the full jot ACL selector HTML
         *
         * @param Page   $page
-        * @param array  $user                  User array
+        * @param int    $uid                   User ID
         * @param bool   $for_federation
         * @param array  $default_permissions   Static defaults permission array:
         *                                      [
@@ -225,18 +236,20 @@ class ACL
         */
        public static function getFullSelectorHTML(
                Page $page,
-               array $user = null,
+               int $uid = null,
                bool $for_federation = false,
                array $default_permissions = [],
                array $condition = [],
                $form_prefix = ''
        ) {
-               if (empty($user['uid'])) {
+               if (empty($uid)) {
                        return '';
                }
 
                static $input_group_id = 0;
 
+               $user = User::getById($uid);
+
                $input_group_id++;
 
                $page->registerFooterScript(Theme::getPathForFile('asset/typeahead.js/dist/typeahead.bundle.js'));