mirror of
https://github.com/friendica/friendica
synced 2025-04-29 10:24:23 +02:00
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
|
@ -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']);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue