Browse Source

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.
pull/5603/head
Roland Häder 3 years ago
committed by Hypolite Petovan
parent
commit
e06fc2aa69
59 changed files with 528 additions and 493 deletions
  1. +20
    -51
      boot.php
  2. +2
    -2
      include/api.php
  3. +8
    -7
      include/conversation.php
  4. +5
    -4
      include/items.php
  5. +8
    -7
      include/text.php
  6. +9
    -8
      mod/acl.php
  7. +16
    -15
      mod/contacts.php
  8. +4
    -3
      mod/crepair.php
  9. +2
    -1
      mod/delegate.php
  10. +10
    -9
      mod/dfrn_confirm.php
  11. +11
    -10
      mod/dfrn_request.php
  12. +8
    -7
      mod/dirfind.php
  13. +3
    -3
      mod/display.php
  14. +3
    -2
      mod/fetch.php
  15. +9
    -8
      mod/follow.php
  16. +11
    -10
      mod/item.php
  17. +3
    -2
      mod/network.php
  18. +4
    -3
      mod/noscrape.php
  19. +7
    -6
      mod/notifications.php
  20. +3
    -2
      mod/ostatus_subscribe.php
  21. +20
    -19
      mod/poco.php
  22. +8
    -5
      mod/profperm.php
  23. +4
    -3
      mod/pubsub.php
  24. +2
    -1
      mod/redir.php
  25. +3
    -2
      mod/repair_ostatus.php
  26. +4
    -3
      mod/salmon.php
  27. +6
    -4
      mod/unfollow.php
  28. +7
    -6
      mod/viewcontacts.php
  29. +17
    -16
      src/Content/ContactSelector.php
  30. +7
    -6
      src/Content/Widget.php
  31. +9
    -5
      src/Core/ACL.php
  32. +5
    -4
      src/Core/NotificationsManager.php
  33. +5
    -4
      src/Core/UserImport.php
  34. +4
    -3
      src/Database/PostUpdate.php
  35. +24
    -23
      src/Model/Contact.php
  36. +3
    -2
      src/Model/Conversation.php
  37. +38
    -37
      src/Model/GContact.php
  38. +21
    -20
      src/Model/Item.php
  39. +5
    -2
      src/Model/ItemContent.php
  40. +9
    -8
      src/Model/Profile.php
  41. +2
    -1
      src/Model/User.php
  42. +19
    -18
      src/Network/Probe.php
  43. +7
    -6
      src/Object/Post.php
  44. +3
    -2
      src/Object/Thread.php
  45. +5
    -4
      src/Protocol/DFRN.php
  46. +18
    -17
      src/Protocol/Diaspora.php
  47. +2
    -1
      src/Protocol/Email.php
  48. +3
    -2
      src/Protocol/Feed.php
  49. +10
    -9
      src/Protocol/OStatus.php
  50. +40
    -39
      src/Protocol/PortableContact.php
  51. +10
    -9
      src/Worker/Cron.php
  52. +4
    -3
      src/Worker/CronJobs.php
  53. +8
    -7
      src/Worker/Delivery.php
  54. +8
    -7
      src/Worker/DiscoverPoCo.php
  55. +4
    -3
      src/Worker/GProbe.php
  56. +12
    -11
      src/Worker/Notifier.php
  57. +17
    -16
      src/Worker/OnePoll.php
  58. +6
    -3
      src/Worker/Queue.php
  59. +3
    -2
      src/Worker/UpdateGContact.php

+ 20
- 51
boot.php View File

@ -179,63 +179,32 @@ define('CP_USERS_AND_GLOBAL', 2);
* @}
*/
/**
* @name Network constants
* @deprecated since version 3.6
* @see Protocol
*
* Network and protocol family types
* @{
*/
define('NETWORK_DFRN' , Protocol::DFRN); // Friendica, Mistpark, other DFRN implementations
define('NETWORK_ZOT' , Protocol::ZOT); // Zot! - Currently unsupported
define('NETWORK_OSTATUS' , Protocol::OSTATUS); // GNU-social, Pleroma, Mastodon, other OStatus implementations
define('NETWORK_FEED' , Protocol::FEED); // RSS/Atom feeds with no known "post/notify" protocol
define('NETWORK_DIASPORA' , Protocol::DIASPORA); // Diaspora
define('NETWORK_MAIL' , Protocol::MAIL); // IMAP/POP
define('NETWORK_FACEBOOK' , Protocol::FACEBOOK); // Facebook API
define('NETWORK_LINKEDIN' , Protocol::LINKEDIN); // LinkedIn
define('NETWORK_XMPP' , Protocol::XMPP); // XMPP - Currently unsupported
define('NETWORK_MYSPACE' , Protocol::MYSPACE); // MySpace - Currently unsupported
define('NETWORK_GPLUS' , Protocol::GPLUS); // Google+
define('NETWORK_PUMPIO' , Protocol::PUMPIO); // pump.io
define('NETWORK_TWITTER' , Protocol::TWITTER); // Twitter
define('NETWORK_DIASPORA2', Protocol::DIASPORA2); // Diaspora connector
define('NETWORK_STATUSNET', Protocol::STATUSNET); // Statusnet connector
define('NETWORK_NEWS' , Protocol::NEWS); // Network News Transfer Protocol - Currently unsupported
define('NETWORK_ICALENDAR', Protocol::ICALENDAR); // iCalendar - Currently unsupported
define('NETWORK_PNUT' , Protocol::PNUT); // pnut.io - Currently unsupported
define('NETWORK_PHANTOM' , Protocol::PHANTOM); // Place holder
/**
* @}
*/
/**
* These numbers are used in stored permissions
* and existing allocations MUST NEVER BE CHANGED
* OR RE-ASSIGNED! You may only add to them.
*/
$netgroup_ids = [
NETWORK_DFRN => (-1),
NETWORK_ZOT => (-2),
NETWORK_OSTATUS => (-3),
NETWORK_FEED => (-4),
NETWORK_DIASPORA => (-5),
NETWORK_MAIL => (-6),
NETWORK_FACEBOOK => (-8),
NETWORK_LINKEDIN => (-9),
NETWORK_XMPP => (-10),
NETWORK_MYSPACE => (-11),
NETWORK_GPLUS => (-12),
NETWORK_PUMPIO => (-13),
NETWORK_TWITTER => (-14),
NETWORK_DIASPORA2 => (-15),
NETWORK_STATUSNET => (-16),
NETWORK_NEWS => (-18),
NETWORK_ICALENDAR => (-19),
NETWORK_PNUT => (-20),
NETWORK_PHANTOM => (-127),
Protocol::DFRN => (-1),
Protocol::ZOT => (-2),
Protocol::OSTATUS => (-3),
Protocol::FEED => (-4),
Protocol::DIASPORA => (-5),
Protocol::MAIL => (-6),
Protocol::FACEBOOK => (-8),
Protocol::LINKEDIN => (-9),
Protocol::XMPP => (-10),
Protocol::MYSPACE => (-11),
Protocol::GPLUS => (-12),
Protocol::PUMPIO => (-13),
Protocol::TWITTER => (-14),
Protocol::DIASPORA2 => (-15),
Protocol::STATUSNET => (-16),
Protocol::NEWS => (-18),
Protocol::ICALENDAR => (-19),
Protocol::PNUT => (-20),
Protocol::PHANTOM => (-127),
];
/**


+ 2
- 2
include/api.php 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");
}


+ 8
- 7
include/conversation.php 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 {


+ 5
- 4
include/items.php 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;
}


+ 8
- 7
include/text.php 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']);
}


+ 9
- 8
mod/acl.php View File

@ -6,6 +6,7 @@ use Friendica\App;
use Friendica\Content\Widget;
use Friendica\Core\ACL;
use Friendica\Core\Addon;
use Friendica\Core\Protocol;
use Friendica\Database\DBA;
use Friendica\Model\Contact;
use Friendica\Model\Item;
@ -84,8 +85,8 @@ function acl_content(App $a)
AND `success_update` >= `failure_update`
AND `network` IN ('%s', '%s') $sql_extra2",
intval(local_user()),
DBA::escape(NETWORK_DFRN),
DBA::escape(NETWORK_DIASPORA)
DBA::escape(Protocol::DFRN),
DBA::escape(Protocol::DIASPORA)
);
$contact_count = (int) $r[0]['c'];
} elseif ($type == 'a') {
@ -143,8 +144,8 @@ function acl_content(App $a)
$sql_extra2
ORDER BY `name` ASC ",
intval(local_user()),
DBA::escape(NETWORK_OSTATUS),
DBA::escape(NETWORK_STATUSNET)
DBA::escape(Protocol::OSTATUS),
DBA::escape(Protocol::STATUSNET)
);
} elseif ($type == 'c') {
$r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag`, `addr`, `forum`, `prv` FROM `contact`
@ -153,7 +154,7 @@ function acl_content(App $a)
$sql_extra2
ORDER BY `name` ASC ",
intval(local_user()),
DBA::escape(NETWORK_STATUSNET)
DBA::escape(Protocol::STATUSNET)
);
} elseif ($type == 'f') {
$r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag`, `addr`, `forum`, `prv` FROM `contact`
@ -163,7 +164,7 @@ function acl_content(App $a)
$sql_extra2
ORDER BY `name` ASC ",
intval(local_user()),
DBA::escape(NETWORK_STATUSNET)
DBA::escape(Protocol::STATUSNET)
);
} elseif ($type == 'm') {
$r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag`, `addr` FROM `contact`
@ -172,8 +173,8 @@ function acl_content(App $a)
$sql_extra2
ORDER BY `name` ASC ",
intval(local_user()),
DBA::escape(NETWORK_DFRN),
DBA::escape(NETWORK_DIASPORA)
DBA::escape(Protocol::DFRN),
DBA::escape(Protocol::DIASPORA)
);
} elseif ($type == 'a') {
$r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag`, `addr`, `forum`, `prv` FROM `contact`


+ 16
- 15
mod/contacts.php View File

@ -10,6 +10,7 @@ use Friendica\Content\Text\BBCode;
use Friendica\Content\Widget;
use Friendica\Core\Addon;
use Friendica\Core\L10n;
use Friendica\Core\Protocol;
use Friendica\Core\System;
use Friendica\Core\Worker;
use Friendica\Database\DBA;
@ -54,7 +55,7 @@ function contacts_init(App $a)
$a->data['contact'] = $contact;
if (($a->data['contact']['network'] != "") && ($a->data['contact']['network'] != NETWORK_DFRN)) {
if (($a->data['contact']['network'] != "") && ($a->data['contact']['network'] != Protocol::DFRN)) {
$networkname = format_network_name($a->data['contact']['network'], $a->data['contact']['url']);
} else {
$networkname = '';
@ -248,7 +249,7 @@ function _contact_update($contact_id)
$uid = $contact["uid"];
if ($contact["network"] == NETWORK_OSTATUS) {
if ($contact["network"] == Protocol::OSTATUS) {
$result = Contact::createFromProbe($uid, $contact["url"], false, $contact["network"]);
if ($result['success']) {
@ -272,7 +273,7 @@ function _contact_update_profile($contact_id)
$data = Probe::uri($contact["url"], "", 0, false);
// "Feed" or "Unknown" is mostly a sign of communication problems
if ((in_array($data["network"], [NETWORK_FEED, NETWORK_PHANTOM])) && ($data["network"] != $contact["network"])) {
if ((in_array($data["network"], [Protocol::FEED, Protocol::PHANTOM])) && ($data["network"] != $contact["network"])) {
return;
}
@ -280,7 +281,7 @@ function _contact_update_profile($contact_id)
"poco", "network", "alias"];
$update = [];
if ($data["network"] == NETWORK_OSTATUS) {
if ($data["network"] == Protocol::OSTATUS) {
$result = Contact::createFromProbe($uid, $data["url"], false);
if ($result['success']) {
@ -532,7 +533,7 @@ function contacts_content(App $a)
break;
}
if (!in_array($contact['network'], [NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_DIASPORA])) {
if (!in_array($contact['network'], [Protocol::DFRN, Protocol::OSTATUS, Protocol::DIASPORA])) {
$relation_text = "";
}
@ -552,9 +553,9 @@ function contacts_content(App $a)
if ($contact['last-update'] > NULL_DATE) {
$last_update .= ' ' . (($contact['last-update'] <= $contact['success_update']) ? L10n::t("\x28Update was successful\x29") : L10n::t("\x28Update was not successful\x29"));
}
$lblsuggest = (($contact['network'] === NETWORK_DFRN) ? L10n::t('Suggest friends') : '');
$lblsuggest = (($contact['network'] === Protocol::DFRN) ? L10n::t('Suggest friends') : '');
$poll_enabled = in_array($contact['network'], [NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_FEED, NETWORK_MAIL]);
$poll_enabled = in_array($contact['network'], [Protocol::DFRN, Protocol::OSTATUS, Protocol::FEED, Protocol::MAIL]);
$nettype = L10n::t('Network type: %s', ContactSelector::networkToName($contact['network'], $contact["url"]));
@ -564,7 +565,7 @@ function contacts_content(App $a)
$lost_contact = (($contact['archive'] && $contact['term-date'] > NULL_DATE && $contact['term-date'] < DateTimeFormat::utcNow()) ? L10n::t('Communications lost with this contact!') : '');
$fetch_further_information = null;
if ($contact['network'] == NETWORK_FEED) {
if ($contact['network'] == Protocol::FEED) {
$fetch_further_information = [
'fetch_further_information',
L10n::t('Fetch further information for feeds'),
@ -579,19 +580,19 @@ function contacts_content(App $a)
}
$poll_interval = null;
if (in_array($contact['network'], [NETWORK_FEED, NETWORK_MAIL])) {
if (in_array($contact['network'], [Protocol::FEED, Protocol::MAIL])) {
$poll_interval = ContactSelector::pollInterval($contact['priority'], (!$poll_enabled));
}
$profile_select = null;
if ($contact['network'] == NETWORK_DFRN) {
$profile_select = ContactSelector::profileAssign($contact['profile-id'], (($contact['network'] !== NETWORK_DFRN) ? true : false));
if ($contact['network'] == Protocol::DFRN) {
$profile_select = ContactSelector::profileAssign($contact['profile-id'], (($contact['network'] !== Protocol::DFRN) ? true : false));
}
/// @todo Only show the following link with DFRN when the remote version supports it
$follow = '';
$follow_text = '';
if (in_array($contact['network'], [NETWORK_DIASPORA, NETWORK_OSTATUS, NETWORK_DFRN])) {
if (in_array($contact['network'], [Protocol::DIASPORA, Protocol::OSTATUS, Protocol::DFRN])) {
if ($contact['rel'] == Contact::FOLLOWER) {
$follow = System::baseUrl(true) . "/follow?url=" . urlencode($contact["url"]);
$follow_text = L10n::t("Connect/Follow");
@ -637,7 +638,7 @@ function contacts_content(App $a)
'$contact_id' => $contact['id'],
'$block_text' => (($contact['blocked']) ? L10n::t('Unblock') : L10n::t('Block') ),
'$ignore_text' => (($contact['readonly']) ? L10n::t('Unignore') : L10n::t('Ignore') ),
'$insecure' => (($contact['network'] !== NETWORK_DFRN && $contact['network'] !== NETWORK_MAIL && $contact['network'] !== NETWORK_DIASPORA) ? $insecure : ''),
'$insecure' => (($contact['network'] !== Protocol::DFRN && $contact['network'] !== Protocol::MAIL && $contact['network'] !== Protocol::DIASPORA) ? $insecure : ''),
'$info' => $contact['info'],
'$cinfo' => ['info', '', $contact['info'], ''],
'$blocked' => (($contact['blocked']) ? L10n::t('Currently blocked') : ''),
@ -991,11 +992,11 @@ function _contact_detail_for_template(array $rr)
*/
function contact_actions($contact)
{
$poll_enabled = in_array($contact['network'], [NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_FEED, NETWORK_MAIL]);
$poll_enabled = in_array($contact['network'], [Protocol::DFRN, Protocol::OSTATUS, Protocol::FEED, Protocol::MAIL]);
$contact_actions = [];
// Provide friend suggestion only for Friendica contacts
if ($contact['network'] === NETWORK_DFRN) {
if ($contact['network'] === Protocol::DFRN) {
$contact_actions['suggest'] = [
'label' => L10n::t('Suggest friends'),
'url' => 'fsuggest/' . $contact['id'],


+ 4
- 3
mod/crepair.php View File

@ -6,6 +6,7 @@
use Friendica\App;
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\Protocol;
use Friendica\Database\DBA;
use Friendica\Model\Contact;
use Friendica\Model\Profile;
@ -122,17 +123,17 @@ function crepair_content(App $a)
// Disable remote self for everything except feeds.
// There is an issue when you repeat an item from maybe twitter and you got comments from friendica and twitter
// Problem is, you couldn't reply to both networks.
if (!in_array($contact['network'], [NETWORK_FEED, NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_TWITTER])) {
if (!in_array($contact['network'], [Protocol::FEED, Protocol::DFRN, Protocol::DIASPORA, Protocol::TWITTER])) {
$allow_remote_self = false;
}
if ($contact['network'] == NETWORK_FEED) {
if ($contact['network'] == Protocol::FEED) {
$remote_self_options = ['0' => L10n::t('No mirroring'), '1' => L10n::t('Mirror as forwarded posting'), '2' => L10n::t('Mirror as my own posting')];
} else {
$remote_self_options = ['0' => L10n::t('No mirroring'), '2' => L10n::t('Mirror as my own posting')];
}
$update_profile = in_array($contact['network'], [NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS]);
$update_profile = in_array($contact['network'], [Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS]);
$tab_str = contacts_tab($a, $contact['id'], 5);


+ 2
- 1
mod/delegate.php View File

@ -5,6 +5,7 @@
use Friendica\App;
use Friendica\Core\L10n;
use Friendica\Core\Protocol;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\Model\User;
@ -112,7 +113,7 @@ function delegate_content(App $a)
AND `network` = '%s' ",
DBA::escape(normalise_link(System::baseUrl())),
intval(local_user()),
DBA::escape(NETWORK_DFRN)
DBA::escape(Protocol::DFRN)
);
if (DBA::isResult($r)) {
$nicknames = [];


+ 10
- 9
mod/dfrn_confirm.php View File

@ -20,6 +20,7 @@
use Friendica\App;
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\Protocol;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\Model\Contact;
@ -136,13 +137,13 @@ function dfrn_confirm_post(App $a, $handsfree = null)
$dfrn_confirm = $contact['confirm'];
$aes_allow = $contact['aes_allow'];
$network = ((strlen($contact['issued-id'])) ? NETWORK_DFRN : NETWORK_OSTATUS);
$network = ((strlen($contact['issued-id'])) ? Protocol::DFRN : Protocol::OSTATUS);
if ($contact['network']) {
$network = $contact['network'];
}
if ($network === NETWORK_DFRN) {
if ($network === Protocol::DFRN) {
/*
* Generate a key pair for all further communications with this person.
* We have a keypair for every contact, and a site key for unknown people.
@ -304,7 +305,7 @@ function dfrn_confirm_post(App $a, $handsfree = null)
logger('dfrn_confirm: confirm - imported photos');
if ($network === NETWORK_DFRN) {
if ($network === Protocol::DFRN) {
$new_relation = Contact::FOLLOWER;
if (($relation == Contact::SHARING) || ($duplex)) {
$new_relation = Contact::FRIEND;
@ -328,12 +329,12 @@ function dfrn_confirm_post(App $a, $handsfree = null)
DBA::escape(DateTimeFormat::utcNow()),
intval($duplex),
intval($hidden),
DBA::escape(NETWORK_DFRN),
DBA::escape(Protocol::DFRN),
intval($contact_id)
);
} else {
// $network !== NETWORK_DFRN
$network = defaults($contact, 'network', NETWORK_OSTATUS);
// $network !== Protocol::DFRN
$network = defaults($contact, 'network', Protocol::OSTATUS);
$arr = Probe::uri($contact['url']);
@ -345,7 +346,7 @@ function dfrn_confirm_post(App $a, $handsfree = null)
$new_relation = $contact['rel'];
$writable = $contact['writable'];
if ($network === NETWORK_DIASPORA) {
if ($network === Protocol::DIASPORA) {
if ($duplex) {
$new_relation = Contact::FRIEND;
} else {
@ -392,7 +393,7 @@ function dfrn_confirm_post(App $a, $handsfree = null)
// reload contact info
$contact = DBA::selectFirst('contact', [], ['id' => $contact_id]);
if ((isset($new_relation) && $new_relation == Contact::FRIEND)) {
if (DBA::isResult($contact) && ($contact['network'] === NETWORK_DIASPORA)) {
if (DBA::isResult($contact) && ($contact['network'] === Protocol::DIASPORA)) {
$ret = Diaspora::sendShare($user, $contact);
logger('share returns: ' . $ret);
}
@ -573,7 +574,7 @@ function dfrn_confirm_post(App $a, $handsfree = null)
intval($duplex),
intval($forum),
intval($prv),
DBA::escape(NETWORK_DFRN),
DBA::escape(Protocol::DFRN),
intval($dfrn_record)
);
if (!DBA::isResult($r)) { // indicates schema is messed up or total db failure


+ 11
- 10
mod/dfrn_request.php View File

@ -15,6 +15,7 @@
use Friendica\App;
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\Protocol;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\Model\Contact;
@ -148,7 +149,7 @@ function dfrn_request_post(App $a)
$parms['dfrn-confirm'],
$parms['dfrn-notify'],
$parms['dfrn-poll'],
DBA::escape(NETWORK_DFRN),
DBA::escape(Protocol::DFRN),
intval($aes_allow),
intval($hidden),
intval($blocked),
@ -287,18 +288,18 @@ function dfrn_request_post(App $a)
// Every time we detect the remote subscription we define this as OStatus.
// We do this even if it is not OStatus.
// we only need to pass this through another section of the code.
if ($network != NETWORK_DIASPORA) {
$network = NETWORK_OSTATUS;
if ($network != Protocol::DIASPORA) {
$network = Protocol::OSTATUS;
}
$url = substr($url, 5);
} else {
$network = NETWORK_DFRN;
$network = Protocol::DFRN;
}
logger('dfrn_request: url: ' . $url . ',network=' . $network, LOGGER_DEBUG);
if ($network === NETWORK_DFRN) {
if ($network === Protocol::DFRN) {
$ret = q("SELECT * FROM `contact` WHERE `uid` = %d AND `url` = '%s' AND `self` = 0 LIMIT 1",
intval($uid),
DBA::escape($url)
@ -388,7 +389,7 @@ function dfrn_request_post(App $a)
$parms['dfrn-confirm'],
$parms['dfrn-notify'],
$parms['dfrn-poll'],
DBA::escape(NETWORK_DFRN),
DBA::escape(Protocol::DFRN),
intval($blocked),
intval($pending)
);
@ -441,15 +442,15 @@ function dfrn_request_post(App $a)
. (($aes_allow) ? "&aes_allow=1" : "")
);
// NOTREACHED
// END $network === NETWORK_DFRN
} elseif (($network != NETWORK_PHANTOM) && ($url != "")) {
// END $network === Protocol::DFRN
} elseif (($network != Protocol::PHANTOM) && ($url != "")) {
/* Substitute our user's feed URL into $url template
* Send the subscriber home to subscribe
*/
// Diaspora needs the uri in the format user@domain.tld
// Diaspora will support the remote subscription in a future version
if ($network == NETWORK_DIASPORA) {
if ($network == Protocol::DIASPORA) {
$uri = $nickname . '@' . $a->get_hostname();
if ($a->get_path()) {
@ -464,7 +465,7 @@ function dfrn_request_post(App $a)
$url = str_replace('{uri}', $uri, $url);
goaway($url);
// NOTREACHED
// END $network != NETWORK_PHANTOM
// END $network != Protocol::PHANTOM
} else {
notice(L10n::t("Remote subscription can't be done for your network. Please subscribe directly on your system.") . EOL);
return;


+ 8
- 7
mod/dirfind.php View File

@ -8,6 +8,7 @@ use Friendica\Content\ContactSelector;
use Friendica\Content\Widget;
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\Protocol;
use Friendica\Core\System;
use Friendica\Core\Worker;
use Friendica\Database\DBA;
@ -53,7 +54,7 @@ function dirfind_content(App $a, $prefix = "") {
if ((valid_email($search) && Network::isEmailDomainValid($search)) ||
(substr(normalise_link($search), 0, 7) == "http://")) {
$user_data = Probe::uri($search);
$discover_user = (in_array($user_data["network"], [NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_DIASPORA]));
$discover_user = (in_array($user_data["network"], [Protocol::DFRN, Protocol::OSTATUS, Protocol::DIASPORA]));
}
}
@ -102,15 +103,15 @@ function dirfind_content(App $a, $prefix = "") {
$startrec = (($a->pager['page']) * $perpage) - $perpage;
if (Config::get('system','diaspora_enabled')) {
$diaspora = NETWORK_DIASPORA;
$diaspora = Protocol::DIASPORA;
} else {
$diaspora = NETWORK_DFRN;
$diaspora = Protocol::DFRN;
}
if (!Config::get('system','ostatus_disabled')) {
$ostatus = NETWORK_OSTATUS;
$ostatus = Protocol::OSTATUS;
} else {
$ostatus = NETWORK_DFRN;
$ostatus = Protocol::DFRN;
}
$search2 = "%".$search."%";
@ -121,7 +122,7 @@ function dirfind_content(App $a, $prefix = "") {
((`last_contact` >= `last_failure`) OR (`updated` >= `last_failure`)) AND
(`url` LIKE '%s' OR `name` LIKE '%s' OR `location` LIKE '%s' OR
`addr` LIKE '%s' OR `about` LIKE '%s' OR `keywords` LIKE '%s') $extra_sql",
DBA::escape(NETWORK_DFRN), DBA::escape($ostatus), DBA::escape($diaspora),
DBA::escape(Protocol::DFRN), DBA::escape($ostatus), DBA::escape($diaspora),
DBA::escape(escape_tags($search2)), DBA::escape(escape_tags($search2)), DBA::escape(escape_tags($search2)),
DBA::escape(escape_tags($search2)), DBA::escape(escape_tags($search2)), DBA::escape(escape_tags($search2)));
@ -133,7 +134,7 @@ function dirfind_content(App $a, $prefix = "") {
`addr` LIKE '%s' OR `about` LIKE '%s' OR `keywords` LIKE '%s') $extra_sql
GROUP BY `nurl`
ORDER BY `updated` DESC LIMIT %d, %d",
DBA::escape(NETWORK_DFRN), DBA::escape($ostatus), DBA::escape($diaspora),
DBA::escape(Protocol::DFRN), DBA::escape($ostatus), DBA::escape($diaspora),
DBA::escape(escape_tags($search2)), DBA::escape(escape_tags($search2)), DBA::escape(escape_tags($search2)),
DBA::escape(escape_tags($search2)), DBA::escape(escape_tags($search2)), DBA::escape(escape_tags($search2)),
intval($startrec), intval($perpage));


+ 3
- 3
mod/display.php View File

@ -94,7 +94,7 @@ function display_init(App $a)
if (DBA::isResult($profile)) {
$profiledata = $profile;
}
$profiledata["network"] = NETWORK_DFRN;
$profiledata["network"] = Protocol::DFRN;
} else {
$profiledata = [];
}
@ -177,10 +177,10 @@ function display_fetchauthor($a, $item)
$profiledata["photo"] = System::removedBaseUrl($profiledata["photo"]);
if (local_user()) {
if (in_array($profiledata["network"], [NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS])) {
if (in_array($profiledata["network"], [Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS])) {
$profiledata["remoteconnect"] = System::baseUrl()."/follow?url=".urlencode($profiledata["url"]);
}
} elseif ($profiledata["network"] == NETWORK_DFRN) {
} elseif ($profiledata["network"] == Protocol::DFRN) {
$connect = str_replace("/profile/", "/dfrn_request/", $profiledata["url"]);
$profiledata["remoteconnect"] = $connect;
}


+ 3
- 2
mod/fetch.php View File

@ -5,6 +5,7 @@ This file is part of the Diaspora protocol. It is used for fetching single publi
use Friendica\App;
use Friendica\Core\L10n;
use Friendica\Core\Protocol;
use Friendica\Core\System;
use Friendica\Protocol\Diaspora;
use Friendica\Model\Item;
@ -25,10 +26,10 @@ function fetch_init(App $a)
// Fetch the item
$fields = ['uid', 'title', 'body', 'guid', 'contact-id', 'private', 'created', 'app', 'location', 'coord', 'network',
'event-id', 'resource-id', 'author-link', 'owner-link', 'attach'];
$condition = ['wall' => true, 'private' => false, 'guid' => $guid, 'network' => [NETWORK_DFRN, NETWORK_DIASPORA]];
$condition = ['wall' => true, 'private' => false, 'guid' => $guid, 'network' => [Protocol::DFRN, Protocol::DIASPORA]];
$item = Item::selectFirst($fields, $condition);
if (!DBA::isResult($item)) {
$condition = ['guid' => $guid, 'network' => [NETWORK_DFRN, NETWORK_DIASPORA]];
$condition = ['guid' => $guid, 'network' => [Protocol::DFRN, Protocol::DIASPORA]];
$item = Item::selectFirst(['author-link'], $condition);
if (DBA::isResult($item)) {
$parts = parse_url($item["author-link"]);


+ 9
- 8
mod/follow.php View File

@ -5,6 +5,7 @@
use Friendica\App;
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\Protocol;
use Friendica\Core\System;
use Friendica\Model\Contact;
use Friendica\Model\Profile;
@ -66,8 +67,8 @@ function follow_content(App $a)
$r = q("SELECT `pending` FROM `contact` WHERE `uid` = %d AND ((`rel` != %d) OR (`network` = '%s')) AND
(`nurl` = '%s' OR `alias` = '%s' OR `alias` = '%s') AND
`network` != '%s' LIMIT 1",
intval(local_user()), DBA::escape(Contact::FOLLOWER), DBA::escape(NETWORK_DFRN), DBA::escape(normalise_link($url)),
DBA::escape(normalise_link($url)), DBA::escape($url), DBA::escape(NETWORK_STATUSNET));
intval(local_user()), DBA::escape(Contact::FOLLOWER), DBA::escape(Protocol::DFRN), DBA::escape(normalise_link($url)),
DBA::escape(normalise_link($url)), DBA::escape($url), DBA::escape(Protocol::STATUSNET));
if ($r) {
if ($r[0]['pending']) {
@ -80,32 +81,32 @@ function follow_content(App $a)
$ret = Probe::uri($url);
if (($ret['network'] == NETWORK_DIASPORA) && !Config::get('system', 'diaspora_enabled')) {
if (($ret['network'] == Protocol::DIASPORA) && !Config::get('system', 'diaspora_enabled')) {
notice(L10n::t("Diaspora support isn't enabled. Contact can't be added."));
$submit = '';
//goaway($_SESSION['return_url']);
// NOTREACHED
}
if (($ret['network'] == NETWORK_OSTATUS) && Config::get('system', 'ostatus_disabled')) {
if (($ret['network'] == Protocol::OSTATUS) && Config::get('system', 'ostatus_disabled')) {
notice(L10n::t("OStatus support is disabled. Contact can't be added."));
$submit = '';
//goaway($_SESSION['return_url']);
// NOTREACHED
}
if ($ret['network'] == NETWORK_PHANTOM) {
if ($ret['network'] == Protocol::PHANTOM) {
notice(L10n::t("The network type couldn't be detected. Contact can't be added."));
$submit = '';
//goaway($_SESSION['return_url']);
// NOTREACHED
}
if ($ret['network'] == NETWORK_MAIL) {
if ($ret['network'] == Protocol::MAIL) {
$ret['url'] = $ret['addr'];
}
if (($ret['network'] === NETWORK_DFRN) && !DBA::isResult($r)) {
if (($ret['network'] === Protocol::DFRN) && !DBA::isResult($r)) {
$request = $ret['request'];
$tpl = get_markup_template('dfrn_request.tpl');
} else {
@ -136,7 +137,7 @@ function follow_content(App $a)
$gcontact_id = $r[0]['id'];
}
if ($ret['network'] === NETWORK_DIASPORA) {
if ($ret['network'] === Protocol::DIASPORA) {
$r[0]['location'] = '';
$r[0]['about'] = '';
}


+ 11
- 10
mod/item.php View File

@ -21,6 +21,7 @@ use Friendica\Content\Text\HTML;
use Friendica\Core\Addon;
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\Protocol;
use Friendica\Core\System;
use Friendica\Core\Worker;
use Friendica\Database\DBA;
@ -158,7 +159,7 @@ function item_post(App $a) {
}
// Allow commenting if it is an answer to a public post
$allow_comment = local_user() && ($profile_uid == 0) && $parent && in_array($parent_item['network'], [NETWORK_OSTATUS, NETWORK_DIASPORA, NETWORK_DFRN]);
$allow_comment = local_user() && ($profile_uid == 0) && $parent && in_array($parent_item['network'], [Protocol::OSTATUS, Protocol::DIASPORA, Protocol::DFRN]);
// Now check that valid personal details have been provided
if (!can_write_wall($profile_uid) && !$allow_comment) {
@ -238,7 +239,7 @@ function item_post(App $a) {
$verb = notags(trim(defaults($_REQUEST, 'verb' , '')));
$emailcc = notags(trim(defaults($_REQUEST, 'emailcc' , '')));
$body = escape_tags(trim(defaults($_REQUEST, 'body' , '')));
$network = notags(trim(defaults($_REQUEST, 'network' , NETWORK_DFRN)));
$network = notags(trim(defaults($_REQUEST, 'network' , Protocol::DFRN)));
$guid = System::createGUID(32);
$postopts = defaults($_REQUEST, 'postopts', '');
@ -253,8 +254,8 @@ function item_post(App $a) {
if ($parent_item) {
// for non native networks use the network of the original post as network of the item
if (($parent_item['network'] != NETWORK_DIASPORA)
&& ($parent_item['network'] != NETWORK_OSTATUS)
if (($parent_item['network'] != Protocol::DIASPORA)
&& ($parent_item['network'] != Protocol::OSTATUS)
&& ($network == "")) {
$network = $parent_item['network'];
}
@ -344,14 +345,14 @@ function item_post(App $a) {
// Add a tag if the parent contact is from OStatus (This will notify them during delivery)
if ($parent) {
if ($thr_parent_contact['network'] == NETWORK_OSTATUS) {
if ($thr_parent_contact['network'] == Protocol::OSTATUS) {
$contact = '@[url=' . $thr_parent_contact['url'] . ']' . $thr_parent_contact['nick'] . '[/url]';
if (!stripos(implode($tags), '[url=' . $thr_parent_contact['url'] . ']')) {
$tags[] = $contact;
}
}
if ($parent_contact['network'] == NETWORK_OSTATUS) {
if ($parent_contact['network'] == Protocol::OSTATUS) {
$contact = '@[url=' . $parent_contact['url'] . ']' . $parent_contact['nick'] . '[/url]';
if (!stripos(implode($tags), '[url=' . $parent_contact['url'] . ']')) {
$tags[] = $contact;
@ -559,7 +560,7 @@ function item_post(App $a) {
}
if ($network == "") {
$network = NETWORK_DFRN;
$network = Protocol::DFRN;
}
$gravity = ($parent ? GRAVITY_COMMENT : GRAVITY_PARENT);
@ -674,7 +675,7 @@ function item_post(App $a) {
// doesn't have an ID.
$datarray["id"] = -1;
$datarray["item_id"] = -1;
$datarray["author-network"] = NETWORK_DFRN;
$datarray["author-network"] = Protocol::DFRN;
$o = conversation($a,[array_merge($contact_record,$datarray)],'search', false, true);
logger('preview: ' . $o);
@ -1021,8 +1022,8 @@ function handle_tag(App $a, &$body, &$inform, &$str_tags, $profile_uid, $tag, $n
$alias = $contact["alias"];
$newname = $contact["nick"];
if (($newname == "") || (($contact["network"] != NETWORK_OSTATUS) && ($contact["network"] != NETWORK_TWITTER)
&& ($contact["network"] != NETWORK_STATUSNET))) {
if (($newname == "") || (($contact["network"] != Protocol::OSTATUS) && ($contact["network"] != Protocol::TWITTER)
&& ($contact["network"] != Protocol::STATUSNET))) {
$newname = $contact["name"];
}
}


+ 3
- 2
mod/network.php View File

@ -14,6 +14,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;
@ -664,7 +665,7 @@ function networkThreadedView(App $a, $update, $parent)
'id' => 'network',
]) . $o;
if ($contact['network'] === NETWORK_OSTATUS && $contact['writable'] && !PConfig::get(local_user(),'system','nowarn_insecure')) {
if ($contact['network'] === Protocol::OSTATUS && $contact['writable'] && !PConfig::get(local_user(),'system','nowarn_insecure')) {
notice(L10n::t('Private messages to this person are at risk of public disclosure.') . EOL);
}
} else {
@ -805,7 +806,7 @@ function networkThreadedView(App $a, $update, $parent)
}
// Only show it when unfiltered (no groups, no networks, ...)
if (in_array($nets, ['', NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS]) && (strlen($sql_extra . $sql_extra2 . $sql_extra3) == 0)) {
if (in_array($nets, ['', Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS]) && (strlen($sql_extra . $sql_extra2 . $sql_extra3) == 0)) {
if (DBA::isResult($r)) {
$top_limit = current($r)['order_date'];
$bottom_limit = end($r)['order_date'];


+ 4
- 3
mod/noscrape.php View File

@ -4,6 +4,7 @@
*/
use Friendica\App;
use Friendica\Core\Protocol;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\Model\Contact;
@ -62,9 +63,9 @@ function noscrape_init(App $a)
$r = q("SELECT COUNT(*) AS `total` FROM `contact` WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 and `pending` = 0 AND `hidden` = 0 AND `archive` = 0
AND `network` IN ('%s', '%s', '%s', '')",
intval($a->profile['uid']),
DBA::escape(NETWORK_DFRN),
DBA::escape(NETWORK_DIASPORA),
DBA::escape(NETWORK_OSTATUS)
DBA::escape(Protocol::DFRN),
DBA::escape(Protocol::DIASPORA),
DBA::escape(Protocol::OSTATUS)
);
if (DBA::isResult($r)) {
$json_info["contacts"] = intval($r[0]['total']);


+ 7
- 6
mod/notifications.php View File

@ -9,6 +9,7 @@ use Friendica\Content\ContactSelector;
use Friendica\Content\Nav;
use Friendica\Core\L10n;
use Friendica\Core\NotificationsManager;
use Friendica\Core\Protocol;
use Friendica\Core\System;
use Friendica\Database\DBA;
@ -181,8 +182,8 @@ function notifications_content(App $a)
// Normal connection requests
default:
$friend_selected = (($it['network'] !== NETWORK_OSTATUS) ? ' checked="checked" ' : ' disabled ');
$fan_selected = (($it['network'] === NETWORK_OSTATUS) ? ' checked="checked" disabled ' : '');
$friend_selected = (($it['network'] !== Protocol::OSTATUS) ? ' checked="checked" ' : ' disabled ');
$fan_selected = (($it['network'] === Protocol::OSTATUS) ? ' checked="checked" disabled ' : '');
$dfrn_tpl = get_markup_template('netfriend.tpl');
$knowyou = '';
@ -192,8 +193,8 @@ function notifications_content(App $a)
$helptext2 = '';
$helptext3 = '';
if ($it['network'] === NETWORK_DFRN || $it['network'] === NETWORK_DIASPORA) {
if ($it['network'] === NETWORK_DFRN) {
if ($it['network'] === Protocol::DFRN || $it['network'] === Protocol::DIASPORA) {
if ($it['network'] === Protocol::DFRN) {
$lbl_knowyou = L10n::t('Claims to be known to you: ');
$knowyou = (($it['knowyou']) ? L10n::t('yes') : L10n::t('no'));
$helptext = L10n::t('Shall your connection be bidirectional or not?');
@ -215,7 +216,7 @@ function notifications_content(App $a)
'$approve_as2' => $helptext2,
'$approve_as3' => $helptext3,
'$as_friend' => L10n::t('Friend'),
'$as_fan' => (($it['network'] == NETWORK_DIASPORA) ? L10n::t('Sharer') : L10n::t('Subscriber'))
'$as_fan' => (($it['network'] == Protocol::DIASPORA) ? L10n::t('Sharer') : L10n::t('Subscriber'))
]);
$header = $it["name"];
@ -226,7 +227,7 @@ function notifications_content(App $a)
$header .= " (".ContactSelector::networkToName($it['network'], $it['url']).")";
if ($it['network'] != NETWORK_DIASPORA) {
if ($it['network'] != Protocol::DIASPORA) {
$discard = L10n::t('Discard');
} else {
$discard = '';


+ 3
- 2
mod/ostatus_subscribe.php View File

@ -5,6 +5,7 @@
use Friendica\App;
use Friendica\Core\L10n;
use Friendica\Core\PConfig;
use Friendica\Core\Protocol;
use Friendica\Core\System;
use Friendica\Model\Contact;
use Friendica\Network\Probe;
@ -72,8 +73,8 @@ function ostatus_subscribe_content(App $a) {
$o .= "<p>".$counter."/".$total.": ".$url;
$data = Probe::uri($url);
if ($data["network"] == NETWORK_OSTATUS) {
$result = Contact::createFromProbe($uid, $url, true, NETWORK_OSTATUS);
if ($data["network"] == Protocol::OSTATUS) {
$result = Contact::createFromProbe($uid, $url, true, Protocol::OSTATUS);
if ($result["success"]) {
$o .= " - ".L10n::t("success");
} else {


+ 20
- 19
mod/poco.php View File

@ -8,6 +8,7 @@ use Friendica\App;
use Friendica\Content\Text\BBCode;
use Friendica\Core\Cache;
use Friendica\Core\Config;
use Friendica\Core\Protocol;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\Protocol\PortableContact;
@ -89,9 +90,9 @@ function poco_init(App $a) {
if ($global) {
$contacts = q("SELECT count(*) AS `total` FROM `gcontact` WHERE `updated` >= '%s' AND `updated` >= `last_failure` AND NOT `hide` AND `network` IN ('%s', '%s', '%s')",
DBA::escape($update_limit),
DBA::escape(NETWORK_DFRN),
DBA::escape(NETWORK_DIASPORA),
DBA::escape(NETWORK_OSTATUS)
DBA::escape(Protocol::DFRN),
DBA::escape(Protocol::DIASPORA),
DBA::escape(Protocol::OSTATUS)
);
} elseif ($system_mode) {
$contacts = q("SELECT count(*) AS `total` FROM `contact` WHERE `self` = 1
@ -101,10 +102,10 @@ function poco_init(App $a) {
AND (`success_update` >= `failure_update` OR `last-item` >= `failure_update`)
AND `network` IN ('%s', '%s', '%s', '%s') $sql_extra",
intval($user['uid']),
DBA::escape(NETWORK_DFRN),
DBA::escape(NETWORK_DIASPORA),
DBA::escape(NETWORK_OSTATUS),
DBA::escape(NETWORK_STATUSNET)
DBA::escape(Protocol::DFRN),
DBA::escape(Protocol::DIASPORA),
DBA::escape(Protocol::OSTATUS),
DBA::escape(Protocol::STATUSNET)
);
}
if (DBA::isResult($contacts)) {
@ -124,9 +125,9 @@ function poco_init(App $a) {
$contacts = q("SELECT * FROM `gcontact` WHERE `updated` > '%s' AND NOT `hide` AND `network` IN ('%s', '%s', '%s') AND `updated` > `last_failure`
ORDER BY `updated` DESC LIMIT %d, %d",
DBA::escape($update_limit),
DBA::escape(NETWORK_DFRN),
DBA::escape(NETWORK_DIASPORA),
DBA::escape(NETWORK_OSTATUS),
DBA::escape(Protocol::DFRN),
DBA::escape(Protocol::DIASPORA),
DBA::escape(Protocol::OSTATUS),
intval($startIndex),
intval($itemsPerPage)
);
@ -148,10 +149,10 @@ function poco_init(App $a) {
AND (`success_update` >= `failure_update` OR `last-item` >= `failure_update`)
AND `network` IN ('%s', '%s', '%s', '%s') $sql_extra LIMIT %d, %d",
intval($user['uid']),
DBA::escape(NETWORK_DFRN),
DBA::escape(NETWORK_DIASPORA),
DBA::escape(NETWORK_OSTATUS),
DBA::escape(NETWORK_STATUSNET),
DBA::escape(Protocol::DFRN),
DBA::escape(Protocol::DIASPORA),
DBA::escape(Protocol::OSTATUS),
DBA::escape(Protocol::STATUSNET),
intval($startIndex),
intval($itemsPerPage)
);
@ -257,7 +258,7 @@ function poco_init(App $a) {
}
// Non connected persons can only see the keywords of a Diaspora account
if ($contact['network'] == NETWORK_DIASPORA) {
if ($contact['network'] == Protocol::DIASPORA) {
$contact['location'] = "";
$about = "";
$contact['gender'] = "";
@ -284,7 +285,7 @@ function poco_init(App $a) {
}
if ($fields_ret['urls']) {
$entry['urls'] = [['value' => $contact['url'], 'type' => 'profile']];
if ($contact['addr'] && ($contact['network'] !== NETWORK_MAIL)) {
if ($contact['addr'] && ($contact['network'] !== Protocol::MAIL)) {
$entry['urls'][] = ['value' => 'acct:' . $contact['addr'], 'type' => 'webfinger'];
}
}
@ -314,11 +315,11 @@ function poco_init(App $a) {
}
if ($fields_ret['network']) {
$entry['network'] = $contact['network'];
if ($entry['network'] == NETWORK_STATUSNET) {
$entry['network'] = NETWORK_OSTATUS;
if ($entry['network'] == Protocol::STATUSNET) {
$entry['network'] = Protocol::OSTATUS;
}
if (($entry['network'] == "") && ($contact['self'])) {
$entry['network'] = NETWORK_DFRN;
$entry['network'] = Protocol::DFRN;
}
}
if ($fields_ret['tags']) {


+ 8
- 5
mod/profperm.php View File

@ -6,6 +6,7 @@ use Friendica\App;
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\PConfig;
use Friendica\Core\Protocol;
use Friendica\Database\DBA;
use Friendica\Model\Profile;
@ -30,7 +31,7 @@ function profperm_content(App $a) {
}
if($a->argc < 2) {
if ($a->argc < 2) {
notice(L10n::t('Invalid profile identifier.') . EOL );
return;
}
@ -47,16 +48,18 @@ function profperm_content(App $a) {
if(($a->argc > 2) && intval($a->argv[1]) && intval($a->argv[2])) {
$r = q("SELECT `id` FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `self` = 0
AND `network` = '%s' AND `id` = %d AND `uid` = %d LIMIT 1",
DBA::escape(NETWORK_DFRN),
DBA::escape(Protocol::DFRN),
intval($a->argv[2]),
intval(local_user())
);
if (DBA::isResult($r))
if (DBA::isResult($r)) {
$change = intval($a->argv[2]);
}
}
if(($a->argc > 1) && (intval($a->argv[1]))) {
if (($a->argc > 1) && (intval($a->argv[1]))) {
$r = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d AND `is-default` = 0 LIMIT 1",
intval($a->argv[1]),
intval(local_user())
@ -144,7 +147,7 @@ function profperm_content(App $a) {
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `blocked` = 0 and `pending` = 0 and `self` = 0
AND `network` = '%s' ORDER BY `name` ASC",
intval(local_user()),
DBA::escape(NETWORK_DFRN)
DBA::escape(Protocol::DFRN)
);
if (DBA::isResult($r)) {


+ 4
- 3
mod/pubsub.php View File

@ -1,6 +1,7 @@
<?php
use Friendica\App;
use Friendica\Core\Protocol;
use Friendica\Database\DBA;
use Friendica\Model\Contact;
use Friendica\Protocol\OStatus;
@ -114,14 +115,14 @@ function pubsub_post(App $a)
}
}
if (!in_array($contact['rel'], [Contact::SHARING, Contact::FRIEND]) && ($contact['network'] != NETWORK_FEED)) {
if (!in_array($contact['rel'], [Contact::SHARING, Contact::FRIEND]) && ($contact['network'] != Protocol::FEED)) {
logger('Contact ' . $contact['id'] . ' is not expected to share with us - ignored.');
hub_post_return();
}
// We import feeds from OStatus, Friendica and ATOM/RSS.
/// @todo Check if Friendica posts really arrive here - otherwise we can discard some stuff
if (!in_array($contact['network'], [NETWORK_OSTATUS, NETWORK_DFRN, NETWORK_FEED])) {
if (!in_array($contact['network'], [Protocol::OSTATUS, Protocol::DFRN, Protocol::FEED])) {
hub_post_return();
}