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:
parent
5f77e98d76
commit
4a22710b3b
27 changed files with 185 additions and 172 deletions
|
@ -1807,17 +1807,17 @@ function admin_page_users(App $a)
|
|||
$adminlist = explode(",", str_replace(" ", "", Config::get('config', 'admin_email')));
|
||||
$_setup_users = function ($e) use ($adminlist) {
|
||||
$page_types = [
|
||||
PAGE_NORMAL => L10n::t('Normal Account Page'),
|
||||
PAGE_SOAPBOX => L10n::t('Soapbox Page'),
|
||||
PAGE_COMMUNITY => L10n::t('Public Forum'),
|
||||
PAGE_FREELOVE => L10n::t('Automatic Friend Page'),
|
||||
PAGE_PRVGROUP => L10n::t('Private Forum')
|
||||
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')
|
||||
];
|
||||
$account_types = [
|
||||
ACCOUNT_TYPE_PERSON => L10n::t('Personal Page'),
|
||||
ACCOUNT_TYPE_ORGANISATION => L10n::t('Organisation Page'),
|
||||
ACCOUNT_TYPE_NEWS => L10n::t('News Page'),
|
||||
ACCOUNT_TYPE_COMMUNITY => L10n::t('Community Forum')
|
||||
Contact::ACCOUNT_TYPE_PERSON => L10n::t('Personal Page'),
|
||||
Contact::ACCOUNT_TYPE_ORGANISATION => L10n::t('Organisation Page'),
|
||||
Contact::ACCOUNT_TYPE_NEWS => L10n::t('News Page'),
|
||||
Contact::ACCOUNT_TYPE_COMMUNITY => L10n::t('Community Forum')
|
||||
];
|
||||
|
||||
$e['page_flags_raw'] = $e['page-flags'];
|
||||
|
|
|
@ -201,11 +201,11 @@ function dfrn_confirm_post(App $a, $handsfree = null)
|
|||
$params['duplex'] = 1;
|
||||
}
|
||||
|
||||
if ($user['page-flags'] == PAGE_COMMUNITY) {
|
||||
if ($user['page-flags'] == Contact::PAGE_COMMUNITY) {
|
||||
$params['page'] = 1;
|
||||
}
|
||||
|
||||
if ($user['page-flags'] == PAGE_PRVGROUP) {
|
||||
if ($user['page-flags'] == Contact::PAGE_PRVGROUP) {
|
||||
$params['page'] = 2;
|
||||
}
|
||||
|
||||
|
|
|
@ -375,7 +375,7 @@ function dfrn_notify_content(App $a) {
|
|||
$rino = $rino_remote;
|
||||
}
|
||||
|
||||
if (($r[0]['rel'] && ($r[0]['rel'] != Contact::SHARING)) || ($r[0]['page-flags'] == PAGE_COMMUNITY)) {
|
||||
if (($r[0]['rel'] && ($r[0]['rel'] != Contact::SHARING)) || ($r[0]['page-flags'] == Contact::PAGE_COMMUNITY)) {
|
||||
$perm = 'rw';
|
||||
} else {
|
||||
$perm = 'r';
|
||||
|
|
|
@ -546,7 +546,7 @@ function dfrn_request_content(App $a)
|
|||
$auto_confirm = false;
|
||||
|
||||
if (DBA::isResult($r)) {
|
||||
if ($r[0]['page-flags'] != PAGE_NORMAL && $r[0]['page-flags'] != PAGE_PRVGROUP) {
|
||||
if ($r[0]['page-flags'] != Contact::PAGE_NORMAL && $r[0]['page-flags'] != Contact::PAGE_PRVGROUP) {
|
||||
$auto_confirm = true;
|
||||
}
|
||||
|
||||
|
@ -574,7 +574,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'] == PAGE_FREELOVE) ? 1 : 0),
|
||||
'duplex' => (($r[0]['page-flags'] == Contact::PAGE_FREELOVE) ? 1 : 0),
|
||||
];
|
||||
dfrn_confirm_post($a, $handsfree);
|
||||
}
|
||||
|
@ -626,7 +626,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'] == PAGE_NORMAL) {
|
||||
if ($a->profile['page-flags'] == Contact::PAGE_NORMAL) {
|
||||
$tpl = get_markup_template('dfrn_request.tpl');
|
||||
} else {
|
||||
$tpl = get_markup_template('auto_request.tpl');
|
||||
|
|
|
@ -6,6 +6,7 @@ use Friendica\App;
|
|||
use Friendica\Core\Config;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\Profile;
|
||||
|
||||
function hcard_init(App $a)
|
||||
|
@ -28,7 +29,7 @@ function hcard_init(App $a)
|
|||
|
||||
Profile::load($a, $which, $profile);
|
||||
|
||||
if ((x($a->profile, 'page-flags')) && ($a->profile['page-flags'] == PAGE_COMMUNITY)) {
|
||||
if ((x($a->profile, 'page-flags')) && ($a->profile['page-flags'] == Contact::PAGE_COMMUNITY)) {
|
||||
$a->page['htmlhead'] .= '<meta name="friendica.community" content="true" />';
|
||||
}
|
||||
if (x($a->profile, 'openidserver')) {
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
use Friendica\App;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\Profile;
|
||||
|
||||
function noscrape_init(App $a)
|
||||
|
@ -30,7 +31,7 @@ function noscrape_init(App $a)
|
|||
'guid' => $a->profile['guid'],
|
||||
'key' => $a->profile['pubkey'],
|
||||
'homepage' => System::baseUrl()."/profile/{$which}",
|
||||
'comm' => ($a->profile['account-type'] == ACCOUNT_TYPE_COMMUNITY),
|
||||
'comm' => ($a->profile['account-type'] == Contact::ACCOUNT_TYPE_COMMUNITY),
|
||||
];
|
||||
|
||||
if (!$a->profile['net-publish'] || $a->profile['hidewall']) {
|
||||
|
|
|
@ -147,7 +147,7 @@ function photos_post(App $a)
|
|||
$visitor = 0;
|
||||
|
||||
$page_owner_uid = $a->data['user']['uid'];
|
||||
$community_page = $a->data['user']['page-flags'] == PAGE_COMMUNITY;
|
||||
$community_page = $a->data['user']['page-flags'] == Contact::PAGE_COMMUNITY;
|
||||
|
||||
if (local_user() && (local_user() == $page_owner_uid)) {
|
||||
$can_post = true;
|
||||
|
@ -964,7 +964,7 @@ function photos_content(App $a)
|
|||
|
||||
$owner_uid = $a->data['user']['uid'];
|
||||
|
||||
$community_page = (($a->data['user']['page-flags'] == PAGE_COMMUNITY) ? true : false);
|
||||
$community_page = (($a->data['user']['page-flags'] == Contact::PAGE_COMMUNITY) ? true : false);
|
||||
|
||||
if (local_user() && (local_user() == $owner_uid)) {
|
||||
$can_post = true;
|
||||
|
|
|
@ -13,6 +13,7 @@ use Friendica\Core\L10n;
|
|||
use Friendica\Core\PConfig;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\Group;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Model\Profile;
|
||||
|
@ -53,7 +54,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 (x($a->profile, 'page-flags') && $a->profile['page-flags'] == PAGE_COMMUNITY) {
|
||||
if (x($a->profile, 'page-flags') && $a->profile['page-flags'] == Contact::PAGE_COMMUNITY) {
|
||||
$a->page['htmlhead'] .= '<meta name="friendica.community" content="true" />';
|
||||
}
|
||||
|
||||
|
@ -191,7 +192,7 @@ function profile_content(App $a, $update = 0)
|
|||
|
||||
$o .= Widget::commonFriendsVisitor($a->profile['profile_uid']);
|
||||
|
||||
$commpage = $a->profile['page-flags'] == PAGE_COMMUNITY;
|
||||
$commpage = $a->profile['page-flags'] == Contact::PAGE_COMMUNITY;
|
||||
$commvisitor = $commpage && $remote_contact;
|
||||
|
||||
$a->page['aside'] .= posted_date_widget(System::baseUrl(true) . '/profile/' . $a->profile['nickname'], $a->profile['profile_uid'], true);
|
||||
|
@ -276,8 +277,8 @@ function profile_content(App $a, $update = 0)
|
|||
// If not then we can improve the performance with an additional condition
|
||||
$r = q("SELECT `uid` FROM `user` WHERE `uid` = %d AND `page-flags` IN (%d, %d)",
|
||||
intval($a->profile['profile_uid']),
|
||||
intval(PAGE_COMMUNITY),
|
||||
intval(PAGE_PRVGROUP)
|
||||
intval(Contact::PAGE_COMMUNITY),
|
||||
intval(Contact::PAGE_PRVGROUP)
|
||||
);
|
||||
|
||||
if (!DBA::isResult($r)) {
|
||||
|
|
|
@ -152,12 +152,10 @@ function profiles_init(App $a) {
|
|||
|
||||
Profile::load($a, $a->user['nickname'], $r[0]['id']);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
function profile_clean_keywords($keywords) {
|
||||
function profile_clean_keywords($keywords)
|
||||
{
|
||||
$keywords = str_replace(",", " ", $keywords);
|
||||
$keywords = explode(" ", $keywords);
|
||||
|
||||
|
@ -550,7 +548,7 @@ function profiles_content(App $a) {
|
|||
]);
|
||||
|
||||
$personal_account = !(in_array($a->user["page-flags"],
|
||||
[PAGE_COMMUNITY, PAGE_PRVGROUP]));
|
||||
[Contact::PAGE_COMMUNITY, Contact::PAGE_PRVGROUP]));
|
||||
|
||||
$detailled_profile = (PConfig::get(local_user(), 'system', 'detailled_profile') AND $personal_account);
|
||||
|
||||
|
|
|
@ -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)],
|
||||
|
||||
|
||||
]);
|
||||
|
|
|
@ -240,7 +240,7 @@ function videos_content(App $a)
|
|||
|
||||
$owner_uid = $a->data['user']['uid'];
|
||||
|
||||
$community_page = (($a->data['user']['page-flags'] == PAGE_COMMUNITY) ? true : false);
|
||||
$community_page = (($a->data['user']['page-flags'] == Contact::PAGE_COMMUNITY) ? true : false);
|
||||
|
||||
if ((local_user()) && (local_user() == $owner_uid)) {
|
||||
$can_post = true;
|
||||
|
|
|
@ -8,6 +8,7 @@ use Friendica\Core\Config;
|
|||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
use Friendica\Util\Mimetype;
|
||||
|
||||
|
@ -42,7 +43,7 @@ function wall_attach_post(App $a) {
|
|||
$page_owner_uid = $r[0]['uid'];
|
||||
$page_owner_cid = $r[0]['id'];
|
||||
$page_owner_nick = $r[0]['nickname'];
|
||||
$community_page = (($r[0]['page-flags'] == PAGE_COMMUNITY) ? true : false);
|
||||
$community_page = (($r[0]['page-flags'] == Contact::PAGE_COMMUNITY) ? true : false);
|
||||
|
||||
if((local_user()) && (local_user() == $page_owner_uid))
|
||||
$can_post = true;
|
||||
|
|
|
@ -13,6 +13,7 @@ use Friendica\Core\L10n;
|
|||
use Friendica\Core\System;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\Photo;
|
||||
use Friendica\Object\Image;
|
||||
|
||||
|
@ -66,7 +67,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'] == PAGE_COMMUNITY) ? true : false);
|
||||
$community_page = (($r[0]['page-flags'] == Contact::PAGE_COMMUNITY) ? true : false);
|
||||
|
||||
if ((local_user()) && (local_user() == $page_owner_uid)) {
|
||||
$can_post = true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue