Moved global PAGE_* to Profile class (#5500)

* Rewrites:
- moved PAGE_* to Friendica\Model\Profile class

* Fixed more rewrites from plain (global namespace) PAGE_* to Friendica\Models\Profile class

* CR request:
- moved all PAGE_* constants to Friendica\Model\Contact class
- fixed all references of both classes

* CR request:
- moved ACCOUNT_TYPE_* constants from boot.php to Contact::ACCOUNT_TYPE_*

* Just copy-pasted this code from boot.php, needs to be changed to `const ACCOUNT_TYPE_FOO = x;`

* Ops, melting brain cells here ... :-/
This commit is contained in:
Roland Häder 2018-07-28 01:25:57 +02:00 committed by Hypolite Petovan
commit 4a22710b3b
27 changed files with 185 additions and 172 deletions

View file

@ -481,14 +481,14 @@ function settings_post(App $a)
}
// Adjust the page flag if the account type doesn't fit to the page flag.
if (($account_type == ACCOUNT_TYPE_PERSON) && !in_array($page_flags, [PAGE_NORMAL, PAGE_SOAPBOX, PAGE_FREELOVE])) {
$page_flags = PAGE_NORMAL;
} elseif (($account_type == ACCOUNT_TYPE_ORGANISATION) && !in_array($page_flags, [PAGE_SOAPBOX])) {
$page_flags = PAGE_SOAPBOX;
} elseif (($account_type == ACCOUNT_TYPE_NEWS) && !in_array($page_flags, [PAGE_SOAPBOX])) {
$page_flags = PAGE_SOAPBOX;
} elseif (($account_type == ACCOUNT_TYPE_COMMUNITY) && !in_array($page_flags, [PAGE_COMMUNITY, PAGE_PRVGROUP])) {
$page_flags = PAGE_COMMUNITY;
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;
}
$email_changed = false;
@ -565,7 +565,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 == PAGE_PRVGROUP) {
if ($page_flags == Contact::PAGE_PRVGROUP) {
$hidewall = 1;
if (!$str_contact_allow && !$str_group_allow && !$str_contact_deny && !$str_group_deny) {
if ($def_gid) {
@ -1029,9 +1029,9 @@ 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'], [PAGE_COMMUNITY, PAGE_PRVGROUP]) &&
($a->user['account-type'] != ACCOUNT_TYPE_COMMUNITY))
$a->user['account-type'] = ACCOUNT_TYPE_COMMUNITY;
if (in_array($a->user['page-flags'], [Contact::PAGE_COMMUNITY, Contact::PAGE_PRVGROUP]) &&
($a->user['account-type'] != Contact::ACCOUNT_TYPE_COMMUNITY))
$a->user['account-type'] = Contact::ACCOUNT_TYPE_COMMUNITY;
$pageset_tpl = get_markup_template('settings/pagetypes.tpl');
@ -1040,46 +1040,46 @@ function settings_content(App $a)
'$user' => L10n::t("Personal Page Subtypes"),
'$community' => L10n::t("Community Forum Subtypes"),
'$account_type' => $a->user['account-type'],
'$type_person' => ACCOUNT_TYPE_PERSON,
'$type_organisation' => ACCOUNT_TYPE_ORGANISATION,
'$type_news' => ACCOUNT_TYPE_NEWS,
'$type_community' => ACCOUNT_TYPE_COMMUNITY,
'$type_person' => Contact::ACCOUNT_TYPE_PERSON,
'$type_organisation' => Contact::ACCOUNT_TYPE_ORGANISATION,
'$type_news' => Contact::ACCOUNT_TYPE_NEWS,
'$type_community' => Contact::ACCOUNT_TYPE_COMMUNITY,
'$account_person' => ['account-type', L10n::t('Personal Page'), ACCOUNT_TYPE_PERSON,
'$account_person' => ['account-type', L10n::t('Personal Page'), Contact::ACCOUNT_TYPE_PERSON,
L10n::t('Account for a personal profile.'),
($a->user['account-type'] == ACCOUNT_TYPE_PERSON)],
($a->user['account-type'] == Contact::ACCOUNT_TYPE_PERSON)],
'$account_organisation' => ['account-type', L10n::t('Organisation Page'), ACCOUNT_TYPE_ORGANISATION,
'$account_organisation' => ['account-type', L10n::t('Organisation Page'), Contact::ACCOUNT_TYPE_ORGANISATION,
L10n::t('Account for an organisation that automatically approves contact requests as "Followers".'),
($a->user['account-type'] == ACCOUNT_TYPE_ORGANISATION)],
($a->user['account-type'] == Contact::ACCOUNT_TYPE_ORGANISATION)],
'$account_news' => ['account-type', L10n::t('News Page'), ACCOUNT_TYPE_NEWS,
'$account_news' => ['account-type', L10n::t('News Page'), Contact::ACCOUNT_TYPE_NEWS,
L10n::t('Account for a news reflector that automatically approves contact requests as "Followers".'),
($a->user['account-type'] == ACCOUNT_TYPE_NEWS)],
($a->user['account-type'] == Contact::ACCOUNT_TYPE_NEWS)],
'$account_community' => ['account-type', L10n::t('Community Forum'), ACCOUNT_TYPE_COMMUNITY,
'$account_community' => ['account-type', L10n::t('Community Forum'), Contact::ACCOUNT_TYPE_COMMUNITY,
L10n::t('Account for community discussions.'),
($a->user['account-type'] == ACCOUNT_TYPE_COMMUNITY)],
($a->user['account-type'] == Contact::ACCOUNT_TYPE_COMMUNITY)],
'$page_normal' => ['page-flags', L10n::t('Normal Account Page'), PAGE_NORMAL,
'$page_normal' => ['page-flags', L10n::t('Normal Account Page'), Contact::PAGE_NORMAL,
L10n::t('Account for a regular personal profile that requires manual approval of "Friends" and "Followers".'),
($a->user['page-flags'] == PAGE_NORMAL)],
($a->user['page-flags'] == Contact::PAGE_NORMAL)],
'$page_soapbox' => ['page-flags', L10n::t('Soapbox Page'), PAGE_SOAPBOX,
'$page_soapbox' => ['page-flags', L10n::t('Soapbox Page'), Contact::PAGE_SOAPBOX,
L10n::t('Account for a public profile that automatically approves contact requests as "Followers".'),
($a->user['page-flags'] == PAGE_SOAPBOX)],
($a->user['page-flags'] == Contact::PAGE_SOAPBOX)],
'$page_community' => ['page-flags', L10n::t('Public Forum'), PAGE_COMMUNITY,
'$page_community' => ['page-flags', L10n::t('Public Forum'), Contact::PAGE_COMMUNITY,
L10n::t('Automatically approves all contact requests.'),
($a->user['page-flags'] == PAGE_COMMUNITY)],
($a->user['page-flags'] == Contact::PAGE_COMMUNITY)],
'$page_freelove' => ['page-flags', L10n::t('Automatic Friend Page'), PAGE_FREELOVE,
'$page_freelove' => ['page-flags', L10n::t('Automatic Friend Page'), Contact::PAGE_FREELOVE,
L10n::t('Account for a popular profile that automatically approves contact requests as "Friends".'),
($a->user['page-flags'] == PAGE_FREELOVE)],
($a->user['page-flags'] == Contact::PAGE_FREELOVE)],
'$page_prvgroup' => ['page-flags', L10n::t('Private Forum [Experimental]'), PAGE_PRVGROUP,
'$page_prvgroup' => ['page-flags', L10n::t('Private Forum [Experimental]'), Contact::PAGE_PRVGROUP,
L10n::t('Requires manual approval of contact requests.'),
($a->user['page-flags'] == PAGE_PRVGROUP)],
($a->user['page-flags'] == Contact::PAGE_PRVGROUP)],
]);