* @}
*/
-/**
- * @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
*
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;
['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;
}
}
intval($cid),
intval(Contact::SHARING),
intval(Contact::FRIEND),
- intval(PAGE_COMMUNITY)
+ intval(Contact::PAGE_COMMUNITY)
);
if (DBA::isResult($r)) {
$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'];
$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;
}
$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';
$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;
}
'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);
}
* 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');
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)
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')) {
use Friendica\App;
use Friendica\Core\System;
use Friendica\Database\DBA;
+use Friendica\Model\Contact;
use Friendica\Model\Profile;
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']) {
$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;
$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;
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;
$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" />';
}
$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);
// 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)) {
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);
]);
$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);
}
// 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;
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) {
// 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');
'$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)],
]);
$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;
use Friendica\Core\L10n;
use Friendica\Core\System;
use Friendica\Database\DBA;
+use Friendica\Model\Contact;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Mimetype;
$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;
use Friendica\Core\System;
use Friendica\Core\Config;
use Friendica\Database\DBA;
+use Friendica\Model\Contact;
use Friendica\Model\Photo;
use Friendica\Object\Image;
$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;
use Friendica\Core\L10n;
use Friendica\Core\System;
use Friendica\Database\DBA;
+use Friendica\Model\Contact;
use Friendica\Model\Profile;
require_once 'boot.php';
$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'), '', ''];
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;
*/
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
*
public static function getByGroupId($gid)
{
$return = [];
+
if (intval($gid)) {
$stmt = DBA::p('SELECT `group_member`.`contact-id`, `contact`.*
FROM `contact`
$gid,
local_user()
);
+
if (DBA::isResult($stmt)) {
$return = DBA::toArray($stmt);
}
$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'];
}
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);
}
}
$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()];
{
// 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.
}
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;
/// @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();
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,
'to_name' => $user['username'],
'to_email' => $user['email'],
'uid' => $user['uid'],
- 'link' => System::baseUrl() . '/notifications/intro',
+ 'link' => System::baseUrl() . '/notifications/intro',
'source_name' => ((strlen(stripslashes($contact_record['name']))) ? stripslashes($contact_record['name']) : L10n::t('[Name Withheld]')),
'source_link' => $contact_record['url'],
'source_photo' => $contact_record['photo'],
]);
}
- } 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)
}
return $redirect;
- }
+ }
}
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)) {
// 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 = [];
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;
/// @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);
}
// 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));
$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;
}
}
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']);
$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 {
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']);
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']);
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");
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);
}
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']);
// 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)) {
$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']);
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;
*/
// 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),
// 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?
}
}
- 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) {
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
// 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;
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);
"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);
$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);
$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);
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",
}
}
- 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",
$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;
// 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);
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'];
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;
$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']);
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() {