1
1
Fork 0

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
parent 5f77e98d76
commit 4a22710b3b
27 changed files with 185 additions and 172 deletions

View file

@ -164,55 +164,6 @@ define('UPDATE_FAILED', 1);
* @}
*/
/**
* @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).
*
* @{
*/
define('PAGE_NORMAL', 0);
define('PAGE_SOAPBOX', 1);
define('PAGE_COMMUNITY', 2);
define('PAGE_FREELOVE', 3);
define('PAGE_BLOG', 4);
define('PAGE_PRVGROUP', 5);
/**
* @}
*/
/**
* @name account types
*
* ACCOUNT_TYPE_PERSON - the account belongs to a person
* Associated page types: PAGE_NORMAL, PAGE_SOAPBOX, PAGE_FREELOVE
*
* ACCOUNT_TYPE_ORGANISATION - the account belongs to an organisation
* Associated page type: PAGE_SOAPBOX
*
* ACCOUNT_TYPE_NEWS - the account is a news reflector
* Associated page type: PAGE_SOAPBOX
*
* ACCOUNT_TYPE_COMMUNITY - the account is community forum
* Associated page types: PAGE_COMMUNITY, PAGE_PRVGROUP
*
* ACCOUNT_TYPE_RELAY - the account is a relay
* This will only be assigned to contacts, not to user accounts
* @{
*/
define('ACCOUNT_TYPE_PERSON', 0);
define('ACCOUNT_TYPE_ORGANISATION', 1);
define('ACCOUNT_TYPE_NEWS', 2);
define('ACCOUNT_TYPE_COMMUNITY', 3);
define('ACCOUNT_TYPE_RELAY', 4);
/**
* @}
*/
/**
* @name CP
*

View file

@ -9,6 +9,7 @@ use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\Model\Contact;
use Friendica\Model\Item;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Emailer;
@ -53,7 +54,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"], [PAGE_COMMUNITY, PAGE_PRVGROUP])) {
if (!DBA::isResult($user) || in_array($user["page-flags"], [Contact::PAGE_COMMUNITY, Contact::PAGE_PRVGROUP])) {
return;
}
}

View file

@ -245,7 +245,7 @@ function can_write_wall($owner)
intval($cid),
intval(Contact::SHARING),
intval(Contact::FRIEND),
intval(PAGE_COMMUNITY)
intval(Contact::PAGE_COMMUNITY)
);
if (DBA::isResult($r)) {

View file

@ -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'];

View file

@ -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;
}

View file

@ -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';

View file

@ -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');

View file

@ -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')) {

View file

@ -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']) {

View file

@ -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;

View file

@ -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)) {

View file

@ -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);

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)],
]);

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -11,6 +11,7 @@ use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\Model\Contact;
use Friendica\Model\Profile;
require_once 'boot.php';
@ -185,7 +186,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 ($_SESSION['page_flags'] != PAGE_COMMUNITY) {
if ($_SESSION['page_flags'] != Contact::PAGE_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'), '', ''];

View file

@ -12,6 +12,7 @@ use Friendica\Core\PConfig;
use Friendica\Core\System;
use Friendica\Core\Worker;
use Friendica\Database\DBA;
use Friendica\Model\Profile;
use Friendica\Network\Probe;
use Friendica\Object\Image;
use Friendica\Protocol\Diaspora;
@ -30,6 +31,55 @@ require_once 'include/text.php';
*/
class Contact extends BaseObject
{
/**
* @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_NORMAL = 0;
const PAGE_SOAPBOX = 1;
const PAGE_COMMUNITY = 2;
const PAGE_FREELOVE = 3;
const PAGE_BLOG = 4;
const PAGE_PRVGROUP = 5;
/**
* @}
*/
/**
* @name account types
*
* ACCOUNT_TYPE_PERSON - the account belongs to a person
* Associated page types: PAGE_NORMAL, PAGE_SOAPBOX, PAGE_FREELOVE
*
* ACCOUNT_TYPE_ORGANISATION - the account belongs to an organisation
* Associated page type: PAGE_SOAPBOX
*
* ACCOUNT_TYPE_NEWS - the account is a news reflector
* Associated page type: PAGE_SOAPBOX
*
* ACCOUNT_TYPE_COMMUNITY - the account is community forum
* Associated page types: PAGE_COMMUNITY, PAGE_PRVGROUP
*
* ACCOUNT_TYPE_RELAY - the account is a relay
* This will only be assigned to contacts, not to user accounts
* @{
*/
const ACCOUNT_TYPE_PERSON = 0;
const ACCOUNT_TYPE_ORGANISATION = 1;
const ACCOUNT_TYPE_NEWS = 2;
const ACCOUNT_TYPE_COMMUNITY = 3;
const ACCOUNT_TYPE_RELAY = 4;
/**
* @}
*/
/**
* @name Contact_is
*
@ -52,6 +102,7 @@ class Contact extends BaseObject
public static function getByGroupId($gid)
{
$return = [];
if (intval($gid)) {
$stmt = DBA::p('SELECT `group_member`.`contact-id`, `contact`.*
FROM `contact`
@ -66,6 +117,7 @@ class Contact extends BaseObject
$gid,
local_user()
);
if (DBA::isResult($stmt)) {
$return = DBA::toArray($stmt);
}
@ -212,8 +264,8 @@ class Contact extends BaseObject
$fields['micro'] = System::baseUrl() . '/images/person-48.jpg';
}
$fields['forum'] = $user['page-flags'] == PAGE_COMMUNITY;
$fields['prv'] = $user['page-flags'] == PAGE_PRVGROUP;
$fields['forum'] = $user['page-flags'] == self::PAGE_COMMUNITY;
$fields['prv'] = $user['page-flags'] == self::PAGE_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'];
@ -374,7 +426,7 @@ class Contact extends BaseObject
}
if (!empty($contact['batch'])) {
$condition = ['batch' => $contact['batch'], 'contact-type' => ACCOUNT_TYPE_RELAY];
$condition = ['batch' => $contact['batch'], 'contact-type' => self::ACCOUNT_TYPE_RELAY];
DBA::update('contact', $fields, $condition);
}
}
@ -1042,7 +1094,7 @@ class Contact extends BaseObject
$author_id = intval($r[0]["author-id"]);
$contact = ($r[0]["contact-type"] == ACCOUNT_TYPE_COMMUNITY ? 'owner-id' : 'author-id');
$contact = ($r[0]["contact-type"] == self::ACCOUNT_TYPE_COMMUNITY ? 'owner-id' : 'author-id');
$condition = ["`$contact` = ? AND `gravity` IN (?, ?) AND " . $sql,
$author_id, GRAVITY_PARENT, GRAVITY_COMMENT, local_user()];
@ -1071,17 +1123,17 @@ 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 PAGE_COMMUNITY and PAGE_PRVGROUP.
// "community" is used in the gcontact table and is true if the contact is PAGE_COMMUNITY or PAGE_PRVGROUP.
if ((isset($contact['page-flags']) && (intval($contact['page-flags']) == PAGE_COMMUNITY))
|| (isset($contact['page-flags']) && (intval($contact['page-flags']) == PAGE_PRVGROUP))
// "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))
|| (isset($contact['forum']) && intval($contact['forum']))
|| (isset($contact['prv']) && intval($contact['prv']))
|| (isset($contact['community']) && intval($contact['community']))
) {
$type = ACCOUNT_TYPE_COMMUNITY;
$type = self::ACCOUNT_TYPE_COMMUNITY;
} else {
$type = ACCOUNT_TYPE_PERSON;
$type = self::ACCOUNT_TYPE_PERSON;
}
// The "contact-type" (contact table) and "account-type" (user table) are more general then the chaos from above.
@ -1094,15 +1146,18 @@ class Contact extends BaseObject
}
switch ($type) {
case ACCOUNT_TYPE_ORGANISATION:
case self::ACCOUNT_TYPE_ORGANISATION:
$account_type = L10n::t("Organisation");
break;
case ACCOUNT_TYPE_NEWS:
case self::ACCOUNT_TYPE_NEWS:
$account_type = L10n::t('News');
break;
case ACCOUNT_TYPE_COMMUNITY:
case self::ACCOUNT_TYPE_COMMUNITY:
$account_type = L10n::t("Forum");
break;
default:
$account_type = "";
break;
@ -1553,7 +1608,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'], [PAGE_SOAPBOX, PAGE_FREELOVE, PAGE_COMMUNITY])) {
if (DBA::isResult($user) && !in_array($user['page-flags'], [self::PAGE_SOAPBOX, self::PAGE_FREELOVE, self::PAGE_COMMUNITY])) {
// create notification
$hash = random_string();
@ -1566,7 +1621,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'], [PAGE_NORMAL])) {
in_array($user['page-flags'], [self::PAGE_NORMAL])) {
notification([
'type' => NOTIFY_INTRO,
@ -1584,7 +1639,7 @@ class Contact extends BaseObject
]);
}
} elseif (DBA::isResult($user) && in_array($user['page-flags'], [PAGE_SOAPBOX, PAGE_FREELOVE, PAGE_COMMUNITY])) {
} elseif (DBA::isResult($user) && in_array($user['page-flags'], [self::PAGE_SOAPBOX, self::PAGE_FREELOVE, self::PAGE_COMMUNITY])) {
q("UPDATE `contact` SET `pending` = 0 WHERE `uid` = %d AND `url` = '%s' AND `pending` LIMIT 1",
intval($importer['uid']),
DBA::escape($url)

View file

@ -2473,8 +2473,8 @@ class Item extends BaseObject
return;
}
$community_page = (($user['page-flags'] == PAGE_COMMUNITY) ? true : false);
$prvgroup = (($user['page-flags'] == PAGE_PRVGROUP) ? true : false);
$community_page = (($user['page-flags'] == Contact::PAGE_COMMUNITY) ? true : false);
$prvgroup = (($user['page-flags'] == Contact::PAGE_PRVGROUP) ? true : false);
$item = self::selectFirst(self::ITEM_FIELDLIST, ['id' => $item_id]);
if (!DBA::isResult($item)) {

View file

@ -398,7 +398,7 @@ class Probe
// This doesn't cover the case when a community isn't a community anymore
if (!empty($data['community']) && $data['community']) {
$fields['community'] = $data['community'];
$fields['contact-type'] = ACCOUNT_TYPE_COMMUNITY;
$fields['contact-type'] = Contact::ACCOUNT_TYPE_COMMUNITY;
}
$fieldnames = [];

View file

@ -11,6 +11,7 @@ use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\Model\Contact;
use Friendica\Model\Photo;
use Friendica\Util\Network;
use Exception;
@ -896,7 +897,7 @@ class Image
/// @TODO
/// $default_cid = $r[0]['id'];
/// $community_page = (($r[0]['page-flags'] == PAGE_COMMUNITY) ? true : false);
/// $community_page = (($r[0]['page-flags'] == Contact::PAGE_COMMUNITY) ? true : false);
if ((strlen($imagedata) == 0) && ($url == "")) {
logger("No image data and no url provided", LOGGER_DEBUG);

View file

@ -547,14 +547,14 @@ class DFRN
}
// For backward compatibility we keep this element
if ($owner['page-flags'] == PAGE_COMMUNITY) {
if ($owner['page-flags'] == Contact::PAGE_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 "PAGE_PRVGROUP"
/// @todo We need a way to transmit the different page flags like "Contact::PAGE_PRVGROUP"
XML::addElement($doc, $root, "updated", DateTimeFormat::utcNow(DateTimeFormat::ATOM));
@ -1220,11 +1220,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'] == PAGE_COMMUNITY) ? 1 : 0);
$page = (($owner['page-flags'] == Contact::PAGE_COMMUNITY) ? 1 : 0);
logger("Remote rino version: ".$rino_remote_version." for ".$contact["url"], LOGGER_DEBUG);
if ($owner['page-flags'] == PAGE_PRVGROUP) {
if ($owner['page-flags'] == Contact::PAGE_PRVGROUP) {
$page = 2;
}
@ -1244,7 +1244,7 @@ class DFRN
}
if (($contact['duplex'] && strlen($contact['pubkey']))
|| ($owner['page-flags'] == PAGE_COMMUNITY && strlen($contact['pubkey']))
|| ($owner['page-flags'] == Contact::PAGE_COMMUNITY && strlen($contact['pubkey']))
|| ($contact['rel'] == Contact::SHARING && strlen($contact['pubkey']))
) {
openssl_public_decrypt($sent_dfrn_id, $final_dfrn_id, $contact['pubkey']);
@ -1273,7 +1273,7 @@ class DFRN
$postvars['dissolve'] = '1';
}
if ((($contact['rel']) && ($contact['rel'] != Contact::SHARING) && (! $contact['blocked'])) || ($owner['page-flags'] == PAGE_COMMUNITY)) {
if ((($contact['rel']) && ($contact['rel'] != Contact::SHARING) && (! $contact['blocked'])) || ($owner['page-flags'] == Contact::PAGE_COMMUNITY)) {
$postvars['data'] = $atom;
$postvars['perm'] = 'rw';
} else {
@ -1307,7 +1307,7 @@ class DFRN
if ($dfrn_version >= 2.1) {
if (($contact['duplex'] && strlen($contact['pubkey']))
|| ($owner['page-flags'] == PAGE_COMMUNITY && strlen($contact['pubkey']))
|| ($owner['page-flags'] == Contact::PAGE_COMMUNITY && strlen($contact['pubkey']))
|| ($contact['rel'] == Contact::SHARING && strlen($contact['pubkey']))
) {
openssl_public_encrypt($key, $postvars['key'], $contact['pubkey']);
@ -1315,7 +1315,7 @@ class DFRN
openssl_private_encrypt($key, $postvars['key'], $contact['prvkey']);
}
} else {
if (($contact['duplex'] && strlen($contact['prvkey'])) || ($owner['page-flags'] == PAGE_COMMUNITY)) {
if (($contact['duplex'] && strlen($contact['prvkey'])) || ($owner['page-flags'] == Contact::PAGE_COMMUNITY)) {
openssl_private_encrypt($key, $postvars['key'], $contact['prvkey']);
} else {
openssl_public_encrypt($key, $postvars['key'], $contact['pubkey']);
@ -2135,7 +2135,7 @@ class DFRN
if ($item["parent-uri"] != $item["uri"]) {
$community = false;
if ($importer["page-flags"] == PAGE_COMMUNITY || $importer["page-flags"] == PAGE_PRVGROUP) {
if ($importer["page-flags"] == Contact::PAGE_COMMUNITY || $importer["page-flags"] == Contact::PAGE_PRVGROUP) {
$sql_extra = "";
$community = true;
logger("possible community action");
@ -2846,7 +2846,7 @@ class DFRN
DBA::update('contact', ['contact-type' => $accounttype], ['id' => $importer["id"]]);
}
// A forum contact can either have set "forum" or "prv" - but not both
if (($accounttype == ACCOUNT_TYPE_COMMUNITY) && (($forum != $importer["forum"]) || ($forum == $importer["prv"]))) {
if (($accounttype == Contact::ACCOUNT_TYPE_COMMUNITY) && (($forum != $importer["forum"]) || ($forum == $importer["prv"]))) {
$condition = ['(`forum` != ? OR `prv` != ?) AND `id` = ?', $forum, !$forum, $importer["id"]];
DBA::update('contact', ['forum' => $forum, 'prv' => !$forum], $condition);
}
@ -3025,8 +3025,8 @@ class DFRN
return false;
}
$community_page = ($u[0]['page-flags'] == PAGE_COMMUNITY);
$prvgroup = ($u[0]['page-flags'] == PAGE_PRVGROUP);
$community_page = ($u[0]['page-flags'] == Contact::PAGE_COMMUNITY);
$prvgroup = ($u[0]['page-flags'] == Contact::PAGE_PRVGROUP);
$link = normalise_link(System::baseUrl() . '/profile/' . $u[0]['nickname']);

View file

@ -144,7 +144,7 @@ class Diaspora
// Fetch the relay contact
$condition = ['uid' => 0, 'nurl' => normalise_link($server_url),
'contact-type' => ACCOUNT_TYPE_RELAY];
'contact-type' => Contact::ACCOUNT_TYPE_RELAY];
$contact = DBA::selectFirst('contact', $fields, $condition);
if (DBA::isResult($contact)) {
@ -183,7 +183,7 @@ class Diaspora
$fields = array_merge($fields, $network_fields);
$condition = ['uid' => 0, 'nurl' => normalise_link($server_url),
'contact-type' => ACCOUNT_TYPE_RELAY];
'contact-type' => Contact::ACCOUNT_TYPE_RELAY];
if (DBA::exists('contact', $condition)) {
unset($fields['created']);
@ -604,7 +604,7 @@ class Diaspora
return false;
}
$importer = ["uid" => 0, "page-flags" => PAGE_FREELOVE];
$importer = ["uid" => 0, "page-flags" => Contact::PAGE_FREELOVE];
$success = self::dispatch($importer, $msg, $fields);
return $success;
@ -1079,7 +1079,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(PAGE_FREELOVE))) {
//if (!$is_comment && $contact["rel"] == Contact::FOLLOWER && in_array($importer["page-flags"], array(Contact::PAGE_FREELOVE))) {
// dba::update(
// 'contact',
// array('rel' => Contact::FRIEND, 'writable' => true),
@ -1099,7 +1099,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"], [PAGE_COMMUNITY, PAGE_PRVGROUP])) {
} elseif (($contact["rel"] == Contact::FOLLOWER) && in_array($importer["page-flags"], [Contact::PAGE_COMMUNITY, Contact::PAGE_PRVGROUP])) {
// That's good
return true;
// Is the message a global user or a comment?
@ -2374,7 +2374,7 @@ class Diaspora
}
}
if (!$following && $sharing && in_array($importer["page-flags"], [PAGE_SOAPBOX, PAGE_NORMAL])) {
if (!$following && $sharing && in_array($importer["page-flags"], [Contact::PAGE_SOAPBOX, Contact::PAGE_NORMAL])) {
logger("Author ".$author." wants to share with us - but doesn't want to listen. Request is ignored.", LOGGER_DEBUG);
return false;
} elseif (!$following && !$sharing) {
@ -2432,7 +2432,7 @@ class Diaspora
Contact::updateAvatar($ret["photo"], $importer['uid'], $contact_record["id"], true);
if (in_array($importer["page-flags"], [PAGE_NORMAL, PAGE_PRVGROUP])) {
if (in_array($importer["page-flags"], [Contact::PAGE_NORMAL, Contact::PAGE_PRVGROUP])) {
logger("Sending intra message for author ".$author.".", LOGGER_DEBUG);
$hash = random_string().(string)time(); // Generate a confirm_key
@ -2459,9 +2459,9 @@ class Diaspora
// but if our page-type is PAGE_COMMUNITY or PAGE_SOAPBOX
// we are going to change the relationship and make them a follower.
if (($importer["page-flags"] == PAGE_FREELOVE) && $sharing && $following) {
if (($importer["page-flags"] == Contact::PAGE_FREELOVE) && $sharing && $following) {
$new_relation = Contact::FRIEND;
} elseif (($importer["page-flags"] == PAGE_FREELOVE) && $sharing) {
} elseif (($importer["page-flags"] == Contact::PAGE_FREELOVE) && $sharing) {
$new_relation = Contact::SHARING;
} else {
$new_relation = Contact::FOLLOWER;
@ -3105,7 +3105,7 @@ class Diaspora
logger("transmit: ".$logid."-".$guid." to ".$dest_url." returns: ".$return_code);
if (!$return_code || (($return_code == 503) && (stristr($a->get_curl_headers(), "retry-after")))) {
if (!$no_queue && ($contact['contact-type'] != ACCOUNT_TYPE_RELAY)) {
if (!$no_queue && ($contact['contact-type'] != Contact::ACCOUNT_TYPE_RELAY)) {
logger("queue message");
// queue message for redelivery
Queue::add($contact["id"], NETWORK_DIASPORA, $envelope, $public_batch, $guid);

View file

@ -1299,7 +1299,7 @@ class OStatus
"rel" => "self", "type" => "application/atom+xml"];
XML::addElement($doc, $root, "link", "", $attributes);
if ($owner['account-type'] == ACCOUNT_TYPE_COMMUNITY) {
if ($owner['account-type'] == Contact::ACCOUNT_TYPE_COMMUNITY) {
$condition = ['uid' => $owner['uid'], 'self' => false, 'pending' => false,
'archive' => false, 'hidden' => false, 'blocked' => false];
$members = DBA::count('contact', $condition);
@ -1407,7 +1407,7 @@ class OStatus
$profile = DBA::selectFirst('profile', ['homepage', 'publish'], ['uid' => $owner['uid'], 'is-default' => true]);
$author = $doc->createElement("author");
XML::addElement($doc, $author, "id", $owner["url"]);
if ($owner['account-type'] == ACCOUNT_TYPE_COMMUNITY) {
if ($owner['account-type'] == Contact::ACCOUNT_TYPE_COMMUNITY) {
XML::addElement($doc, $author, "activity:object-type", ACTIVITY_OBJ_GROUP);
} else {
XML::addElement($doc, $author, "activity:object-type", ACTIVITY_OBJ_PERSON);
@ -1872,7 +1872,7 @@ class OStatus
$entry = $doc->createElement("entry");
$title = sprintf("New note by %s", $owner["nick"]);
if ($owner['account-type'] == ACCOUNT_TYPE_COMMUNITY) {
if ($owner['account-type'] == Contact::ACCOUNT_TYPE_COMMUNITY) {
$contact = self::contactEntry($item['author-link'], $owner);
$author = self::addAuthor($doc, $contact, false);
$entry->appendChild($author);
@ -2030,8 +2030,8 @@ class OStatus
foreach ($mentioned as $mention) {
$condition = ['uid' => $owner['uid'], 'nurl' => normalise_link($mention)];
$contact = DBA::selectFirst('contact', ['forum', 'prv', 'self', 'contact-type'], $condition);
if ($contact["forum"] || $contact["prv"] || ($owner['contact-type'] == ACCOUNT_TYPE_COMMUNITY) ||
($contact['self'] && ($owner['account-type'] == ACCOUNT_TYPE_COMMUNITY))) {
if ($contact["forum"] || $contact["prv"] || ($owner['contact-type'] == Contact::ACCOUNT_TYPE_COMMUNITY) ||
($contact['self'] && ($owner['account-type'] == Contact::ACCOUNT_TYPE_COMMUNITY))) {
XML::addElement($doc, $entry, "link", "",
[
"rel" => "mentioned",
@ -2048,7 +2048,7 @@ class OStatus
}
}
if ($owner['account-type'] == ACCOUNT_TYPE_COMMUNITY) {
if ($owner['account-type'] == Contact::ACCOUNT_TYPE_COMMUNITY) {
XML::addElement($doc, $entry, "link", "", [
"rel" => "mentioned",
"ostatus:object-type" => "http://activitystrea.ms/schema/1.0/group",
@ -2155,7 +2155,7 @@ class OStatus
$condition[] = ACTIVITY_OBJ_COMMENT;
}
if ($owner['account-type'] != ACCOUNT_TYPE_COMMUNITY) {
if ($owner['account-type'] != Contact::ACCOUNT_TYPE_COMMUNITY) {
$condition[0] .= " AND `contact-id` = ? AND `author-id` = ?";
$condition[] = $owner["id"];
$condition[] = $authorid;

View file

@ -277,7 +277,7 @@ class Delivery extends BaseObject
// Se we transmit with the new method and via Diaspora as a fallback
if (!empty($items) && (($items[0]['uid'] == 0) || ($contact['uid'] == 0))) {
// Transmit in public if it's a relay post
$public_dfrn = ($contact['contact-type'] == ACCOUNT_TYPE_RELAY);
$public_dfrn = ($contact['contact-type'] == Contact::ACCOUNT_TYPE_RELAY);
$deliver_status = DFRN::transmit($owner, $contact, $atom, $public_dfrn);
@ -331,7 +331,7 @@ class Delivery extends BaseObject
private static function deliverDiaspora($cmd, $contact, $owner, $items, $target_item, $public_message, $top_level, $followup)
{
// We don't treat Forum posts as "wall-to-wall" to be able to post them via Diaspora
$walltowall = $top_level && ($owner['id'] != $items[0]['contact-id']) & ($owner['account-type'] != ACCOUNT_TYPE_COMMUNITY);
$walltowall = $top_level && ($owner['id'] != $items[0]['contact-id']) & ($owner['account-type'] != Contact::ACCOUNT_TYPE_COMMUNITY);
if ($public_message) {
$loc = 'public batch ' . $contact['batch'];

View file

@ -9,6 +9,7 @@ use Friendica\Core\Cache;
use Friendica\Core\Config;
use Friendica\Core\Worker;
use Friendica\Database\DBA;
use Friendica\Model\Contact;
use Friendica\Model\PushSubscriber;
use Friendica\Model\Queue as QueueModel;
use Friendica\Model\User;
@ -136,7 +137,7 @@ class Queue
$deliver_status = Diaspora::transmit($owner, $contact, $data, $public, true, 'Queue:' . $q_item['id'], true);
if ((($deliver_status >= 200) && ($deliver_status <= 299)) ||
($contact['contact-type'] == ACCOUNT_TYPE_RELAY)) {
($contact['contact-type'] == Contact::ACCOUNT_TYPE_RELAY)) {
QueueModel::removeItem($q_item['id']);
} else {
QueueModel::updateTime($q_item['id']);

View file

@ -149,7 +149,7 @@ function update_1191() {
function update_1203() {
$r = q("UPDATE `user` SET `account-type` = %d WHERE `page-flags` IN (%d, %d)",
DBA::escape(ACCOUNT_TYPE_COMMUNITY), DBA::escape(PAGE_COMMUNITY), DBA::escape(PAGE_PRVGROUP));
DBA::escape(Contact::ACCOUNT_TYPE_COMMUNITY), DBA::escape(Contact::PAGE_COMMUNITY), DBA::escape(Contact::PAGE_PRVGROUP));
}
function update_1244() {