User::PAGE_FLAGS_PRVGROUP => L10n::t('Private Forum')
];
$account_types = [
- 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')
+ User::ACCOUNT_TYPE_PERSON => L10n::t('Personal Page'),
+ User::ACCOUNT_TYPE_ORGANISATION => L10n::t('Organisation Page'),
+ User::ACCOUNT_TYPE_NEWS => L10n::t('News Page'),
+ User::ACCOUNT_TYPE_COMMUNITY => L10n::t('Community Forum'),
+ User::ACCOUNT_TYPE_RELAY => L10n::t('Relay'),
];
$e['page_flags_raw'] = $e['page-flags'];
use Friendica\Database\DBA;
use Friendica\Model\Contact;
use Friendica\Model\Item;
+use Friendica\Model\User;
function community_init(App $a)
{
if ($a->argc > 2) {
switch ($a->argv[2]) {
case 'person':
- $accounttype = Contact::ACCOUNT_TYPE_PERSON;
+ $accounttype = User::ACCOUNT_TYPE_PERSON;
break;
case 'organisation':
- $accounttype = Contact::ACCOUNT_TYPE_ORGANISATION;
+ $accounttype = User::ACCOUNT_TYPE_ORGANISATION;
break;
case 'news':
- $accounttype = Contact::ACCOUNT_TYPE_NEWS;
+ $accounttype = User::ACCOUNT_TYPE_NEWS;
break;
case 'community':
- $accounttype = Contact::ACCOUNT_TYPE_COMMUNITY;
+ $accounttype = User::ACCOUNT_TYPE_COMMUNITY;
break;
}
}
use Friendica\Database\DBA;
use Friendica\Model\Contact;
use Friendica\Model\Profile;
+use Friendica\Model\User;
function noscrape_init(App $a)
{
'guid' => $a->profile['guid'],
'key' => $a->profile['pubkey'],
'homepage' => System::baseUrl()."/profile/{$which}",
- 'comm' => ($a->profile['account-type'] == Contact::ACCOUNT_TYPE_COMMUNITY),
+ 'comm' => ($a->profile['account-type'] == User::ACCOUNT_TYPE_COMMUNITY),
'account-type' => $a->profile['account-type'],
];
/**
* @name account types
*
- * ACCOUNT_TYPE_PERSON - the account belongs to a person
+ * TYPE_UNKNOWN - the account has been imported from gcontact where this is the default type value
+ *
+ * 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
+ * TYPE_ORGANISATION - the account belongs to an organisation
* Associated page type: PAGE_SOAPBOX
*
- * ACCOUNT_TYPE_NEWS - the account is a news reflector
+ * TYPE_NEWS - the account is a news reflector
* Associated page type: PAGE_SOAPBOX
*
- * ACCOUNT_TYPE_COMMUNITY - the account is community forum
+ * TYPE_COMMUNITY - the account is community forum
* Associated page types: PAGE_COMMUNITY, PAGE_PRVGROUP
*
- * ACCOUNT_TYPE_RELAY - the account is a relay
+ * 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;
+ const TYPE_UNKNOWN = -1;
+ const TYPE_PERSON = User::ACCOUNT_TYPE_PERSON;
+ const TYPE_ORGANISATION = User::ACCOUNT_TYPE_ORGANISATION;
+ const TYPE_NEWS = User::ACCOUNT_TYPE_NEWS;
+ const TYPE_COMMUNITY = User::ACCOUNT_TYPE_COMMUNITY;
+ const TYPE_RELAY = User::ACCOUNT_TYPE_RELAY;
/**
* @}
*/
DBA::update('contact', $fields, ['nurl' => Strings::normaliseLink($contact['url'])]);
if (!empty($contact['batch'])) {
- $condition = ['batch' => $contact['batch'], 'contact-type' => self::ACCOUNT_TYPE_RELAY];
+ $condition = ['batch' => $contact['batch'], 'contact-type' => self::TYPE_RELAY];
DBA::update('contact', $fields, $condition);
}
}
$sql = "`item`.`uid` = ?";
}
- $contact_field = ($contact["contact-type"] == self::ACCOUNT_TYPE_COMMUNITY ? 'owner-id' : 'author-id');
+ $contact_field = ($contact["contact-type"] == self::TYPE_COMMUNITY ? 'owner-id' : 'author-id');
if ($thread_mode) {
$condition = ["`$contact_field` = ? AND `gravity` = ? AND " . $sql,
|| (isset($contact['prv']) && intval($contact['prv']))
|| (isset($contact['community']) && intval($contact['community']))
) {
- $type = self::ACCOUNT_TYPE_COMMUNITY;
+ $type = self::TYPE_COMMUNITY;
} else {
- $type = self::ACCOUNT_TYPE_PERSON;
+ $type = self::TYPE_PERSON;
}
// The "contact-type" (contact table) and "account-type" (user table) are more general then the chaos from above.
}
switch ($type) {
- case self::ACCOUNT_TYPE_ORGANISATION:
+ case self::TYPE_ORGANISATION:
$account_type = L10n::t("Organisation");
break;
- case self::ACCOUNT_TYPE_NEWS:
+ case self::TYPE_NEWS:
$account_type = L10n::t('News');
break;
- case self::ACCOUNT_TYPE_COMMUNITY:
+ case self::TYPE_COMMUNITY:
$account_type = L10n::t("Forum");
break;
/**
* @}
*/
+
+ /**
+ * Account types
+ *
+ * ACCOUNT_TYPE_PERSON - the account belongs to a person
+ * Associated page types: PAGE_FLAGS_NORMAL, PAGE_FLAGS_SOAPBOX, PAGE_FLAGS_FREELOVE
+ *
+ * ACCOUNT_TYPE_ORGANISATION - the account belongs to an organisation
+ * Associated page type: PAGE_FLAGS_SOAPBOX
+ *
+ * ACCOUNT_TYPE_NEWS - the account is a news reflector
+ * Associated page type: PAGE_FLAGS_SOAPBOX
+ *
+ * ACCOUNT_TYPE_COMMUNITY - the account is community forum
+ * Associated page types: PAGE_COMMUNITY, PAGE_FLAGS_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;
+ /**
+ * @}
+ */
+
/**
* Returns true if a user record exists with the provided id
*
// 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'] = Contact::ACCOUNT_TYPE_COMMUNITY;
+ $fields['contact-type'] = Contact::TYPE_COMMUNITY;
}
$fieldnames = [];
// Check if the potential receiver is following the actor
// Exception: The receiver is targetted via "to" or this is a comment
- if ((($element != 'as:to') && empty($replyto)) || ($contact['contact-type'] == Contact::ACCOUNT_TYPE_COMMUNITY)) {
+ if ((($element != 'as:to') && empty($replyto)) || ($contact['contact-type'] == Contact::TYPE_COMMUNITY)) {
$networks = [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS];
$condition = ['nurl' => Strings::normaliseLink($actor), 'rel' => [Contact::SHARING, Contact::FRIEND],
'network' => $networks, 'archive' => false, 'pending' => false, 'uid' => $contact['uid']];
// Forum posts are only accepted from forum contacts
- if ($contact['contact-type'] == Contact::ACCOUNT_TYPE_COMMUNITY) {
+ if ($contact['contact-type'] == Contact::TYPE_COMMUNITY) {
$condition['rel'] = [Contact::SHARING, Contact::FRIEND, Contact::FOLLOWER];
}
// When the possible receiver isn't a community, then it is no valid receiver
$owner = User::getOwnerDataById($contact['uid']);
- if (empty($owner) || ($owner['contact-type'] != Contact::ACCOUNT_TYPE_COMMUNITY)) {
+ if (empty($owner) || ($owner['contact-type'] != Contact::TYPE_COMMUNITY)) {
return false;
}
DBA::update('contact', ['contact-type' => $accounttype], ['uid' => 0, 'nurl' => $importer['nurl']]);
}
// A forum contact can either have set "forum" or "prv" - but not both
- if ($accounttype == Contact::ACCOUNT_TYPE_COMMUNITY) {
+ if ($accounttype == User::ACCOUNT_TYPE_COMMUNITY) {
// It's a forum, so either set the public or private forum flag
$condition = ['(`forum` != ? OR `prv` != ?) AND `id` = ?', $forum, !$forum, $importer['id']];
DBA::update('contact', ['forum' => $forum, 'prv' => !$forum], $condition);
// Fetch the relay contact
$condition = ['uid' => 0, 'nurl' => Strings::normaliseLink($server_url),
- 'contact-type' => Contact::ACCOUNT_TYPE_RELAY];
+ 'contact-type' => Contact::TYPE_RELAY];
$contact = DBA::selectFirst('contact', $fields, $condition);
if (DBA::isResult($contact)) {
$fields = array_merge($fields, $network_fields);
$condition = ['uid' => 0, 'nurl' => Strings::normaliseLink($server_url),
- 'contact-type' => Contact::ACCOUNT_TYPE_RELAY];
+ 'contact-type' => Contact::TYPE_RELAY];
if (DBA::exists('contact', $condition)) {
unset($fields['created']);
Logger::log("transmit: ".$logid."-".$guid." to ".$dest_url." returns: ".$return_code);
if (!$return_code || (($return_code == 503) && (stristr($postResult->getHeader(), "retry-after")))) {
- if (!$no_queue && !empty($contact['contact-type']) && ($contact['contact-type'] != Contact::ACCOUNT_TYPE_RELAY)) {
+ if (!$no_queue && !empty($contact['contact-type']) && ($contact['contact-type'] != Contact::TYPE_RELAY)) {
Logger::log("queue message");
// queue message for redelivery
Queue::add($contact["id"], Protocol::DIASPORA, $envelope, $public_batch, $guid);
$attributes = ["href" => System::baseUrl() . $selfUri, "rel" => "self", "type" => "application/atom+xml"];
XML::addElement($doc, $root, "link", "", $attributes);
- if ($owner['account-type'] == Contact::ACCOUNT_TYPE_COMMUNITY) {
+ if ($owner['account-type'] == Contact::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'] == Contact::ACCOUNT_TYPE_COMMUNITY) {
+ if ($owner['account-type'] == User::ACCOUNT_TYPE_COMMUNITY) {
XML::addElement($doc, $author, "activity:object-type", ACTIVITY_OBJ_GROUP);
} else {
XML::addElement($doc, $author, "activity:object-type", ACTIVITY_OBJ_PERSON);
$title = sprintf("New note by %s", $owner["nick"]);
}
- if ($owner['account-type'] == Contact::ACCOUNT_TYPE_COMMUNITY) {
+ if ($owner['account-type'] == User::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' => Strings::normaliseLink($mention)];
$contact = DBA::selectFirst('contact', ['forum', 'prv', 'self', 'contact-type'], $condition);
- if ($contact["forum"] || $contact["prv"] || ($owner['contact-type'] == Contact::ACCOUNT_TYPE_COMMUNITY) ||
- ($contact['self'] && ($owner['account-type'] == Contact::ACCOUNT_TYPE_COMMUNITY))) {
+ if ($contact["forum"] || $contact["prv"] || ($owner['contact-type'] == Contact::TYPE_COMMUNITY) ||
+ ($contact['self'] && ($owner['account-type'] == User::ACCOUNT_TYPE_COMMUNITY))) {
XML::addElement($doc, $entry, "link", "",
[
"rel" => "mentioned",
}
}
- if ($owner['account-type'] == Contact::ACCOUNT_TYPE_COMMUNITY) {
+ if ($owner['account-type'] == User::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'] != Contact::ACCOUNT_TYPE_COMMUNITY) {
+ if ($owner['account-type'] != User::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'] == Contact::ACCOUNT_TYPE_RELAY);
+ $public_dfrn = ($contact['contact-type'] == Contact::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'] != Contact::ACCOUNT_TYPE_COMMUNITY);
+ $walltowall = $top_level && ($owner['id'] != $items[0]['contact-id']) & ($owner['account-type'] != User::ACCOUNT_TYPE_COMMUNITY);
if ($public_message) {
$loc = 'public batch ' . $contact['batch'];
$deliver_status = Diaspora::transmit($owner, $contact, $data, $public, true, 'Queue:' . $q_item['id'], true);
if ((($deliver_status >= 200) && ($deliver_status <= 299)) ||
- ($contact['contact-type'] == Contact::ACCOUNT_TYPE_RELAY)) {
+ ($contact['contact-type'] == Contact::TYPE_RELAY)) {
QueueModel::removeItem($q_item['id']);
} else {
QueueModel::updateTime($q_item['id']);