]> git.mxchange.org Git - friendica.git/commitdiff
Move Contact::Page_* constants to User::PAGE_FLAGS_*
authorHypolite Petovan <hypolite@mrpetovan.com>
Sun, 6 Jan 2019 17:37:48 +0000 (12:37 -0500)
committerHypolite Petovan <hypolite@mrpetovan.com>
Mon, 21 Jan 2019 15:55:37 +0000 (10:55 -0500)
23 files changed:
include/enotify.php
mod/admin.php
mod/dfrn_confirm.php
mod/dfrn_notify.php
mod/dfrn_request.php
mod/hcard.php
mod/photos.php
mod/profile.php
mod/profiles.php
mod/settings.php
mod/videos.php
mod/wall_attach.php
mod/wall_upload.php
src/Content/Nav.php
src/Model/Contact.php
src/Model/Item.php
src/Model/User.php
src/Object/Image.php
src/Protocol/ActivityPub/Transmitter.php
src/Protocol/DFRN.php
src/Protocol/Diaspora.php
src/Util/Security.php
update.php

index be8552ed6e710477bcbc2b97ffdcc76314e2b5b2..80e6782c2dcc74303f22f5dc91b827aa8150aff9 100644 (file)
@@ -78,7 +78,7 @@ function notification($params)
                        ['uid' => $params['uid']]);
 
                // There is no need to create notifications for forum accounts
-               if (!DBA::isResult($user) || in_array($user["page-flags"], [Contact::PAGE_COMMUNITY, Contact::PAGE_PRVGROUP])) {
+               if (!DBA::isResult($user) || in_array($user["page-flags"], [User::PAGE_FLAGS_COMMUNITY, User::PAGE_FLAGS_PRVGROUP])) {
                        return;
                }
                $nickname = $user["nickname"];
index e5df09d0eac7e8d8cbb8e369b29b71e30eeb09ff..e20e9c341f7aca4e9d62b6a7df7e087e1447bd67 100644 (file)
@@ -1988,11 +1988,11 @@ function admin_page_users(App $a)
        $adminlist = explode(",", str_replace(" ", "", Config::get('config', 'admin_email')));
        $_setup_users = function ($e) use ($adminlist) {
                $page_types = [
-                       Contact::PAGE_NORMAL    => L10n::t('Normal Account Page'),
-                       Contact::PAGE_SOAPBOX   => L10n::t('Soapbox Page'),
-                       Contact::PAGE_COMMUNITY => L10n::t('Public Forum'),
-                       Contact::PAGE_FREELOVE  => L10n::t('Automatic Friend Page'),
-                       Contact::PAGE_PRVGROUP  => L10n::t('Private Forum')
+                       User::PAGE_FLAGS_NORMAL    => L10n::t('Normal Account Page'),
+                       User::PAGE_FLAGS_SOAPBOX   => L10n::t('Soapbox Page'),
+                       User::PAGE_FLAGS_COMMUNITY => L10n::t('Public Forum'),
+                       User::PAGE_FLAGS_FREELOVE  => L10n::t('Automatic Friend Page'),
+                       User::PAGE_FLAGS_PRVGROUP  => L10n::t('Private Forum')
                ];
                $account_types = [
                        Contact::ACCOUNT_TYPE_PERSON       => L10n::t('Personal Page'),
index 2059e14034eef49b0e49c2ec003aebddf7f7432e..770c7070b44fea2ad68df07da10f1e568783ee3c 100644 (file)
@@ -202,11 +202,11 @@ function dfrn_confirm_post(App $a, $handsfree = null)
                                $params['duplex'] = 1;
                        }
 
-                       if ($user['page-flags'] == Contact::PAGE_COMMUNITY) {
+                       if ($user['page-flags'] == User::PAGE_FLAGS_COMMUNITY) {
                                $params['page'] = 1;
                        }
 
-                       if ($user['page-flags'] == Contact::PAGE_PRVGROUP) {
+                       if ($user['page-flags'] == User::PAGE_FLAGS_PRVGROUP) {
                                $params['page'] = 2;
                        }
 
index 41b7684ac64f7392b2e6d9f9d55b5b916cbb5068..ac62d745342b8322ee0b8d0900b0c81b865c125d 100644 (file)
@@ -351,7 +351,7 @@ function dfrn_notify_content(App $a) {
                        $rino = $rino_remote;
                }
 
-               if (($importer['rel'] && ($importer['rel'] != Contact::SHARING)) || ($importer['page-flags'] == Contact::PAGE_COMMUNITY)) {
+               if (($importer['rel'] && ($importer['rel'] != Contact::SHARING)) || ($importer['page-flags'] == User::PAGE_FLAGS_COMMUNITY)) {
                        $perm = 'rw';
                } else {
                        $perm = 'r';
index 7c76af1b6a2acf923eed7a42db1fd8bfeec22bec..6142257e77fd0083f9b80205450580452c67be56 100644 (file)
@@ -544,7 +544,7 @@ function dfrn_request_content(App $a)
                        $auto_confirm = false;
 
                        if (DBA::isResult($r)) {
-                               if ($r[0]['page-flags'] != Contact::PAGE_NORMAL && $r[0]['page-flags'] != Contact::PAGE_PRVGROUP) {
+                               if ($r[0]['page-flags'] != User::PAGE_FLAGS_NORMAL && $r[0]['page-flags'] != User::PAGE_FLAGS_PRVGROUP) {
                                        $auto_confirm = true;
                                }
 
@@ -572,7 +572,7 @@ function dfrn_request_content(App $a)
                                                'node'     => $r[0]['nickname'],
                                                'dfrn_id'  => $r[0]['issued-id'],
                                                'intro_id' => $intro[0]['id'],
-                                               'duplex'   => (($r[0]['page-flags'] == Contact::PAGE_FREELOVE) ? 1 : 0),
+                                               'duplex'   => (($r[0]['page-flags'] == User::PAGE_FLAGS_FREELOVE) ? 1 : 0),
                                        ];
                                        dfrn_confirm_post($a, $handsfree);
                                }
@@ -623,7 +623,7 @@ function dfrn_request_content(App $a)
                 * because nobody is going to read the comments and
                 * it doesn't matter if they know you or not.
                 */
-               if ($a->profile['page-flags'] == Contact::PAGE_NORMAL) {
+               if ($a->profile['page-flags'] == User::PAGE_FLAGS_NORMAL) {
                        $tpl = Renderer::getMarkupTemplate('dfrn_request.tpl');
                } else {
                        $tpl = Renderer::getMarkupTemplate('auto_request.tpl');
index c8b6db455c6e4dab2d1325558c751f3eb6bb1e2a..9a0c969ae49e2dd3af615c725a069e6fa1aec0f9 100644 (file)
@@ -29,7 +29,7 @@ function hcard_init(App $a)
 
        Profile::load($a, $which, $profile);
 
-       if (!empty($a->profile['page-flags']) && ($a->profile['page-flags'] == Contact::PAGE_COMMUNITY)) {
+       if (!empty($a->profile['page-flags']) && ($a->profile['page-flags'] == User::PAGE_FLAGS_COMMUNITY)) {
                $a->page['htmlhead'] .= '<meta name="friendica.community" content="true" />';
        }
        if (!empty($a->profile['openidserver'])) {
index 31b026f8995a40536a99dad17033be5e7898d6d0..2171309e8f6165c03bfa0d4e2b1766ff7c6ac0c7 100644 (file)
@@ -153,7 +153,7 @@ function photos_post(App $a)
        $visitor   = 0;
 
        $page_owner_uid = $a->data['user']['uid'];
-       $community_page = $a->data['user']['page-flags'] == Contact::PAGE_COMMUNITY;
+       $community_page = $a->data['user']['page-flags'] == User::PAGE_FLAGS_COMMUNITY;
 
        if (local_user() && (local_user() == $page_owner_uid)) {
                $can_post = true;
@@ -938,7 +938,7 @@ function photos_content(App $a)
 
        $owner_uid = $a->data['user']['uid'];
 
-       $community_page = (($a->data['user']['page-flags'] == Contact::PAGE_COMMUNITY) ? true : false);
+       $community_page = (($a->data['user']['page-flags'] == User::PAGE_FLAGS_COMMUNITY) ? true : false);
 
        if (local_user() && (local_user() == $owner_uid)) {
                $can_post = true;
index 8a21e24dc1e7e37067a9158c850d982503b0c37c..e6b7f453c3e5a6f6f933e8ff830ee7d73ad51f4f 100644 (file)
@@ -62,7 +62,7 @@ function profile_init(App $a)
        $blocked   = !local_user() && !remote_user() && Config::get('system', 'block_public');
        $userblock = !local_user() && !remote_user() && $a->profile['hidewall'];
 
-       if (!empty($a->profile['page-flags']) && $a->profile['page-flags'] == Contact::PAGE_COMMUNITY) {
+       if (!empty($a->profile['page-flags']) && $a->profile['page-flags'] == User::PAGE_FLAGS_COMMUNITY) {
                $a->page['htmlhead'] .= '<meta name="friendica.community" content="true" />';
        }
 
@@ -172,7 +172,7 @@ function profile_content(App $a, $update = 0)
 
                $o .= Widget::commonFriendsVisitor($a->profile['profile_uid']);
 
-               $commpage = $a->profile['page-flags'] == Contact::PAGE_COMMUNITY;
+               $commpage = $a->profile['page-flags'] == User::PAGE_FLAGS_COMMUNITY;
                $commvisitor = $commpage && $remote_contact;
 
                $a->page['aside'] .= posted_date_widget(System::baseUrl(true) . '/profile/' . $a->profile['nickname'], $a->profile['profile_uid'], true);
@@ -256,7 +256,7 @@ function profile_content(App $a, $update = 0)
 
                // Does the profile page belong to a forum?
                // If not then we can improve the performance with an additional condition
-               $condition = ['uid' => $a->profile['profile_uid'], 'page-flags' => [Contact::PAGE_COMMUNITY, Contact::PAGE_PRVGROUP]];
+               $condition = ['uid' => $a->profile['profile_uid'], 'page-flags' => [User::PAGE_FLAGS_COMMUNITY, User::PAGE_FLAGS_PRVGROUP]];
                if (!DBA::exists('user', $condition)) {
                        $sql_extra3 = sprintf(" AND `thread`.`contact-id` = %d ", intval(intval($a->profile['contact_id'])));
                } else {
index b56a7911d3f7612371bb4b170fc5280e1920cd49..add9d50852b6f8e02dfead7e21474fdfe58f4c9e 100644 (file)
@@ -532,7 +532,7 @@ function profiles_content(App $a) {
                ]);
 
                $personal_account = !(in_array($a->user["page-flags"],
-                                       [Contact::PAGE_COMMUNITY, Contact::PAGE_PRVGROUP]));
+                                       [User::PAGE_FLAGS_COMMUNITY, User::PAGE_FLAGS_PRVGROUP]));
 
                $detailled_profile = (PConfig::get(local_user(), 'system', 'detailled_profile') AND $personal_account);
 
index 567270c6ea24936b7e28be4423e105600ef71878..8aba6809f23618c421d79870e8c930e2d2c5fd17 100644 (file)
@@ -474,14 +474,14 @@ function settings_post(App $a)
        }
 
        // Adjust the page flag if the account type doesn't fit to the page flag.
-       if (($account_type == Contact::ACCOUNT_TYPE_PERSON) && !in_array($page_flags, [Contact::PAGE_NORMAL, Contact::PAGE_SOAPBOX, Contact::PAGE_FREELOVE])) {
-               $page_flags = Contact::PAGE_NORMAL;
-       } elseif (($account_type == Contact::ACCOUNT_TYPE_ORGANISATION) && !in_array($page_flags, [Contact::PAGE_SOAPBOX])) {
-               $page_flags = Contact::PAGE_SOAPBOX;
-       } elseif (($account_type == Contact::ACCOUNT_TYPE_NEWS) && !in_array($page_flags, [Contact::PAGE_SOAPBOX])) {
-               $page_flags = Contact::PAGE_SOAPBOX;
-       } elseif (($account_type == Contact::ACCOUNT_TYPE_COMMUNITY) && !in_array($page_flags, [Contact::PAGE_COMMUNITY, Contact::PAGE_PRVGROUP])) {
-               $page_flags = Contact::PAGE_COMMUNITY;
+       if (($account_type == Contact::ACCOUNT_TYPE_PERSON) && !in_array($page_flags, [User::PAGE_FLAGS_NORMAL, User::PAGE_FLAGS_SOAPBOX, User::PAGE_FLAGS_FREELOVE])) {
+               $page_flags = User::PAGE_FLAGS_NORMAL;
+       } elseif (($account_type == Contact::ACCOUNT_TYPE_ORGANISATION) && !in_array($page_flags, [User::PAGE_FLAGS_SOAPBOX])) {
+               $page_flags = User::PAGE_FLAGS_SOAPBOX;
+       } elseif (($account_type == Contact::ACCOUNT_TYPE_NEWS) && !in_array($page_flags, [User::PAGE_FLAGS_SOAPBOX])) {
+               $page_flags = User::PAGE_FLAGS_SOAPBOX;
+       } elseif (($account_type == Contact::ACCOUNT_TYPE_COMMUNITY) && !in_array($page_flags, [User::PAGE_FLAGS_COMMUNITY, User::PAGE_FLAGS_PRVGROUP])) {
+               $page_flags = User::PAGE_FLAGS_COMMUNITY;
        }
 
        $err = '';
@@ -555,7 +555,7 @@ function settings_post(App $a)
        PConfig::set(local_user(), 'system', 'email_textonly', $email_textonly);
        PConfig::set(local_user(), 'system', 'detailed_notif', $detailed_notif);
 
-       if ($page_flags == Contact::PAGE_PRVGROUP) {
+       if ($page_flags == User::PAGE_FLAGS_PRVGROUP) {
                $hidewall = 1;
                if (!$str_contact_allow && !$str_group_allow && !$str_contact_deny && !$str_group_deny) {
                        if ($def_gid) {
@@ -1014,7 +1014,7 @@ function settings_content(App $a)
 
        // Set the account type to "Community" when the page is a community page but the account type doesn't fit
        // This is only happening on the first visit after the update
-       if (in_array($a->user['page-flags'], [Contact::PAGE_COMMUNITY, Contact::PAGE_PRVGROUP]) &&
+       if (in_array($a->user['page-flags'], [User::PAGE_FLAGS_COMMUNITY, User::PAGE_FLAGS_PRVGROUP]) &&
                ($a->user['account-type'] != Contact::ACCOUNT_TYPE_COMMUNITY))
                $a->user['account-type'] = Contact::ACCOUNT_TYPE_COMMUNITY;
 
@@ -1046,25 +1046,25 @@ function settings_content(App $a)
                                                                        L10n::t('Account for community discussions.'),
                                                                        ($a->user['account-type'] == Contact::ACCOUNT_TYPE_COMMUNITY)],
 
-               '$page_normal'          => ['page-flags', L10n::t('Normal Account Page'), Contact::PAGE_NORMAL,
+               '$page_normal'          => ['page-flags', L10n::t('Normal Account Page'), User::PAGE_FLAGS_NORMAL,
                                                                        L10n::t('Account for a regular personal profile that requires manual approval of "Friends" and "Followers".'),
-                                                                       ($a->user['page-flags'] == Contact::PAGE_NORMAL)],
+                                                                       ($a->user['page-flags'] == User::PAGE_FLAGS_NORMAL)],
 
-               '$page_soapbox'         => ['page-flags', L10n::t('Soapbox Page'), Contact::PAGE_SOAPBOX,
+               '$page_soapbox'         => ['page-flags', L10n::t('Soapbox Page'), User::PAGE_FLAGS_SOAPBOX,
                                                                        L10n::t('Account for a public profile that automatically approves contact requests as "Followers".'),
-                                                                       ($a->user['page-flags'] == Contact::PAGE_SOAPBOX)],
+                                                                       ($a->user['page-flags'] == User::PAGE_FLAGS_SOAPBOX)],
 
-               '$page_community'       => ['page-flags', L10n::t('Public Forum'), Contact::PAGE_COMMUNITY,
+               '$page_community'       => ['page-flags', L10n::t('Public Forum'), User::PAGE_FLAGS_COMMUNITY,
                                                                        L10n::t('Automatically approves all contact requests.'),
-                                                                       ($a->user['page-flags'] == Contact::PAGE_COMMUNITY)],
+                                                                       ($a->user['page-flags'] == User::PAGE_FLAGS_COMMUNITY)],
 
-               '$page_freelove'        => ['page-flags', L10n::t('Automatic Friend Page'), Contact::PAGE_FREELOVE,
+               '$page_freelove'        => ['page-flags', L10n::t('Automatic Friend Page'), User::PAGE_FLAGS_FREELOVE,
                                                                        L10n::t('Account for a popular profile that automatically approves contact requests as "Friends".'),
-                                                                       ($a->user['page-flags'] == Contact::PAGE_FREELOVE)],
+                                                                       ($a->user['page-flags'] == User::PAGE_FLAGS_FREELOVE)],
 
-               '$page_prvgroup'        => ['page-flags', L10n::t('Private Forum [Experimental]'), Contact::PAGE_PRVGROUP,
+               '$page_prvgroup'        => ['page-flags', L10n::t('Private Forum [Experimental]'), User::PAGE_FLAGS_PRVGROUP,
                                                                        L10n::t('Requires manual approval of contact requests.'),
-                                                                       ($a->user['page-flags'] == Contact::PAGE_PRVGROUP)],
+                                                                       ($a->user['page-flags'] == User::PAGE_FLAGS_PRVGROUP)],
 
 
        ]);
index df0fb237569882712791a0f21d30994008dab2fd..1d37b76bd6d3397e8bd8ff6e87540846e80ef580 100644 (file)
@@ -178,7 +178,7 @@ function videos_content(App $a)
 
        $owner_uid = $a->data['user']['uid'];
 
-       $community_page = (($a->data['user']['page-flags'] == Contact::PAGE_COMMUNITY) ? true : false);
+       $community_page = (($a->data['user']['page-flags'] == User::PAGE_FLAGS_COMMUNITY) ? true : false);
 
        if ((local_user()) && (local_user() == $owner_uid)) {
                $can_post = true;
index fb665ac2fa49c56518dcf90f0efb8f3d8fbd7b8d..4a4d1edc532af179de370093112c58ca408cf0c8 100644 (file)
@@ -41,7 +41,7 @@ function wall_attach_post(App $a) {
 
        $page_owner_uid   = $r[0]['uid'];
        $page_owner_cid   = $r[0]['id'];
-       $community_page   = (($r[0]['page-flags'] == Contact::PAGE_COMMUNITY) ? true : false);
+       $community_page   = (($r[0]['page-flags'] == User::PAGE_FLAGS_COMMUNITY) ? true : false);
 
        if ((local_user()) && (local_user() == $page_owner_uid)) {
                $can_post = true;
index ea06b1d1c1a2deefb5e3c48f1c3777e9cb54a19c..84da85598490ebbe8dbfbc62cd219a34d873ac7c 100644 (file)
@@ -69,7 +69,7 @@ function wall_upload_post(App $a, $desktopmode = true)
        $page_owner_uid   = $r[0]['uid'];
        $default_cid      = $r[0]['id'];
        $page_owner_nick  = $r[0]['nickname'];
-       $community_page   = (($r[0]['page-flags'] == Contact::PAGE_COMMUNITY) ? true : false);
+       $community_page   = (($r[0]['page-flags'] == User::PAGE_FLAGS_COMMUNITY) ? true : false);
 
        if ((local_user()) && (local_user() == $page_owner_uid)) {
                $can_post = true;
index 51cee03bf84a7ab5e03a7da10095e46f1135a85e..6bee0633f3774aec0d37726ee25a66bb3fe265b5 100644 (file)
@@ -242,7 +242,7 @@ class Nav
                        $nav['home'] = ['profile/' . $a->user['nickname'], L10n::t('Home'), '', L10n::t('Your posts and conversations')];
 
                        // Don't show notifications for public communities
-                       if (defaults($_SESSION, 'page_flags', '') != Contact::PAGE_COMMUNITY) {
+                       if (defaults($_SESSION, 'page_flags', '') != User::PAGE_FLAGS_COMMUNITY) {
                                $nav['introductions'] = ['notifications/intros', L10n::t('Introductions'), '', L10n::t('Friend Requests')];
                                $nav['notifications'] = ['notifications',       L10n::t('Notifications'), '', L10n::t('Notifications')];
                                $nav['notifications']['all'] = ['notifications/system', L10n::t('See all notifications'), '', ''];
index f3448569b6fdba0845f4145d8566a7a420e1375f..745bbacaddfa828b15dd16c12e6896db76360979 100644 (file)
@@ -32,15 +32,8 @@ use Friendica\Util\Strings;
 class Contact extends BaseObject
 {
        /**
-        * Page/profile types
-        *
-        * PAGE_NORMAL is a typical personal profile account
-        * PAGE_SOAPBOX automatically approves all friend requests as Contact::SHARING, (readonly)
-        * PAGE_COMMUNITY automatically approves all friend requests as Contact::SHARING, but with
-        *      write access to wall and comments (no email and not included in page owner's ACL lists)
-        * PAGE_FREELOVE automatically approves all friend requests as full friends (Contact::FRIEND).
-        *
-        * @{
+        * @deprecated since version 2019.03
+        * @see User::PAGE_FLAGS_NORMAL
         */
        const PAGE_NORMAL    = 0;
        const PAGE_SOAPBOX   = 1;
@@ -48,6 +41,32 @@ class Contact extends BaseObject
        const PAGE_FREELOVE  = 3;
        const PAGE_BLOG      = 4;
        const PAGE_PRVGROUP  = 5;
+       const PAGE_NORMAL    = User::PAGE_FLAGS_NORMAL;
+       /**
+        * @deprecated since version 2019.03
+        * @see User::PAGE_FLAGS_SOAPBOX
+        */
+       const PAGE_SOAPBOX   = User::PAGE_FLAGS_SOAPBOX;
+       /**
+        * @deprecated since version 2019.03
+        * @see User::PAGE_FLAGS_COMMUNITY
+        */
+       const PAGE_COMMUNITY = User::PAGE_FLAGS_COMMUNITY;
+       /**
+        * @deprecated since version 2019.03
+        * @see User::PAGE_FLAGS_FREELOVE
+        */
+       const PAGE_FREELOVE  = User::PAGE_FLAGS_FREELOVE;
+       /**
+        * @deprecated since version 2019.03
+        * @see User::PAGE_FLAGS_BLOG
+        */
+       const PAGE_BLOG      = User::PAGE_FLAGS_BLOG;
+       /**
+        * @deprecated since version 2019.03
+        * @see User::PAGE_FLAGS_PRVGROUP
+        */
+       const PAGE_PRVGROUP  = User::PAGE_FLAGS_PRVGROUP;
        /**
         * @}
         */
@@ -529,8 +548,8 @@ class Contact extends BaseObject
                        $fields['micro'] = System::baseUrl() . '/images/person-48.jpg';
                }
 
-               $fields['forum'] = $user['page-flags'] == self::PAGE_COMMUNITY;
-               $fields['prv'] = $user['page-flags'] == self::PAGE_PRVGROUP;
+               $fields['forum'] = $user['page-flags'] == User::PAGE_FLAGS_COMMUNITY;
+               $fields['prv'] = $user['page-flags'] == User::PAGE_FLAGS_PRVGROUP;
 
                // it seems as if ported accounts can have wrong values, so we make sure that now everything is fine.
                $fields['url'] = System::baseUrl() . '/profile/' . $user['nickname'];
@@ -1465,10 +1484,10 @@ class Contact extends BaseObject
        {
                // 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 self::PAGE_COMMUNITY and self::PAGE_PRVGROUP.
-               // "community" is used in the gcontact table and is true if the contact is self::PAGE_COMMUNITY or self::PAGE_PRVGROUP.
-               if ((isset($contact['page-flags']) && (intval($contact['page-flags']) == self::PAGE_COMMUNITY))
-                       || (isset($contact['page-flags']) && (intval($contact['page-flags']) == self::PAGE_PRVGROUP))
+               // "forum" and "prv" are used in the contact table. They stand for User::PAGE_FLAGS_COMMUNITY and User::PAGE_FLAGS_PRVGROUP.
+               // "community" is used in the gcontact table and is true if the contact is User::PAGE_FLAGS_COMMUNITY or 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']))
@@ -1983,7 +2002,7 @@ class Contact extends BaseObject
                        /// @TODO Encapsulate this into a function/method
                        $fields = ['uid', 'username', 'email', 'page-flags', 'notify-flags', 'language'];
                        $user = DBA::selectFirst('user', $fields, ['uid' => $importer['uid']]);
-                       if (DBA::isResult($user) && !in_array($user['page-flags'], [self::PAGE_SOAPBOX, self::PAGE_FREELOVE, self::PAGE_COMMUNITY])) {
+                       if (DBA::isResult($user) && !in_array($user['page-flags'], [User::PAGE_FLAGS_SOAPBOX, User::PAGE_FLAGS_FREELOVE, User::PAGE_FLAGS_COMMUNITY])) {
                                // create notification
                                $hash = Strings::getRandomHex();
 
@@ -1996,7 +2015,7 @@ class Contact extends BaseObject
                                Group::addMember(User::getDefaultGroup($importer['uid'], $contact_record["network"]), $contact_record['id']);
 
                                if (($user['notify-flags'] & NOTIFY_INTRO) &&
-                                       in_array($user['page-flags'], [self::PAGE_NORMAL])) {
+                                       in_array($user['page-flags'], [User::PAGE_FLAGS_NORMAL])) {
 
                                        notification([
                                                'type'         => NOTIFY_INTRO,
@@ -2014,7 +2033,7 @@ class Contact extends BaseObject
                                        ]);
 
                                }
-                       } elseif (DBA::isResult($user) && in_array($user['page-flags'], [self::PAGE_SOAPBOX, self::PAGE_FREELOVE, self::PAGE_COMMUNITY])) {
+                       } elseif (DBA::isResult($user) && in_array($user['page-flags'], [User::PAGE_FLAGS_SOAPBOX, User::PAGE_FLAGS_FREELOVE, User::PAGE_FLAGS_COMMUNITY])) {
                                $condition = ['uid' => $importer['uid'], 'url' => $url, 'pending' => true];
                                DBA::update('contact', ['pending' => false], $condition);
 
index f18ca088f97778641ce0321bf311d4def44d98c6..cffa25397c850df81bd3a1e57d091cdec3edefe8 100644 (file)
@@ -2526,8 +2526,8 @@ class Item extends BaseObject
                        return;
                }
 
-               $community_page = (($user['page-flags'] == Contact::PAGE_COMMUNITY) ? true : false);
-               $prvgroup = (($user['page-flags'] == Contact::PAGE_PRVGROUP) ? true : false);
+               $community_page = (($user['page-flags'] == User::PAGE_FLAGS_COMMUNITY) ? true : false);
+               $prvgroup = (($user['page-flags'] == User::PAGE_FLAGS_PRVGROUP) ? true : false);
 
                $item = self::selectFirst(self::ITEM_FIELDLIST, ['id' => $item_id]);
                if (!DBA::isResult($item)) {
index 80cae7b0d2561feb94b07b7e785115344990e97e..dd754fb46e5a0343169a94e3933925d05a980162 100644 (file)
@@ -28,6 +28,26 @@ use LightOpenID;
  */
 class User
 {
+       /**
+        * @name page/profile types
+        *
+        * PAGE_NORMAL is a typical personal profile account
+        * PAGE_SOAPBOX automatically approves all friend requests as Contact::SHARING, (readonly)
+        * PAGE_COMMUNITY automatically approves all friend requests as Contact::SHARING, but with
+        *      write access to wall and comments (no email and not included in page owner's ACL lists)
+        * PAGE_FREELOVE automatically approves all friend requests as full friends (Contact::FRIEND).
+        *
+        * @{
+        */
+       const PAGE_FLAGS_NORMAL    = 0;
+       const PAGE_FLAGS_SOAPBOX   = 1;
+       const PAGE_FLAGS_COMMUNITY = 2;
+       const PAGE_FLAGS_FREELOVE  = 3;
+       const PAGE_FLAGS_BLOG      = 4;
+       const PAGE_FLAGS_PRVGROUP  = 5;
+       /**
+        * @}
+        */
        /**
         * Returns true if a user record exists with the provided id
         *
index ae360f376d505c43308d6e888ab0b74b667430c9..1fe0a048b95c2d0d9be6a939ef5a76e200f61735 100644 (file)
@@ -899,7 +899,7 @@ class Image
 
                /// @TODO
                /// $default_cid      = $r[0]['id'];
-               /// $community_page   = (($r[0]['page-flags'] == Contact::PAGE_COMMUNITY) ? true : false);
+               /// $community_page   = (($r[0]['page-flags'] == User::PAGE_FLAGS_COMMUNITY) ? true : false);
 
                if ((strlen($imagedata) == 0) && ($url == "")) {
                        Logger::log("No image data and no url provided", Logger::DEBUG);
index 499337acb1cbc1395d2b0d33a7df701afb5a1002..44bb491813d7eb5a58b1a0d4515e2bcf2e16c2d6 100644 (file)
@@ -232,7 +232,7 @@ class Transmitter
                        'vcard:region' => $profile['region'], 'vcard:locality' => $profile['locality']];
                $data['summary'] = $contact['about'];
                $data['url'] = $contact['url'];
-               $data['manuallyApprovesFollowers'] = in_array($user['page-flags'], [Contact::PAGE_NORMAL, Contact::PAGE_PRVGROUP]);
+               $data['manuallyApprovesFollowers'] = in_array($user['page-flags'], [User::PAGE_FLAGS_NORMAL, User::PAGE_FLAGS_PRVGROUP]);
                $data['publicKey'] = ['id' => $contact['url'] . '#main-key',
                        'owner' => $contact['url'],
                        'publicKeyPem' => $user['pubkey']];
index e4269f38ec1782799354cd25118ec6cc9d1a8063..550f5e07f17202dd85270733e4bafa2468a080f6 100644 (file)
@@ -587,14 +587,14 @@ class DFRN
                }
 
                // For backward compatibility we keep this element
-               if ($owner['page-flags'] == Contact::PAGE_COMMUNITY) {
+               if ($owner['page-flags'] == User::PAGE_FLAGS_COMMUNITY) {
                        XML::addElement($doc, $root, "dfrn:community", 1);
                }
 
                // The former element is replaced by this one
                XML::addElement($doc, $root, "dfrn:account_type", $owner["account-type"]);
 
-               /// @todo We need a way to transmit the different page flags like "Contact::PAGE_PRVGROUP"
+               /// @todo We need a way to transmit the different page flags like "User::PAGE_FLAGS_PRVGROUP"
 
                XML::addElement($doc, $root, "updated", DateTimeFormat::utcNow(DateTimeFormat::ATOM));
 
@@ -1264,11 +1264,11 @@ class DFRN
                $perm         = (($res->perm) ? $res->perm : null);
                $dfrn_version = (float) (($res->dfrn_version) ? $res->dfrn_version : 2.0);
                $rino_remote_version = intval($res->rino);
-               $page         = (($owner['page-flags'] == Contact::PAGE_COMMUNITY) ? 1 : 0);
+               $page         = (($owner['page-flags'] == User::PAGE_FLAGS_COMMUNITY) ? 1 : 0);
 
                Logger::log("Remote rino version: ".$rino_remote_version." for ".$contact["url"], Logger::DEBUG);
 
-               if ($owner['page-flags'] == Contact::PAGE_PRVGROUP) {
+               if ($owner['page-flags'] == User::PAGE_FLAGS_PRVGROUP) {
                        $page = 2;
                }
 
@@ -1285,7 +1285,7 @@ class DFRN
                }
 
                if (($contact['duplex'] && strlen($contact['pubkey']))
-                       || ($owner['page-flags'] == Contact::PAGE_COMMUNITY && strlen($contact['pubkey']))
+                       || ($owner['page-flags'] == User::PAGE_FLAGS_COMMUNITY && strlen($contact['pubkey']))
                        || ($contact['rel'] == Contact::SHARING && strlen($contact['pubkey']))
                ) {
                        openssl_public_decrypt($sent_dfrn_id, $final_dfrn_id, $contact['pubkey']);
@@ -1314,7 +1314,7 @@ class DFRN
                        $postvars['dissolve'] = '1';
                }
 
-               if ((($contact['rel']) && ($contact['rel'] != Contact::SHARING) && (! $contact['blocked'])) || ($owner['page-flags'] == Contact::PAGE_COMMUNITY)) {
+               if ((($contact['rel']) && ($contact['rel'] != Contact::SHARING) && (! $contact['blocked'])) || ($owner['page-flags'] == User::PAGE_FLAGS_COMMUNITY)) {
                        $postvars['data'] = $atom;
                        $postvars['perm'] = 'rw';
                } else {
@@ -1349,7 +1349,7 @@ class DFRN
 
                        if ($dfrn_version >= 2.1) {
                                if (($contact['duplex'] && strlen($contact['pubkey']))
-                                       || ($owner['page-flags'] == Contact::PAGE_COMMUNITY && strlen($contact['pubkey']))
+                                       || ($owner['page-flags'] == User::PAGE_FLAGS_COMMUNITY && strlen($contact['pubkey']))
                                        || ($contact['rel'] == Contact::SHARING && strlen($contact['pubkey']))
                                ) {
                                        openssl_public_encrypt($key, $postvars['key'], $contact['pubkey']);
@@ -1357,7 +1357,7 @@ class DFRN
                                        openssl_private_encrypt($key, $postvars['key'], $contact['prvkey']);
                                }
                        } else {
-                               if (($contact['duplex'] && strlen($contact['prvkey'])) || ($owner['page-flags'] == Contact::PAGE_COMMUNITY)) {
+                               if (($contact['duplex'] && strlen($contact['prvkey'])) || ($owner['page-flags'] == User::PAGE_FLAGS_COMMUNITY)) {
                                        openssl_private_encrypt($key, $postvars['key'], $contact['prvkey']);
                                } else {
                                        openssl_public_encrypt($key, $postvars['key'], $contact['pubkey']);
@@ -2146,7 +2146,7 @@ class DFRN
                if ($item["parent-uri"] != $item["uri"]) {
                        $community = false;
 
-                       if ($importer["page-flags"] == Contact::PAGE_COMMUNITY || $importer["page-flags"] == Contact::PAGE_PRVGROUP) {
+                       if ($importer["page-flags"] == User::PAGE_FLAGS_COMMUNITY || $importer["page-flags"] == User::PAGE_FLAGS_PRVGROUP) {
                                $sql_extra = "";
                                $community = true;
                                Logger::log("possible community action");
@@ -3073,8 +3073,8 @@ class DFRN
                        return false;
                }
 
-               $community_page = ($user['page-flags'] == Contact::PAGE_COMMUNITY);
-               $prvgroup = ($user['page-flags'] == Contact::PAGE_PRVGROUP);
+               $community_page = ($user['page-flags'] == User::PAGE_FLAGS_COMMUNITY);
+               $prvgroup = ($user['page-flags'] == User::PAGE_FLAGS_PRVGROUP);
 
                $link = Strings::normaliseLink(System::baseUrl() . '/profile/' . $user['nickname']);
 
index fadf337a6ac1a2ac67f471fed77c863ef266f042..9a29edaaf6355014c8bd5baf82674f16a3d727f9 100644 (file)
@@ -639,7 +639,7 @@ class Diaspora
                        return false;
                }
 
-               $importer = ["uid" => 0, "page-flags" => Contact::PAGE_FREELOVE];
+               $importer = ["uid" => 0, "page-flags" => User::PAGE_FLAGS_FREELOVE];
                $success = self::dispatch($importer, $msg, $fields);
 
                return $success;
@@ -1123,7 +1123,7 @@ class Diaspora
                 */
                // It is deactivated by now, due to side effects. See issue https://github.com/friendica/friendica/pull/4033
                // It is not removed by now. Possibly the code is needed?
-               //if (!$is_comment && $contact["rel"] == Contact::FOLLOWER && in_array($importer["page-flags"], array(Contact::PAGE_FREELOVE))) {
+               //if (!$is_comment && $contact["rel"] == Contact::FOLLOWER && in_array($importer["page-flags"], array(User::PAGE_FLAGS_FREELOVE))) {
                //      DBA::update(
                //              'contact',
                //              array('rel' => Contact::FRIEND, 'writable' => true),
@@ -1143,7 +1143,7 @@ class Diaspora
                        // Yes, then it is fine.
                        return true;
                        // Is it a post to a community?
-               } elseif (($contact["rel"] == Contact::FOLLOWER) && in_array($importer["page-flags"], [Contact::PAGE_COMMUNITY, Contact::PAGE_PRVGROUP])) {
+               } elseif (($contact["rel"] == Contact::FOLLOWER) && in_array($importer["page-flags"], [User::PAGE_FLAGS_COMMUNITY, User::PAGE_FLAGS_PRVGROUP])) {
                        // That's good
                        return true;
                        // Is the message a global user or a comment?
@@ -2422,7 +2422,7 @@ class Diaspora
                        }
                }
 
-               if (!$following && $sharing && in_array($importer["page-flags"], [Contact::PAGE_SOAPBOX, Contact::PAGE_NORMAL])) {
+               if (!$following && $sharing && in_array($importer["page-flags"], [User::PAGE_FLAGS_SOAPBOX, User::PAGE_FLAGS_NORMAL])) {
                        Logger::log("Author ".$author." wants to share with us - but doesn't want to listen. Request is ignored.", Logger::DEBUG);
                        return false;
                } elseif (!$following && !$sharing) {
@@ -2480,7 +2480,7 @@ class Diaspora
 
                Contact::updateAvatar($ret["photo"], $importer['uid'], $contact_record["id"], true);
 
-               if (in_array($importer["page-flags"], [Contact::PAGE_NORMAL, Contact::PAGE_PRVGROUP])) {
+               if (in_array($importer["page-flags"], [User::PAGE_FLAGS_NORMAL, User::PAGE_FLAGS_PRVGROUP])) {
                        Logger::log("Sending intra message for author ".$author.".", Logger::DEBUG);
 
                        $hash = Strings::getRandomHex().(string)time();   // Generate a confirm_key
@@ -2508,9 +2508,9 @@ class Diaspora
                         * but if our page-type is Profile::PAGE_COMMUNITY or Profile::PAGE_SOAPBOX
                         * we are going to change the relationship and make them a follower.
                         */
-                       if (($importer["page-flags"] == Contact::PAGE_FREELOVE) && $sharing && $following) {
+                       if (($importer["page-flags"] == User::PAGE_FLAGS_FREELOVE) && $sharing && $following) {
                                $new_relation = Contact::FRIEND;
-                       } elseif (($importer["page-flags"] == Contact::PAGE_FREELOVE) && $sharing) {
+                       } elseif (($importer["page-flags"] == User::PAGE_FLAGS_FREELOVE) && $sharing) {
                                $new_relation = Contact::SHARING;
                        } else {
                                $new_relation = Contact::FOLLOWER;
index 2ad12cebae7f78cb49219e600cc6ad6c6792ac0c..d1e668e0d8ce80a46ec101630d5a1fb4a88db9ce 100644 (file)
@@ -9,6 +9,7 @@ use Friendica\BaseObject;
 use Friendica\Database\DBA;
 use Friendica\Model\Contact;
 use Friendica\Model\Group;
+use Friendica\Model\User;
 
 /**
  * Secures that User is allow to do requests
@@ -65,7 +66,7 @@ class Security extends BaseObject
                                        intval($cid),
                                        intval(Contact::SHARING),
                                        intval(Contact::FRIEND),
-                                       intval(Contact::PAGE_COMMUNITY)
+                                       intval(User::PAGE_FLAGS_COMMUNITY)
                                );
 
                                if (DBA::isResult($r)) {
index 2ed1a819979b60f45e0b1f0b7752bead2592a63f..4b0b2f2b6ad8cf715f900595fc4c7411b9516987 100644 (file)
@@ -162,8 +162,8 @@ function update_1203()
 {
        $r = q("UPDATE `user` SET `account-type` = %d WHERE `page-flags` IN (%d, %d)",
                DBA::escape(Contact::ACCOUNT_TYPE_COMMUNITY),
-               DBA::escape(Contact::PAGE_COMMUNITY),
-               DBA::escape(Contact::PAGE_PRVGROUP)
+               DBA::escape(User::PAGE_FLAGS_COMMUNITY),
+               DBA::escape(User::PAGE_FLAGS_PRVGROUP)
        );
 }