Moved CONTACT_* constants to Friendica\Model\Contact class, lesser in global namespace (#5490)

* Rewrite:
- moved all CONTACT_* constants from boot.php to Contact class

* CR request:
- renamed Contact::CONTACT_IS_* -> Contact::* ;-)
This commit is contained in:
Roland Häder 2018-07-25 04:53:46 +02:00 committed by Hypolite Petovan
parent cff90e20f2
commit 37253656e3
26 changed files with 139 additions and 118 deletions

View file

@ -1260,7 +1260,7 @@ class DFRN
if (($contact['duplex'] && strlen($contact['pubkey']))
|| ($owner['page-flags'] == PAGE_COMMUNITY && strlen($contact['pubkey']))
|| ($contact['rel'] == CONTACT_IS_SHARING && strlen($contact['pubkey']))
|| ($contact['rel'] == Contact::SHARING && strlen($contact['pubkey']))
) {
openssl_public_decrypt($sent_dfrn_id, $final_dfrn_id, $contact['pubkey']);
openssl_public_decrypt($challenge, $postvars['challenge'], $contact['pubkey']);
@ -1288,7 +1288,7 @@ class DFRN
$postvars['dissolve'] = '1';
}
if ((($contact['rel']) && ($contact['rel'] != CONTACT_IS_SHARING) && (! $contact['blocked'])) || ($owner['page-flags'] == PAGE_COMMUNITY)) {
if ((($contact['rel']) && ($contact['rel'] != Contact::SHARING) && (! $contact['blocked'])) || ($owner['page-flags'] == PAGE_COMMUNITY)) {
$postvars['data'] = $atom;
$postvars['perm'] = 'rw';
} else {
@ -1323,7 +1323,7 @@ class DFRN
if ($dfrn_version >= 2.1) {
if (($contact['duplex'] && strlen($contact['pubkey']))
|| ($owner['page-flags'] == PAGE_COMMUNITY && strlen($contact['pubkey']))
|| ($contact['rel'] == CONTACT_IS_SHARING && strlen($contact['pubkey']))
|| ($contact['rel'] == Contact::SHARING && strlen($contact['pubkey']))
) {
openssl_public_encrypt($key, $postvars['key'], $contact['pubkey']);
} else {
@ -2712,7 +2712,7 @@ class DFRN
$item["owner-id"] = Contact::getIdForURL($importer["url"], 0);
}
if (($importer["rel"] == CONTACT_IS_FOLLOWER) && (!self::tgroupCheck($importer["importer_uid"], $item))) {
if (($importer["rel"] == Contact::FOLLOWER) && (!self::tgroupCheck($importer["importer_uid"], $item))) {
logger("Contact ".$importer["id"]." is only follower and tgroup check was negative.", LOGGER_DEBUG);
return;
}

View file

@ -177,7 +177,7 @@ class Diaspora
'name' => 'relay', 'nick' => 'relay',
'url' => $server_url, 'network' => NETWORK_DIASPORA,
'batch' => $server_url . '/receive/public',
'rel' => CONTACT_IS_FOLLOWER, 'blocked' => false,
'rel' => Contact::FOLLOWER, 'blocked' => false,
'pending' => false, 'writable' => true];
$fields = array_merge($fields, $network_fields);
@ -1079,14 +1079,14 @@ 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_IS_FOLLOWER && in_array($importer["page-flags"], array(PAGE_FREELOVE))) {
//if (!$is_comment && $contact["rel"] == Contact::FOLLOWER && in_array($importer["page-flags"], array(PAGE_FREELOVE))) {
// dba::update(
// 'contact',
// array('rel' => CONTACT_IS_FRIEND, 'writable' => true),
// array('rel' => Contact::FRIEND, 'writable' => true),
// array('id' => $contact["id"], 'uid' => $contact["uid"])
// );
//
// $contact["rel"] = CONTACT_IS_FRIEND;
// $contact["rel"] = Contact::FRIEND;
// logger("defining user ".$contact["nick"]." as friend");
//}
@ -1095,11 +1095,11 @@ class Diaspora
// Maybe blocked, don't accept.
return false;
// We are following this person?
} elseif (($contact["rel"] == CONTACT_IS_SHARING) || ($contact["rel"] == CONTACT_IS_FRIEND)) {
} elseif (($contact["rel"] == Contact::SHARING) || ($contact["rel"] == Contact::FRIEND)) {
// Yes, then it is fine.
return true;
// Is it a post to a community?
} elseif (($contact["rel"] == CONTACT_IS_FOLLOWER) && in_array($importer["page-flags"], [PAGE_COMMUNITY, PAGE_PRVGROUP])) {
} elseif (($contact["rel"] == Contact::FOLLOWER) && in_array($importer["page-flags"], [PAGE_COMMUNITY, PAGE_PRVGROUP])) {
// That's good
return true;
// Is the message a global user or a comment?
@ -2305,10 +2305,10 @@ class Diaspora
{
$a = get_app();
if ($contact["rel"] == CONTACT_IS_SHARING) {
if ($contact["rel"] == Contact::SHARING) {
DBA::update(
'contact',
['rel' => CONTACT_IS_FRIEND, 'writable' => true],
['rel' => Contact::FRIEND, 'writable' => true],
['id' => $contact["id"], 'uid' => $importer["uid"]]
);
}
@ -2359,7 +2359,7 @@ class Diaspora
// If we are now friends, we are sending a share message.
// Normally we needn't to do so, but the first message could have been vanished.
if (in_array($contact["rel"], [CONTACT_IS_FRIEND])) {
if (in_array($contact["rel"], [Contact::FRIEND])) {
$u = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1", intval($importer["uid"]));
if ($u) {
logger("Sending share message to author ".$author." - Contact: ".$contact["id"]." - User: ".$importer["uid"], LOGGER_DEBUG);
@ -2455,16 +2455,16 @@ class Diaspora
Contact::updateAvatar($contact_record["photo"], $importer["uid"], $contact_record["id"]);
// technically they are sharing with us (CONTACT_IS_SHARING),
// technically they are sharing with us (Contact::SHARING),
// 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) {
$new_relation = CONTACT_IS_FRIEND;
$new_relation = Contact::FRIEND;
} elseif (($importer["page-flags"] == PAGE_FREELOVE) && $sharing) {
$new_relation = CONTACT_IS_SHARING;
$new_relation = Contact::SHARING;
} else {
$new_relation = CONTACT_IS_FOLLOWER;
$new_relation = Contact::FOLLOWER;
}
$r = q(
@ -3269,13 +3269,15 @@ class Diaspora
/*
switch ($contact["rel"]) {
case CONTACT_IS_FRIEND:
case Contact::FRIEND:
$following = true;
$sharing = true;
case CONTACT_IS_SHARING:
case Contact::SHARING:
$following = false;
$sharing = true;
case CONTACT_IS_FOLLOWER:
case Contact::FOLLOWER:
$following = true;
$sharing = false;
}
@ -4131,7 +4133,7 @@ class Diaspora
AND `uid` = %d AND `rel` != %d",
DBA::escape(NETWORK_DIASPORA),
intval($uid),
intval(CONTACT_IS_SHARING)
intval(Contact::SHARING)
);
}

View file

@ -76,7 +76,7 @@ class OStatus
if ($aliaslink != '') {
$condition = ["`uid` = ? AND `alias` = ? AND `network` != ? AND `rel` IN (?, ?)",
$importer["uid"], $aliaslink, NETWORK_STATUSNET,
CONTACT_IS_SHARING, CONTACT_IS_FRIEND];
Contact::SHARING, Contact::FRIEND];
$contact = DBA::selectFirst('contact', [], $condition);
}
@ -87,14 +87,14 @@ class OStatus
$condition = ["`uid` = ? AND `nurl` IN (?, ?) AND `network` != ? AND `rel` IN (?, ?)",
$importer["uid"], normalise_link($author["author-link"]), normalise_link($aliaslink),
NETWORK_STATUSNET, CONTACT_IS_SHARING, CONTACT_IS_FRIEND];
NETWORK_STATUSNET, Contact::SHARING, Contact::FRIEND];
$contact = DBA::selectFirst('contact', [], $condition);
}
if (!DBA::isResult($contact) && ($addr != '')) {
$condition = ["`uid` = ? AND `addr` = ? AND `network` != ? AND `rel` IN (?, ?)",
$importer["uid"], $addr, NETWORK_STATUSNET,
CONTACT_IS_SHARING, CONTACT_IS_FRIEND];
Contact::SHARING, Contact::FRIEND];
$contact = DBA::selectFirst('contact', [], $condition);
}