Stopped using deprecated constants NETWORK_* (#5537)

* Rewrite:
- stopped using deprecated NETWORK_* constants, now Protocol::* should be used
- still left them intact for slow/lazy developers ...

* Removed deprecated NETWORK_* constants as per code reviewer's request.
This commit is contained in:
Roland Häder 2018-08-11 22:40:44 +02:00 committed by Hypolite Petovan
parent c623465df2
commit e06fc2aa69
59 changed files with 527 additions and 492 deletions

View file

@ -9,6 +9,7 @@ use Friendica\Core\Addon;
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\PConfig;
use Friendica\Core\Protocol;
use Friendica\Core\System;
use Friendica\Core\Worker;
use Friendica\Database\DBA;
@ -146,7 +147,7 @@ class Contact extends BaseObject
AND `contact`.`notify` != ""',
$gid,
local_user(),
NETWORK_OSTATUS
Protocol::OSTATUS
);
$return = $contacts['count'];
}
@ -334,7 +335,7 @@ class Contact extends BaseObject
*/
public static function terminateFriendship(array $user, array $contact)
{
if (in_array($contact['network'], [NETWORK_OSTATUS, NETWORK_DFRN])) {
if (in_array($contact['network'], [Protocol::OSTATUS, Protocol::DFRN])) {
// create an unfollow slap
$item = [];
$item['verb'] = NAMESPACE_OSTATUS . "/unfollow";
@ -349,7 +350,7 @@ class Contact extends BaseObject
if (!empty($contact['notify'])) {
Salmon::slapper($user, $contact['notify'], $slap);
}
} elseif ($contact['network'] == NETWORK_DIASPORA) {
} elseif ($contact['network'] == Protocol::DIASPORA) {
Diaspora::sendUnshare($user, $contact);
}
}
@ -508,7 +509,7 @@ class Contact extends BaseObject
// If there is more than one entry we filter out the connector networks
if (count($r) > 1) {
foreach ($r as $id => $result) {
if ($result["network"] == NETWORK_STATUSNET) {
if ($result["network"] == Protocol::STATUSNET) {
unset($r[$id]);
}
}
@ -562,13 +563,13 @@ class Contact extends BaseObject
}
if ((empty($profile["addr"]) || empty($profile["name"])) && (defaults($profile, "gid", 0) != 0)
&& in_array($profile["network"], [NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS])
&& in_array($profile["network"], [Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS])
) {
Worker::add(PRIORITY_LOW, "UpdateGContact", $profile["gid"]);
}
// Show contact details of Diaspora contacts only if connected
if ((defaults($profile, "cid", 0) == 0) && (defaults($profile, "network", "") == NETWORK_DIASPORA)) {
if ((defaults($profile, "cid", 0) == 0) && (defaults($profile, "network", "") == Protocol::DIASPORA)) {
$profile["location"] = "";
$profile["about"] = "";
$profile["gender"] = "";
@ -687,7 +688,7 @@ class Contact extends BaseObject
}
$sparkle = false;
if (($contact['network'] === NETWORK_DFRN) && !$contact['self']) {
if (($contact['network'] === Protocol::DFRN) && !$contact['self']) {
$sparkle = true;
$profile_link = System::baseUrl() . '/redir/' . $contact['id'];
} else {
@ -704,11 +705,11 @@ class Contact extends BaseObject
$profile_link = $profile_link . '?url=profile';
}
if (in_array($contact['network'], [NETWORK_DFRN, NETWORK_DIASPORA]) && !$contact['self']) {
if (in_array($contact['network'], [Protocol::DFRN, Protocol::DIASPORA]) && !$contact['self']) {
$pm_url = System::baseUrl() . '/message/new/' . $contact['id'];
}
if (($contact['network'] == NETWORK_DFRN) && !$contact['self']) {
if (($contact['network'] == Protocol::DFRN) && !$contact['self']) {
$poke_link = System::baseUrl() . '/poke/?f=&c=' . $contact['id'];
}
@ -869,7 +870,7 @@ class Contact extends BaseObject
}
// Last try in gcontact for unsupported networks
if (!in_array($data["network"], [NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_DIASPORA, NETWORK_PUMPIO, NETWORK_MAIL, NETWORK_FEED])) {
if (!in_array($data["network"], [Protocol::DFRN, Protocol::OSTATUS, Protocol::DIASPORA, Protocol::PUMPIO, Protocol::MAIL, Protocol::FEED])) {
if ($uid != 0) {
return 0;
}
@ -1108,7 +1109,7 @@ class Contact extends BaseObject
return '';
}
if (in_array($r[0]["network"], [NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS, ""])) {
if (in_array($r[0]["network"], [Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS, ""])) {
$sql = "(`item`.`uid` = 0 OR (`item`.`uid` = ? AND NOT `item`.`global`))";
} else {
$sql = "`item`.`uid` = ?";
@ -1400,7 +1401,7 @@ class Contact extends BaseObject
);
}
if (($ret['network'] === NETWORK_DFRN) && !DBA::isResult($r)) {
if (($ret['network'] === Protocol::DFRN) && !DBA::isResult($r)) {
if ($interactive) {
if (strlen($a->urlpath)) {
$myaddr = bin2hex(System::baseUrl() . '/profile/' . $a->user['nickname']);
@ -1412,14 +1413,14 @@ class Contact extends BaseObject
// NOTREACHED
}
} elseif (Config::get('system', 'dfrn_only') && ($ret['network'] != NETWORK_DFRN)) {
} elseif (Config::get('system', 'dfrn_only') && ($ret['network'] != Protocol::DFRN)) {
$result['message'] = L10n::t('This site is not configured to allow communications with other networks.') . EOL;
$result['message'] != L10n::t('No compatible communication protocols or feeds were discovered.') . EOL;
return $result;
}
// This extra param just confuses things, remove it
if ($ret['network'] === NETWORK_DIASPORA) {
if ($ret['network'] === Protocol::DIASPORA) {
$ret['url'] = str_replace('?absolute=true', '', $ret['url']);
}
@ -1443,7 +1444,7 @@ class Contact extends BaseObject
return $result;
}
if ($ret['network'] === NETWORK_OSTATUS && Config::get('system', 'ostatus_disabled')) {
if ($ret['network'] === Protocol::OSTATUS && Config::get('system', 'ostatus_disabled')) {
$result['message'] .= L10n::t('The profile address specified belongs to a network which has been disabled on this site.') . EOL;
$ret['notify'] = '';
}
@ -1452,13 +1453,13 @@ class Contact extends BaseObject
$result['message'] .= L10n::t('Limited profile. This person will be unable to receive direct/personal notifications from you.') . EOL;
}
$writeable = ((($ret['network'] === NETWORK_OSTATUS) && ($ret['notify'])) ? 1 : 0);
$writeable = ((($ret['network'] === Protocol::OSTATUS) && ($ret['notify'])) ? 1 : 0);
$subhub = (($ret['network'] === NETWORK_OSTATUS) ? true : false);
$subhub = (($ret['network'] === Protocol::OSTATUS) ? true : false);
$hidden = (($ret['network'] === NETWORK_MAIL) ? 1 : 0);
$hidden = (($ret['network'] === Protocol::MAIL) ? 1 : 0);
if (in_array($ret['network'], [NETWORK_MAIL, NETWORK_DIASPORA])) {
if (in_array($ret['network'], [Protocol::MAIL, Protocol::DIASPORA])) {
$writeable = 1;
}
@ -1469,7 +1470,7 @@ class Contact extends BaseObject
$fields = ['rel' => $new_relation, 'subhub' => $subhub, 'readonly' => false];
DBA::update('contact', $fields, ['id' => $r[0]['id']]);
} else {
$new_relation = ((in_array($ret['network'], [NETWORK_MAIL])) ? self::FRIEND : self::SHARING);
$new_relation = ((in_array($ret['network'], [Protocol::MAIL])) ? self::FRIEND : self::SHARING);
// create contact record
DBA::insert('contact', [
@ -1522,7 +1523,7 @@ class Contact extends BaseObject
);
if (DBA::isResult($r)) {
if (in_array($contact['network'], [NETWORK_OSTATUS, NETWORK_DFRN])) {
if (in_array($contact['network'], [Protocol::OSTATUS, Protocol::DFRN])) {
// create a follow slap
$item = [];
$item['verb'] = ACTIVITY_FOLLOW;
@ -1536,7 +1537,7 @@ class Contact extends BaseObject
if (!empty($contact['notify'])) {
Salmon::slapper($r[0], $contact['notify'], $slap);
}
} elseif ($contact['network'] == NETWORK_DIASPORA) {
} elseif ($contact['network'] == Protocol::DIASPORA) {
$ret = Diaspora::sendShare($a->user, $contact);
logger('share returns: ' . $ret);
}
@ -1817,7 +1818,7 @@ class Contact extends BaseObject
*/
public static function magicLinkbyContact($contact, $url = '')
{
if ($contact['network'] != NETWORK_DFRN) {
if ($contact['network'] != Protocol::DFRN) {
return $url ?: $contact['url']; // Equivalent to ($url != '') ? $url : $contact['url'];
}