1
1
Fork 0

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
commit e06fc2aa69
59 changed files with 527 additions and 492 deletions

View file

@ -692,7 +692,7 @@ function api_get_user(App $a, $contact_id = null)
if ($uinfo[0]['self']) {
if ($uinfo[0]['network'] == "") {
$uinfo[0]['network'] = NETWORK_DFRN;
$uinfo[0]['network'] = Protocol::DFRN;
}
$usr = DBA::selectFirst('user', ['default-location'], ['uid' => api_user()]);
@ -4702,7 +4702,7 @@ function api_friendica_remoteauth()
$contact = DBA::selectFirst('contact', [], ['uid' => api_user(), 'nurl' => $c_url]);
if (!DBA::isResult($contact) || ($contact['network'] !== NETWORK_DFRN)) {
if (!DBA::isResult($contact) || ($contact['network'] !== Protocol::DFRN)) {
throw new BadRequestException("Unknown contact");
}

View file

@ -11,6 +11,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\Database\DBA;
use Friendica\Model\Contact;
@ -542,7 +543,7 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o
if ($mode === 'community') {
$writable = true;
} else {
$writable = ($items[0]['uid'] == 0) && in_array($items[0]['network'], [NETWORK_OSTATUS, NETWORK_DIASPORA, NETWORK_DFRN]);
$writable = ($items[0]['uid'] == 0) && in_array($items[0]['network'], [Protocol::OSTATUS, Protocol::DIASPORA, Protocol::DFRN]);
}
if (!local_user()) {
@ -575,7 +576,7 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o
$sparkle = '';
// prevent private email from leaking.
if ($item['network'] === NETWORK_MAIL && local_user() != $item['uid']) {
if ($item['network'] === Protocol::MAIL && local_user() != $item['uid']) {
continue;
}
@ -713,7 +714,7 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o
builtin_activity_puller($item, $conv_responses);
// Only add what is visible
if ($item['network'] === NETWORK_MAIL && local_user() != $item['uid']) {
if ($item['network'] === Protocol::MAIL && local_user() != $item['uid']) {
continue;
}
@ -793,7 +794,7 @@ function conversation_add_children(array $parents, $block_authors, $order, $uid)
foreach ($items as $index => $item) {
if ($item['uid'] == 0) {
$items[$index]['writable'] = in_array($item['network'], [NETWORK_OSTATUS, NETWORK_DIASPORA, NETWORK_DFRN]);
$items[$index]['writable'] = in_array($item['network'], [Protocol::OSTATUS, Protocol::DIASPORA, Protocol::DFRN]);
}
}
@ -842,7 +843,7 @@ function item_photo_menu($item) {
$contact_url = 'contacts/' . $cid;
$posts_link = 'contacts/' . $cid . '/posts';
if (in_array($network, [NETWORK_DFRN, NETWORK_DIASPORA])) {
if (in_array($network, [Protocol::DFRN, Protocol::DIASPORA])) {
$pm_url = 'message/new/' . $cid;
}
}
@ -858,12 +859,12 @@ function item_photo_menu($item) {
L10n::t('Send PM') => $pm_url
];
if ($network == NETWORK_DFRN) {
if ($network == Protocol::DFRN) {
$menu[L10n::t("Poke")] = $poke_link;
}
if ((($cid == 0) || ($rel == Contact::FOLLOWER)) &&
in_array($item['network'], [NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_DIASPORA])) {
in_array($item['network'], [Protocol::DFRN, Protocol::OSTATUS, Protocol::DIASPORA])) {
$menu[L10n::t('Connect/Follow')] = 'follow?url=' . urlencode($item['author-link']);
}
} else {

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\Database\DBA;
use Friendica\Model\Item;
@ -240,7 +241,7 @@ function add_page_info_to_body($body, $texturl = false, $no_photos = false)
*/
function consume_feed($xml, array $importer, array $contact, &$hub, $datedir = 0, $pass = 0)
{
if ($contact['network'] === NETWORK_OSTATUS) {
if ($contact['network'] === Protocol::OSTATUS) {
if ($pass < 2) {
// Test - remove before flight
//$tempfile = tempnam(get_temppath(), "ostatus2");
@ -252,7 +253,7 @@ function consume_feed($xml, array $importer, array $contact, &$hub, $datedir = 0
return;
}
if ($contact['network'] === NETWORK_FEED) {
if ($contact['network'] === Protocol::FEED) {
if ($pass < 2) {
logger("Consume feeds", LOGGER_DEBUG);
Feed::import($xml, $importer, $contact, $hub);
@ -261,7 +262,7 @@ function consume_feed($xml, array $importer, array $contact, &$hub, $datedir = 0
return;
}
if ($contact['network'] === NETWORK_DFRN) {
if ($contact['network'] === Protocol::DFRN) {
logger("Consume DFRN messages", LOGGER_DEBUG);
$r = q("SELECT `contact`.*, `contact`.`uid` AS `importer_uid`,
@ -301,7 +302,7 @@ function subscribe_to_hub($url, array $importer, array $contact, $hubmode = 'sub
* through the direct Diaspora protocol. If we try and use
* the feed, we'll get duplicates. So don't.
*/
if ((!DBA::isResult($r)) || $contact['network'] === NETWORK_DIASPORA) {
if ((!DBA::isResult($r)) || $contact['network'] === Protocol::DIASPORA) {
return;
}

View file

@ -12,6 +12,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\Database\DBA;
use Friendica\Model\Contact;
@ -755,9 +756,9 @@ function contact_block() {
AND NOT `pending` AND NOT `hidden` AND NOT `archive`
AND `network` IN ('%s', '%s', '%s')",
intval($a->profile['uid']),
DBA::escape(NETWORK_DFRN),
DBA::escape(NETWORK_OSTATUS),
DBA::escape(NETWORK_DIASPORA)
DBA::escape(Protocol::DFRN),
DBA::escape(Protocol::OSTATUS),
DBA::escape(Protocol::DIASPORA)
);
if (DBA::isResult($r)) {
$total = intval($r[0]['total']);
@ -773,9 +774,9 @@ function contact_block() {
AND `network` IN ('%s', '%s', '%s')
ORDER BY RAND() LIMIT %d",
intval($a->profile['uid']),
DBA::escape(NETWORK_DFRN),
DBA::escape(NETWORK_OSTATUS),
DBA::escape(NETWORK_DIASPORA),
DBA::escape(Protocol::DFRN),
DBA::escape(Protocol::OSTATUS),
DBA::escape(Protocol::DIASPORA),
intval($shown)
);
if (DBA::isResult($r)) {
@ -1039,7 +1040,7 @@ function redir_private_images($a, &$item)
continue;
}
if ((local_user() == $item['uid']) && ($item['private'] == 1) && ($item['contact-id'] != $a->contact['id']) && ($item['network'] == NETWORK_DFRN)) {
if ((local_user() == $item['uid']) && ($item['private'] == 1) && ($item['contact-id'] != $a->contact['id']) && ($item['network'] == Protocol::DFRN)) {
$img_url = 'redir?f=1&quiet=1&url=' . urlencode($mtch[1]) . '&conurl=' . urlencode($item['author-link']);
$item['body'] = str_replace($mtch[0], '[img]' . $img_url . '[/img]', $item['body']);
}