]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Contact.php
Merge pull request #11275 from MrPetovan/bug/11274-message-misdirected
[friendica.git] / src / Model / Contact.php
index 0af28a7401d4aa396d27fa8b57d2464171bf2e5e..d80827c93f9e60c61467d284267c1d57ea4630b2 100644 (file)
@@ -685,7 +685,7 @@ class Contact
         */
        public static function updateSelfFromUserID($uid, $update_avatar = false)
        {
-               $fields = ['id', 'name', 'nick', 'location', 'about', 'keywords', 'avatar', 'prvkey', 'pubkey',
+               $fields = ['id', 'name', 'nick', 'location', 'about', 'keywords', 'avatar', 'prvkey', 'pubkey', 'manually-approve',
                        'xmpp', 'matrix', 'contact-type', 'forum', 'prv', 'avatar-date', 'url', 'nurl', 'unsearchable',
                        'photo', 'thumb', 'micro', 'header', 'addr', 'request', 'notify', 'poll', 'confirm', 'poco', 'network'];
                $self = DBA::selectFirst('contact', $fields, ['uid' => $uid, 'self' => true]);
@@ -757,6 +757,7 @@ class Contact
                $fields['forum'] = $user['page-flags'] == User::PAGE_FLAGS_COMMUNITY;
                $fields['prv'] = $user['page-flags'] == User::PAGE_FLAGS_PRVGROUP;
                $fields['unsearchable'] = !$profile['net-publish'];
+               $fields['manually-approve'] = in_array($user['page-flags'], [User::PAGE_FLAGS_NORMAL, User::PAGE_FLAGS_PRVGROUP]);
 
                $update = false;
 
@@ -1457,34 +1458,11 @@ class Contact
         *
         * The function can be called with either the user or the contact array
         *
-        * @param array $contact contact or user array
+        * @param int $type type of contact or account
         * @return string
         */
-       public static function getAccountType(array $contact)
-       {
-               // There are several fields that indicate that the contact or user is a forum
-               // "page-flags" is a field in the user table,
-               // "forum" and "prv" are used in the contact table. They stand for User::PAGE_FLAGS_COMMUNITY and User::PAGE_FLAGS_PRVGROUP.
-               if ((isset($contact['page-flags']) && (intval($contact['page-flags']) == User::PAGE_FLAGS_COMMUNITY))
-                       || (isset($contact['page-flags']) && (intval($contact['page-flags']) == User::PAGE_FLAGS_PRVGROUP))
-                       || (isset($contact['forum']) && intval($contact['forum']))
-                       || (isset($contact['prv']) && intval($contact['prv']))
-                       || (isset($contact['community']) && intval($contact['community']))
-               ) {
-                       $type = self::TYPE_COMMUNITY;
-               } else {
-                       $type = self::TYPE_PERSON;
-               }
-
-               // The "contact-type" (contact table) and "account-type" (user table) are more general then the chaos from above.
-               if (isset($contact["contact-type"])) {
-                       $type = $contact["contact-type"];
-               }
-
-               if (isset($contact["account-type"])) {
-                       $type = $contact["account-type"];
-               }
-
+       public static function getAccountType(int $type)
+       {
                switch ($type) {
                        case self::TYPE_ORGANISATION:
                                $account_type = DI::l10n()->t("Organisation");
@@ -2947,7 +2925,7 @@ class Contact
         */
        public static function isForum($contactid)
        {
-               $fields = ['contact-type', 'forum', 'prv'];
+               $fields = ['contact-type'];
                $condition = ['id' => $contactid];
                $contact = DBA::selectFirst('contact', $fields, $condition);
                if (!DBA::isResult($contact)) {
@@ -2955,7 +2933,7 @@ class Contact
                }
 
                // Is it a forum?
-               return (($contact['contact-type'] == self::TYPE_COMMUNITY) || $contact['forum'] || $contact['prv']);
+               return ($contact['contact-type'] == self::TYPE_COMMUNITY);
        }
 
        /**