]> git.mxchange.org Git - friendica.git/commitdiff
Stopped using deprecated constants NETWORK_* (#5537)
authorRoland Häder <Quix0r@users.noreply.github.com>
Sat, 11 Aug 2018 20:40:44 +0000 (22:40 +0200)
committerHypolite Petovan <mrpetovan@eml.cc>
Sat, 11 Aug 2018 20:40:44 +0000 (22:40 +0200)
* 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.

59 files changed:
boot.php
include/api.php
include/conversation.php
include/items.php
include/text.php
mod/acl.php
mod/contacts.php
mod/crepair.php
mod/delegate.php
mod/dfrn_confirm.php
mod/dfrn_request.php
mod/dirfind.php
mod/display.php
mod/fetch.php
mod/follow.php
mod/item.php
mod/network.php
mod/noscrape.php
mod/notifications.php
mod/ostatus_subscribe.php
mod/poco.php
mod/profperm.php
mod/pubsub.php
mod/redir.php
mod/repair_ostatus.php
mod/salmon.php
mod/unfollow.php
mod/viewcontacts.php
src/Content/ContactSelector.php
src/Content/Widget.php
src/Core/ACL.php
src/Core/NotificationsManager.php
src/Core/UserImport.php
src/Database/PostUpdate.php
src/Model/Contact.php
src/Model/Conversation.php
src/Model/GContact.php
src/Model/Item.php
src/Model/ItemContent.php
src/Model/Profile.php
src/Model/User.php
src/Network/Probe.php
src/Object/Post.php
src/Object/Thread.php
src/Protocol/DFRN.php
src/Protocol/Diaspora.php
src/Protocol/Email.php
src/Protocol/Feed.php
src/Protocol/OStatus.php
src/Protocol/PortableContact.php
src/Worker/Cron.php
src/Worker/CronJobs.php
src/Worker/Delivery.php
src/Worker/DiscoverPoCo.php
src/Worker/GProbe.php
src/Worker/Notifier.php
src/Worker/OnePoll.php
src/Worker/Queue.php
src/Worker/UpdateGContact.php

index ebdb58236b2d9fd968eb3f4e5ec4243eda811ff3..9b18361b0606450f7cc3f9700cabbef98a2aa9b8 100644 (file)
--- a/boot.php
+++ b/boot.php
@@ -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),
 ];
 
 /**
index 4fbbc37779ecf0f5d177268e62ec98f1c521194e..9fe3cb4bd7bbf525c97d467572b4e461287aca7d 100644 (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");
        }
 
index 6aaf67a6eb3d9314538799816fcbe95718dd9332..3ceccf36ae1141eb6eae9fd0796658aa87adabc0 100644 (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 {
index 34d6132f018b38146328aff3f61c7fe26e89a26d..7045a2953a58911237128dc9f3919ed27f7a3dec 100644 (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;
        }
 
index 7c86326435cd04733b0877b617e637bc93aa8ba9..a9a11f76f2a8aae0d51a1b484ad31d83990d3589 100644 (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']);
                        }
index 29e53394b5ef3cb87e07d3c61f723cbf9ad80b06..f9589598dda5b1ef0a5b4715a814c2c5cee68df9 100644 (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`
index c5a43d4f2c2fbf26337e404b58e0cd60d14e5b09..9800dbdc1acba3911598daf18142c73f4cab47a6 100644 (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'],
index 309a356d5393e6638415943468e9a6e4f18ec1f9..37956421f52bdaa69a1cca9f94f7f42c171ab96f 100644 (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);
 
index d0fd78cecc879e71d42b41b6bb75d0c6d9f86949..ed4f854377109c6c4466487ec6ab9f34eedb0eff 100644 (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 = [];
index d8d74298669b0e8a84890015bfc7426f47703a51..e2fbf1cdbec79dbf1d06423d8266012fc42c3b29 100644 (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
index 484599f6fc51e2b9807b988b3c73189d58d91f01..25fe69066fb3d51619c2de82353b927b9951e786 100644 (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;
index 2d728f8e730f0bb4e309d783c8899ae8588260fc..fd31b2cbf1260a3f24f1da704602e67964d171a5 100644 (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));
index d57b151bcf9b587077b4b1c27345178ff2c9e331..c30e2262630f6412835c63e899d6783de9b8e6e2 100644 (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;
        }
index 36f9eef701d82e4d6b375bc5ceb0feaf368a2075..35455e2822dc95c7e703af229bb0db7ffd29eb66 100644 (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"]);
index 15a5b2f40170d6fc76b8bb3e99849a6095daed0a..ef2325ad03d3d7ae0a599297ca525373f08057a1 100644 (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'] = '';
        }
index 685a16143de812ea229686e40ea4fc4fd8997b3e..125606d2778697a2d9e36383cf1eb84616f00f15 100644 (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"];
                        }
                }
index 4609674fc49fc2b09446a5706f51c904d3a1195e..49f9c7cb1b00b5afe5b57f58dd4d9108ca4b1aaf 100644 (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'];
index a948bee4f38807530c25610bd007843899f0ce09..3a8abe2290928e62c40eeb0cda12a389c042af21 100644 (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']);
index e906f9385188e6ba6a69bd616f7319aa4c70ae3a..52521b017a43cf7a02e41c2bd71432052b711eeb 100644 (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 = '';
index e8ba144a1633a7b2e5d30d4a35ffb502096eab73..987f31699e588539727d545a6f113ba967399d29 100644 (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 {
index a2f038d08cfdad85f099184a0bbcf4f3d17e940c..a16495326009eed93b10ac60968a874e541d7ffa 100644 (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']) {
index 6ad922b594266a4847d94ac2d5a5898feef18633..4ee933e6cbecea30c696b37722aefdaa42f20aae 100644 (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)) {
index ef97bb7f7f625fbfef87d3355bd719b9c4ce11e7..bc284a4eb2f92e531bb926e53730b284672ffb8a 100644 (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();
        }
 
@@ -130,7 +131,7 @@ function pubsub_post(App $a)
        consume_feed($xml, $importer, $contact, $feedhub);
 
        // do it a second time for DFRN so that any children find their parents.
-       if ($contact['network'] === NETWORK_DFRN) {
+       if ($contact['network'] === Protocol::DFRN) {
                consume_feed($xml, $importer, $contact, $feedhub);
        }
 
index 0272ff1c87d001bc3dd3b6720455377e27acbd9b..727b70d660b17242b269327ddc8a803ea87ab8ee 100644 (file)
@@ -2,6 +2,7 @@
 
 use Friendica\App;
 use Friendica\Core\L10n;
+use Friendica\Core\Protocol;
 use Friendica\Core\System;
 use Friendica\Database\DBA;
 use Friendica\Model\Contact;
@@ -31,7 +32,7 @@ function redir_init(App $a) {
 
                $contact_url = $contact['url'];
 
-               if ($contact['network'] !== NETWORK_DFRN // Authentication isn't supported for non DFRN contacts.
+               if ($contact['network'] !== Protocol::DFRN // Authentication isn't supported for non DFRN contacts.
                        || (!local_user() && !remote_user()) // Visitors (not logged in or not remotes) can't authenticate.
                        || (!empty($a->contact['id']) && $a->contact['id'] == $cid)) // Local user is already authenticated.
                {
index 7531ad35c23e811af063df354f239d48ad579b5f..a1695127e6732b2466aab301a7d5bf0ba9b161ca 100644 (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\Contact;
@@ -28,7 +29,7 @@ function repair_ostatus_content(App $a) {
         $r = q("SELECT COUNT(*) AS `total` FROM `contact` WHERE
                 `uid` = %d AND `network` = '%s' AND `rel` IN (%d, %d)",
                 intval($uid),
-                DBA::escape(NETWORK_OSTATUS),
+                DBA::escape(Protocol::OSTATUS),
                 intval(Contact::FRIEND),
                 intval(Contact::SHARING));
 
@@ -42,7 +43,7 @@ function repair_ostatus_content(App $a) {
                ORDER BY `url`
                LIMIT %d, 1",
                 intval($uid),
-                DBA::escape(NETWORK_OSTATUS),
+                DBA::escape(Protocol::OSTATUS),
                 intval(Contact::FRIEND),
                 intval(Contact::SHARING), $counter++);
 
index d1f9cf9a31e6934e4f7440c81b9cf89f26f9c9ca..8bdfdefeee1663ba2d9c72bd3644f7848787dda0 100644 (file)
@@ -4,6 +4,7 @@
  */
 use Friendica\App;
 use Friendica\Core\PConfig;
+use Friendica\Core\Protocol;
 use Friendica\Core\System;
 use Friendica\Database\DBA;
 use Friendica\Model\Contact;
@@ -145,8 +146,8 @@ function salmon_post(App $a, $xml = '') {
        $r = q("SELECT * FROM `contact` WHERE `network` IN ('%s', '%s')
                                                AND (`nurl` = '%s' OR `alias` = '%s' OR `alias` = '%s')
                                                AND `uid` = %d LIMIT 1",
-               DBA::escape(NETWORK_OSTATUS),
-               DBA::escape(NETWORK_DFRN),
+               DBA::escape(Protocol::OSTATUS),
+               DBA::escape(Protocol::DFRN),
                DBA::escape(normalise_link($author_link)),
                DBA::escape($author_link),
                DBA::escape(normalise_link($author_link)),
@@ -159,7 +160,7 @@ function salmon_post(App $a, $xml = '') {
                        if($result['success']) {
                                $r = q("SELECT * FROM `contact` WHERE `network` = '%s' AND ( `url` = '%s' OR `alias` = '%s')
                                        AND `uid` = %d LIMIT 1",
-                                       DBA::escape(NETWORK_OSTATUS),
+                                       DBA::escape(Protocol::OSTATUS),
                                        DBA::escape($author_link),
                                        DBA::escape($author_link),
                                        intval($importer['uid'])
index f4e4316d6a09b0d729394caa1c89cc33ce508dda..5c00726e272bfb7224d577ce740eea9ae576217a 100644 (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\Contact;
@@ -28,13 +29,13 @@ function unfollow_post(App $a)
 
        $condition = ["`uid` = ? AND `rel` = ? AND (`nurl` = ? OR `alias` = ? OR `alias` = ?) AND `network` != ?",
                        $uid, Contact::FRIEND, normalise_link($url),
-                       normalise_link($url), $url, NETWORK_STATUSNET];
+                       normalise_link($url), $url, Protocol::STATUSNET];
        $contact = DBA::selectFirst('contact', [], $condition);
 
        if (!DBA::isResult($contact)) {
                notice(L10n::t("Contact wasn't found or can't be unfollowed."));
        } else {
-               if (in_array($contact['network'], [NETWORK_OSTATUS, NETWORK_DIASPORA, NETWORK_DFRN])) {
+               if (in_array($contact['network'], [Protocol::OSTATUS, Protocol::DIASPORA, Protocol::DFRN])) {
                        $r = q("SELECT `contact`.*, `user`.* FROM `contact` INNER JOIN `user` ON `contact`.`uid` = `user`.`uid`
                                WHERE `user`.`uid` = %d AND `contact`.`self` LIMIT 1",
                                intval($uid)
@@ -67,7 +68,8 @@ function unfollow_content(App $a)
 
        $condition = ["`uid` = ? AND `rel` = ? AND (`nurl` = ? OR `alias` = ? OR `alias` = ?) AND `network` != ?",
                        local_user(), Contact::FRIEND, normalise_link($url),
-                       normalise_link($url), $url, NETWORK_STATUSNET];
+                       normalise_link($url), $url, Protocol::STATUSNET];
+
        $contact = DBA::selectFirst('contact', ['url', 'network', 'addr', 'name'], $condition);
 
        if (!DBA::isResult($contact)) {
@@ -76,7 +78,7 @@ function unfollow_content(App $a)
                // NOTREACHED
        }
 
-       if (!in_array($contact['network'], [NETWORK_DIASPORA, NETWORK_OSTATUS, NETWORK_DFRN])) {
+       if (!in_array($contact['network'], [Protocol::DIASPORA, Protocol::OSTATUS, Protocol::DFRN])) {
                notice(L10n::t("Unfollowing is currently not supported by your network.").EOL);
                $submit = "";
                // NOTREACHED
index 3b3579ce7611bf775b142422ae8f6c2a4878413a..9219f49d9bfaa18fe5312b0b0c2c90bc43907e58 100644 (file)
@@ -7,6 +7,7 @@ use Friendica\Content\ContactSelector;
 use Friendica\Content\Nav;
 use Friendica\Core\Config;
 use Friendica\Core\L10n;
+use Friendica\Core\Protocol;
 use Friendica\Database\DBA;
 use Friendica\Model\Contact;
 use Friendica\Model\Profile;
@@ -65,9 +66,9 @@ function viewcontacts_content(App $a)
                        AND NOT `hidden` AND NOT `archive`
                        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)) {
                $a->set_pager_total($r[0]['total']);
@@ -79,9 +80,9 @@ function viewcontacts_content(App $a)
                        AND `network` IN ('%s', '%s', '%s')
                ORDER BY `name` ASC LIMIT %d, %d",
                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),
                intval($a->pager['start']),
                intval($a->pager['itemspage'])
        );
index 07eeda4234683abad41d966624cc13e3af81bbd7..d5efecb8060d420564ea2020417fd70cb5432ed8 100644 (file)
@@ -6,6 +6,7 @@ namespace Friendica\Content;
 
 use Friendica\Core\Addon;
 use Friendica\Core\L10n;
+use Friendica\Core\Protocol;
 use Friendica\Database\DBA;
 
 /**
@@ -74,21 +75,21 @@ class ContactSelector
        public static function networkToName($s, $profile = "")
        {
                $nets = [
-                       NETWORK_DFRN     => L10n::t('Friendica'),
-                       NETWORK_OSTATUS  => L10n::t('OStatus'),
-                       NETWORK_FEED     => L10n::t('RSS/Atom'),
-                       NETWORK_MAIL     => L10n::t('Email'),
-                       NETWORK_DIASPORA => L10n::t('Diaspora'),
-                       NETWORK_ZOT      => L10n::t('Zot!'),
-                       NETWORK_LINKEDIN => L10n::t('LinkedIn'),
-                       NETWORK_XMPP     => L10n::t('XMPP/IM'),
-                       NETWORK_MYSPACE  => L10n::t('MySpace'),
-                       NETWORK_GPLUS    => L10n::t('Google+'),
-                       NETWORK_PUMPIO   => L10n::t('pump.io'),
-                       NETWORK_TWITTER  => L10n::t('Twitter'),
-                       NETWORK_DIASPORA2 => L10n::t('Diaspora Connector'),
-                       NETWORK_STATUSNET => L10n::t('GNU Social Connector'),
-                       NETWORK_PNUT      => L10n::t('pnut')
+                       Protocol::DFRN      => L10n::t('Friendica'),
+                       Protocol::OSTATUS   => L10n::t('OStatus'),
+                       Protocol::FEED      => L10n::t('RSS/Atom'),
+                       Protocol::MAIL      => L10n::t('Email'),
+                       Protocol::DIASPORA  => L10n::t('Diaspora'),
+                       Protocol::ZOT       => L10n::t('Zot!'),
+                       Protocol::LINKEDIN  => L10n::t('LinkedIn'),
+                       Protocol::XMPP      => L10n::t('XMPP/IM'),
+                       Protocol::MYSPACE   => L10n::t('MySpace'),
+                       Protocol::GPLUS     => L10n::t('Google+'),
+                       Protocol::PUMPIO    => L10n::t('pump.io'),
+                       Protocol::TWITTER   => L10n::t('Twitter'),
+                       Protocol::DIASPORA2 => L10n::t('Diaspora Connector'),
+                       Protocol::STATUSNET => L10n::t('GNU Social Connector'),
+                       Protocol::PNUT      => L10n::t('pnut'),
                ];
 
                Addon::callHooks('network_to_name', $nets);
@@ -98,7 +99,7 @@ class ContactSelector
 
                $networkname = str_replace($search, $replace, $s);
 
-               if ((in_array($s, [NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS])) && ($profile != "")) {
+               if ((in_array($s, [Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS])) && ($profile != "")) {
                        $r = DBA::fetchFirst("SELECT `gserver`.`platform` FROM `gcontact`
                                        INNER JOIN `gserver` ON `gserver`.`nurl` = `gcontact`.`server_url`
                                        WHERE `gcontact`.`nurl` = ? AND `platform` != ''", normalise_link($profile));
index a46ccc62eb75a233b0c31b9a7815e0341dca6ab2..9662e9271864051e16dfa542dffb2dbe559ff6ea 100644 (file)
@@ -10,6 +10,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;
@@ -83,27 +84,27 @@ class Widget
                $networks = ['face', 'apdn'];
 
                if (!Addon::isEnabled("statusnet")) {
-                       $networks[] = NETWORK_STATUSNET;
+                       $networks[] = Protocol::STATUSNET;
                }
 
                if (!Addon::isEnabled("pumpio")) {
-                       $networks[] = NETWORK_PUMPIO;
+                       $networks[] = Protocol::PUMPIO;
                }
 
                if (!Addon::isEnabled("twitter")) {
-                       $networks[] = NETWORK_TWITTER;
+                       $networks[] = Protocol::TWITTER;
                }
 
                if (Config::get("system", "ostatus_disabled")) {
-                       $networks[] = NETWORK_OSTATUS;
+                       $networks[] = Protocol::OSTATUS;
                }
 
                if (!Config::get("system", "diaspora_enabled")) {
-                       $networks[] = NETWORK_DIASPORA;
+                       $networks[] = Protocol::DIASPORA;
                }
 
                if (!Addon::isEnabled("pnut")) {
-                       $networks[] = NETWORK_PNUT;
+                       $networks[] = Protocol::PNUT;
                }
 
                if (!sizeof($networks)) {
index 11af99af660a2c69b110b7a488aa2c5e22bc3811..0b996bfe9b6a3fea4817b3f4a6e469956643efe8 100644 (file)
@@ -8,6 +8,7 @@ namespace Friendica\Core;
 
 use Friendica\BaseObject;
 use Friendica\Content\Feature;
+use Friendica\Core\Protocol;
 use Friendica\Database\DBA;
 use Friendica\Model\Contact;
 use Friendica\Model\GContact;
@@ -46,18 +47,21 @@ class ACL extends BaseObject
 
                switch (defaults($options, 'networks', Protocol::PHANTOM)) {
                        case 'DFRN_ONLY':
-                               $networks = [NETWORK_DFRN];
+                               $networks = [Protocol::DFRN];
                                break;
+
                        case 'PRIVATE':
-                               $networks = [NETWORK_DFRN, NETWORK_MAIL, NETWORK_DIASPORA];
+                               $networks = [Protocol::DFRN, Protocol::MAIL, Protocol::DIASPORA];
                                break;
+
                        case 'TWO_WAY':
                                if (!empty($a->user['prvnets'])) {
-                                       $networks = [NETWORK_DFRN, NETWORK_MAIL, NETWORK_DIASPORA];
+                                       $networks = [Protocol::DFRN, Protocol::MAIL, Protocol::DIASPORA];
                                } else {
-                                       $networks = [NETWORK_DFRN, NETWORK_MAIL, NETWORK_DIASPORA, NETWORK_OSTATUS];
+                                       $networks = [Protocol::DFRN, Protocol::MAIL, Protocol::DIASPORA, Protocol::OSTATUS];
                                }
                                break;
+
                        default: /// @TODO Maybe log this call?
                                break;
                }
@@ -148,7 +152,7 @@ class ACL extends BaseObject
                // When used for private messages, we limit correspondence to mutual DFRN/Friendica friends and the selector
                // to one recipient. By default our selector allows multiple selects amongst all contacts.
                $sql_extra = sprintf(" AND `rel` = %d ", intval(Contact::FRIEND));
-               $sql_extra .= sprintf(" AND `network` IN ('%s' , '%s') ", NETWORK_DFRN, NETWORK_DIASPORA);
+               $sql_extra .= sprintf(" AND `network` IN ('%s' , '%s') ", Protocol::DFRN, Protocol::DIASPORA);
 
                $tabindex_attr = !empty($tabindex) ? ' tabindex="' . intval($tabindex) . '"' : '';
 
index 55effc14a4a044f55f67ffc10493660ebbb22b80..734e4eb03095acfa3c8bd2e477444275fc8b2d07 100644 (file)
@@ -9,6 +9,7 @@ namespace Friendica\Core;
 use Friendica\BaseObject;
 use Friendica\Content\Text\BBCode;
 use Friendica\Content\Text\HTML;
+use Friendica\Core\Protocol;
 use Friendica\Database\DBA;
 use Friendica\Model\Contact;
 use Friendica\Model\Item;
@@ -235,7 +236,7 @@ class NotificationsManager extends BaseObject
                                }
 
                                // For feed items we use the user's contact, since the avatar is mostly self choosen.
-                               if (!empty($it['network']) && $it['network'] == NETWORK_FEED) {
+                               if (!empty($it['network']) && $it['network'] == Protocol::FEED) {
                                        $it['author-avatar'] = $it['contact-avatar'];
                                }
 
@@ -639,14 +640,14 @@ class NotificationsManager extends BaseObject
                                $it = $this->getMissingIntroData($it);
 
                                // Don't show these data until you are connected. Diaspora is doing the same.
-                               if ($it['gnetwork'] === NETWORK_DIASPORA) {
+                               if ($it['gnetwork'] === Protocol::DIASPORA) {
                                        $it['glocation'] = "";
                                        $it['gabout'] = "";
                                        $it['ggender'] = "";
                                }
                                $intro = [
-                                       'label' => (($it['network'] !== NETWORK_OSTATUS) ? 'friend_request' : 'follower'),
-                                       'notify_type' => (($it['network'] !== NETWORK_OSTATUS) ? L10n::t('Friend/Connect Request') : L10n::t('New Follower')),
+                                       'label' => (($it['network'] !== Protocol::OSTATUS) ? 'friend_request' : 'follower'),
+                                       'notify_type' => (($it['network'] !== Protocol::OSTATUS) ? L10n::t('Friend/Connect Request') : L10n::t('New Follower')),
                                        'dfrn_id' => $it['issued-id'],
                                        'uid' => $_SESSION['uid'],
                                        'intro_id' => $it['intro_id'],
index efd4bd2f8fea963872d79b467118be380903d7d1..e62084049e3240baed70bd218babf683686f048f 100644 (file)
@@ -5,6 +5,7 @@
 namespace Friendica\Core;
 
 use Friendica\App;
+use Friendica\Core\Protocol;
 use Friendica\Database\DBA;
 use Friendica\Model\Photo;
 use Friendica\Object\Image;
@@ -182,12 +183,12 @@ class UserImport
                                $contact["avatar-date"] = NULL_DATE;
 
                                switch ($contact['network']) {
-                                       case NETWORK_DFRN:
-                                       case NETWORK_DIASPORA:
+                                       case Protocol::DFRN:
+                                       case Protocol::DIASPORA:
                                                //  send relocate message (below)
                                                break;
-                                       case NETWORK_FEED:
-                                       case NETWORK_MAIL:
+                                       case Protocol::FEED:
+                                       case Protocol::MAIL:
                                                // Nothing to do
                                                break;
                                        default:
index b7c69668e066012c21542cd03b5ad8fdfc4b533d..09e940b149d1ae9f45e92b4bd9e12b49aba11327 100644 (file)
@@ -5,6 +5,7 @@
 namespace Friendica\Database;
 
 use Friendica\Core\Config;
+use Friendica\Core\Protocol;
 use Friendica\Model\Contact;
 use Friendica\Model\Item;
 use Friendica\Model\ItemURI;
@@ -81,7 +82,7 @@ class PostUpdate
 
                $r = q($query1.$query2.$query3."  ORDER BY `item`.`id` LIMIT 1",
                        intval($start_id), intval($end_id),
-                       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 (!$r) {
                        Config::set("system", "post_update_version", 1194);
                        logger("Update is done", LOGGER_DEBUG);
@@ -95,7 +96,7 @@ class PostUpdate
 
                $r = q($query1.$query2.$query3."  ORDER BY `item`.`id` LIMIT 1000,1",
                        intval($start_id), intval($end_id),
-                       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 ($r) {
                        $pos_id = $r[0]["id"];
                } else {
@@ -105,7 +106,7 @@ class PostUpdate
 
                q("UPDATE `item` ".$query2." SET `item`.`global` = 1 ".$query3,
                        intval($start_id), intval($pos_id),
-                       DBA::escape(NETWORK_DFRN), DBA::escape(NETWORK_DIASPORA), DBA::escape(NETWORK_OSTATUS));
+                       DBA::escape(Protocol::DFRN), DBA::escape(Protocol::DIASPORA), DBA::escape(Protocol::OSTATUS));
 
                logger("Done", LOGGER_DEBUG);
        }
index 095bad37cda5703b9269577892a771e268ebebce..39a0ba718a8cd0b2d78c78a38e5dbbae9515f0e1 100644 (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'];
                }
 
index cb32c0f20eafa6043d714a88b913bdb07154497c..29ec4771d60a20a4abe6e2d3657c0dba1ea2dc61 100644 (file)
@@ -5,6 +5,7 @@
 
 namespace Friendica\Model;
 
+use Friendica\Core\Protocol;
 use Friendica\Database\DBA;
 use Friendica\Util\DateTimeFormat;
 
@@ -32,8 +33,8 @@ class Conversation
         */
        public static function insert(array $arr)
        {
-               if (in_array(defaults($arr, 'network', NETWORK_PHANTOM),
-                               [NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS, NETWORK_TWITTER]) && !empty($arr['uri'])) {
+               if (in_array(defaults($arr, 'network', Protocol::PHANTOM),
+                               [Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS, Protocol::TWITTER]) && !empty($arr['uri'])) {
                        $conversation = ['item-uri' => $arr['uri'], 'received' => DateTimeFormat::utcNow()];
 
                        if (isset($arr['parent-uri']) && ($arr['parent-uri'] != $arr['uri'])) {
index 94a2c11409448eb2bf0c28b412908c9a2f50c30d..eb93c55ce6498a88e4b1219f9be0eada23540ea5 100644 (file)
@@ -8,6 +8,7 @@ namespace Friendica\Model;
 
 use Exception;
 use Friendica\Core\Config;
+use Friendica\Core\Protocol;
 use Friendica\Core\System;
 use Friendica\Core\Worker;
 use Friendica\Database\DBA;
@@ -39,15 +40,15 @@ class GContact
 
                // check supported networks
                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;
                }
 
                // check if we search only communities or every contact
@@ -64,7 +65,7 @@ class GContact
                                ((`last_contact` >= `last_failure`) OR (`updated` >= `last_failure`)) AND
                                (`addr` LIKE ? OR `name` LIKE ? OR `nick` LIKE ?) $extra_sql
                                GROUP BY `nurl` ORDER BY `nurl` DESC LIMIT 1000",
-                       NETWORK_DFRN, $ostatus, $diaspora, $search, $search, $search
+                       Protocol::DFRN, $ostatus, $diaspora, $search, $search, $search
                );
 
                $gcontacts = [];
@@ -156,13 +157,13 @@ class GContact
                }
 
                // Don't store the statusnet connector as network
-               // We can't simply set this to NETWORK_OSTATUS since the connector could have fetched posts from friendica as well
-               if ($gcontact['network'] == NETWORK_STATUSNET) {
+               // We can't simply set this to Protocol::OSTATUS since the connector could have fetched posts from friendica as well
+               if ($gcontact['network'] == Protocol::STATUSNET) {
                        $gcontact['network'] = "";
                }
 
                // Assure that there are no parameter fragments in the profile url
-               if (in_array($gcontact['network'], [NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS, ""])) {
+               if (in_array($gcontact['network'], [Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS, ""])) {
                        $gcontact['url'] = self::cleanContactUrl($gcontact['url']);
                }
 
@@ -177,18 +178,18 @@ class GContact
                        $r = q(
                                "SELECT `network` FROM `contact` WHERE `uid` = 0 AND `nurl` = '%s' AND `network` != '' AND `network` != '%s' LIMIT 1",
                                DBA::escape(normalise_link($gcontact['url'])),
-                               DBA::escape(NETWORK_STATUSNET)
+                               DBA::escape(Protocol::STATUSNET)
                        );
                        if (DBA::isResult($r)) {
                                $gcontact['network'] = $r[0]["network"];
                        }
 
-                       if (($gcontact['network'] == "") || ($gcontact['network'] == NETWORK_OSTATUS)) {
+                       if (($gcontact['network'] == "") || ($gcontact['network'] == Protocol::OSTATUS)) {
                                $r = q(
                                        "SELECT `network`, `url` FROM `contact` WHERE `uid` = 0 AND `alias` IN ('%s', '%s') AND `network` != '' AND `network` != '%s' LIMIT 1",
                                        DBA::escape($gcontact['url']),
                                        DBA::escape(normalise_link($gcontact['url'])),
-                                       DBA::escape(NETWORK_STATUSNET)
+                                       DBA::escape(Protocol::STATUSNET)
                                );
                                if (DBA::isResult($r)) {
                                        $gcontact['network'] = $r[0]["network"];
@@ -205,7 +206,7 @@ class GContact
                );
 
                if (DBA::isResult($x)) {
-                       if (!isset($gcontact['network']) && ($x[0]["network"] != NETWORK_STATUSNET)) {
+                       if (!isset($gcontact['network']) && ($x[0]["network"] != Protocol::STATUSNET)) {
                                $gcontact['network'] = $x[0]["network"];
                        }
                        if ($gcontact['updated'] <= NULL_DATE) {
@@ -224,7 +225,7 @@ class GContact
                ) {
                        $data = Probe::uri($gcontact['url']);
 
-                       if ($data["network"] == NETWORK_PHANTOM) {
+                       if ($data["network"] == Protocol::PHANTOM) {
                                throw new Exception('Probing for URL '.$gcontact['url'].' failed');
                        }
 
@@ -234,7 +235,7 @@ class GContact
 
                        $gcontact = array_merge($gcontact, $data);
 
-                       if ($alternate && ($gcontact['network'] == NETWORK_OSTATUS)) {
+                       if ($alternate && ($gcontact['network'] == Protocol::OSTATUS)) {
                                // Delete the old entry - if it exists
                                if (DBA::exists('gcontact', ['nurl' => normalise_link($orig_profile)])) {
                                        DBA::delete('gcontact', ['nurl' => normalise_link($orig_profile)]);
@@ -246,7 +247,7 @@ class GContact
                        throw new Exception('No name and photo for URL '.$gcontact['url']);
                }
 
-               if (!in_array($gcontact['network'], [NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_DIASPORA])) {
+               if (!in_array($gcontact['network'], [Protocol::DFRN, Protocol::OSTATUS, Protocol::DIASPORA])) {
                        throw new Exception('No federated network ('.$gcontact['network'].') detected for URL '.$gcontact['url']);
                }
 
@@ -460,14 +461,14 @@ class GContact
                //      return $list;
                //}
 
-               $network = [NETWORK_DFRN];
+               $network = [Protocol::DFRN];
 
                if (Config::get('system', 'diaspora_enabled')) {
-                       $network[] = NETWORK_DIASPORA;
+                       $network[] = Protocol::DIASPORA;
                }
 
                if (!Config::get('system', 'ostatus_disabled')) {
-                       $network[] = NETWORK_OSTATUS;
+                       $network[] = Protocol::OSTATUS;
                }
 
                $sql_network = implode("', '", $network);
@@ -580,8 +581,8 @@ class GContact
                // Query your contacts from Friendica and Redmatrix/Hubzilla for their contacts
                $r = q(
                        "SELECT DISTINCT(`poco`) AS `poco` FROM `contact` WHERE `network` IN ('%s', '%s')",
-                       DBA::escape(NETWORK_DFRN),
-                       DBA::escape(NETWORK_DIASPORA)
+                       DBA::escape(Protocol::DFRN),
+                       DBA::escape(Protocol::DIASPORA)
                );
 
                if (DBA::isResult($r)) {
@@ -634,9 +635,9 @@ class GContact
         */
        public static function fixAlternateContactAddress(&$contact)
        {
-               if (($contact["network"] == NETWORK_OSTATUS) && PortableContact::alternateOStatusUrl($contact["url"])) {
+               if (($contact["network"] == Protocol::OSTATUS) && PortableContact::alternateOStatusUrl($contact["url"])) {
                        $data = Probe::uri($contact["url"]);
-                       if ($contact["network"] == NETWORK_OSTATUS) {
+                       if ($contact["network"] == Protocol::OSTATUS) {
                                logger("Fix primary url from ".$contact["url"]." to ".$data["url"]." - Called by: ".System::callstack(), LOGGER_DEBUG);
                                $contact["url"] = $data["url"];
                                $contact["addr"] = $data["addr"];
@@ -665,13 +666,13 @@ class GContact
                        return false;
                }
 
-               if (in_array($contact["network"], [NETWORK_PHANTOM])) {
+               if (in_array($contact["network"], [Protocol::PHANTOM])) {
                        logger("Invalid network for contact url ".$contact["url"]." - Called by: ".System::callstack(), LOGGER_DEBUG);
                        return false;
                }
 
-               if ($contact["network"] == NETWORK_STATUSNET) {
-                       $contact["network"] = NETWORK_OSTATUS;
+               if ($contact["network"] == Protocol::STATUSNET) {
+                       $contact["network"] = Protocol::OSTATUS;
                }
 
                // All new contacts are hidden by default
@@ -683,7 +684,7 @@ class GContact
                self::fixAlternateContactAddress($contact);
 
                // Remove unwanted parts from the contact url (e.g. "?zrl=...")
-               if (in_array($contact["network"], [NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS])) {
+               if (in_array($contact["network"], [Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS])) {
                        $contact["url"] = self::cleanContactUrl($contact["url"]);
                }
 
@@ -697,7 +698,7 @@ class GContact
                        $gcontact_id = $r[0]["id"];
 
                        // Update every 90 days
-                       if (in_array($r[0]["network"], [NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS, ""])) {
+                       if (in_array($r[0]["network"], [Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS, ""])) {
                                $last_failure_str = $r[0]["last_failure"];
                                $last_failure = strtotime($r[0]["last_failure"]);
                                $last_contact_str = $r[0]["last_contact"];
@@ -735,7 +736,7 @@ class GContact
                        if (DBA::isResult($r)) {
                                $gcontact_id = $r[0]["id"];
 
-                               $doprobing = in_array($r[0]["network"], [NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS, ""]);
+                               $doprobing = in_array($r[0]["network"], [Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS, ""]);
                        }
                }
                DBA::unlock();
@@ -810,8 +811,8 @@ class GContact
 
                $fields["hide"] = $public_contact[0]["hide"];
 
-               if ($contact["network"] == NETWORK_STATUSNET) {
-                       $contact["network"] = NETWORK_OSTATUS;
+               if ($contact["network"] == Protocol::STATUSNET) {
+                       $contact["network"] = Protocol::OSTATUS;
                }
 
                // Replace alternate OStatus user format with the primary one
@@ -821,13 +822,13 @@ class GContact
                        $contact["updated"] = DateTimeFormat::utcNow();
                }
 
-               if ($contact["network"] == NETWORK_TWITTER) {
+               if ($contact["network"] == Protocol::TWITTER) {
                        $contact["server_url"] = 'http://twitter.com';
                }
 
                if ($contact["server_url"] == "") {
                        $data = Probe::uri($contact["url"]);
-                       if ($data["network"] != NETWORK_PHANTOM) {
+                       if ($data["network"] != Protocol::PHANTOM) {
                                $contact["server_url"] = $data['baseurl'];
                        }
                } else {
@@ -923,7 +924,7 @@ class GContact
        {
                $data = Probe::uri($url);
 
-               if (in_array($data["network"], [NETWORK_PHANTOM])) {
+               if (in_array($data["network"], [Protocol::PHANTOM])) {
                        logger("Invalid network for contact url ".$data["url"]." - Called by: ".System::callstack(), LOGGER_DEBUG);
                        return;
                }
@@ -972,7 +973,7 @@ class GContact
                                "hide" => ($r[0]["hidewall"] || !$r[0]["net-publish"]),
                                "nick" => $r[0]["nickname"], "addr" => $addr,
                                "connect" => $addr, "server_url" => System::baseUrl(),
-                               "generation" => 1, "network" => NETWORK_DFRN];
+                               "generation" => 1, "network" => Protocol::DFRN];
 
                self::update($gcontact);
        }
@@ -1028,7 +1029,7 @@ class GContact
                                                "name" => $user->fullname,
                                                "addr" => $user->nickname."@".$hostname,
                                                "nick" => $user->nickname,
-                                               "network" => NETWORK_OSTATUS,
+                                               "network" => Protocol::OSTATUS,
                                                "photo" => System::baseUrl()."/images/person-175.jpg"];
 
                                if (isset($user->bio)) {
@@ -1052,7 +1053,7 @@ class GContact
 
                $r = q(
                        "SELECT `nurl`, `url` FROM `gserver` WHERE `last_contact` >= `last_failure` AND `network` = '%s' AND `last_poco_query` < '%s' ORDER BY RAND() LIMIT 5",
-                       DBA::escape(NETWORK_OSTATUS),
+                       DBA::escape(Protocol::OSTATUS),
                        DBA::escape($last_update)
                );
 
@@ -1076,7 +1077,7 @@ class GContact
                                        AND `last_contact` >= `last_failure`
                                        AND `updated` > UTC_TIMESTAMP - INTERVAL 1 MONTH
                                ORDER BY rand() LIMIT 1",
-                       DBA::escape(NETWORK_DFRN)
+                       DBA::escape(Protocol::DFRN)
                );
 
                if (DBA::isResult($r)) {
index 3b491cbe863f6e612ffd6a7d2d1087b286c7c1e1..e22af0e261d337b7009b6f113ea308a5853f6dab 100644 (file)
@@ -12,6 +12,7 @@ use Friendica\Core\Addon;
 use Friendica\Core\Config;
 use Friendica\Core\Lock;
 use Friendica\Core\PConfig;
+use Friendica\Core\Protocol;
 use Friendica\Core\System;
 use Friendica\Core\Worker;
 use Friendica\Database\DBA;
@@ -175,7 +176,7 @@ class Item extends BaseObject
 
                // We can always comment on posts from these networks
                if (array_key_exists('writable', $row) &&
-                       in_array($row['internal-network'], [NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS])) {
+                       in_array($row['internal-network'], [Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS])) {
                        $row['writable'] = true;
                }
 
@@ -1254,7 +1255,7 @@ class Item extends BaseObject
                if ($notify) {
                        $item['wall'] = 1;
                        $item['origin'] = 1;
-                       $item['network'] = NETWORK_DFRN;
+                       $item['network'] = Protocol::DFRN;
                        $item['protocol'] = Conversation::PARCEL_DFRN;
 
                        if (is_int($notify)) {
@@ -1263,7 +1264,7 @@ class Item extends BaseObject
                                $priority = PRIORITY_HIGH;
                        }
                } else {
-                       $item['network'] = trim(defaults($item, 'network', NETWORK_PHANTOM));
+                       $item['network'] = trim(defaults($item, 'network', Protocol::PHANTOM));
                }
 
                $item['guid'] = self::guid($item, $notify);
@@ -1296,7 +1297,7 @@ class Item extends BaseObject
 
                // Converting the plink
                /// @TODO Check if this is really still needed
-               if ($item['network'] == NETWORK_OSTATUS) {
+               if ($item['network'] == Protocol::OSTATUS) {
                        if (isset($item['plink'])) {
                                $item['plink'] = OStatus::convertHref($item['plink']);
                        } elseif (isset($item['uri'])) {
@@ -1343,10 +1344,10 @@ class Item extends BaseObject
                 * We have to check several networks since Friendica posts could be repeated
                 * via OStatus (maybe Diasporsa as well)
                 */
-               if (in_array($item['network'], [NETWORK_DIASPORA, NETWORK_DFRN, NETWORK_OSTATUS, ""])) {
+               if (in_array($item['network'], [Protocol::DIASPORA, Protocol::DFRN, Protocol::OSTATUS, ""])) {
                        $condition = ["`uri` = ? AND `uid` = ? AND `network` IN (?, ?, ?)",
                                trim($item['uri']), $item['uid'],
-                               NETWORK_DIASPORA, NETWORK_DFRN, NETWORK_OSTATUS];
+                               Protocol::DIASPORA, Protocol::DFRN, Protocol::OSTATUS];
                        $existing = self::selectFirst(['id', 'network'], $condition);
                        if (DBA::isResult($existing)) {
                                // We only log the entries with a different user id than 0. Otherwise we would have too many false positives
@@ -1462,10 +1463,10 @@ class Item extends BaseObject
                unset($item['owner-name']);
                unset($item['owner-avatar']);
 
-               if ($item['network'] == NETWORK_PHANTOM) {
+               if ($item['network'] == Protocol::PHANTOM) {
                        logger('Missing network. Called by: '.System::callstack(), LOGGER_DEBUG);
 
-                       $item['network'] = NETWORK_DFRN;
+                       $item['network'] = Protocol::DFRN;
                        logger("Set network to " . $item["network"] . " for " . $item["uri"], LOGGER_DEBUG);
                }
 
@@ -1588,14 +1589,14 @@ class Item extends BaseObject
                $item['thr-parent-id'] = ItemURI::getIdByURI($item['thr-parent']);
 
                $condition = ["`uri` = ? AND `network` IN (?, ?) AND `uid` = ?",
-                       $item['uri'], $item['network'], NETWORK_DFRN, $item['uid']];
+                       $item['uri'], $item['network'], Protocol::DFRN, $item['uid']];
                if (self::exists($condition)) {
                        logger('duplicated item with the same uri found. '.print_r($item,true));
                        return 0;
                }
 
                // On Friendica and Diaspora the GUID is unique
-               if (in_array($item['network'], [NETWORK_DFRN, NETWORK_DIASPORA])) {
+               if (in_array($item['network'], [Protocol::DFRN, Protocol::DIASPORA])) {
                        $condition = ['guid' => $item['guid'], 'uid' => $item['uid']];
                        if (self::exists($condition)) {
                                logger('duplicated item with the same guid found. '.print_r($item,true));
@@ -2044,7 +2045,7 @@ class Item extends BaseObject
 
                // Only distribute public items from native networks
                $condition = ['id' => $itemid, 'uid' => 0,
-                       'network' => [NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS, ""],
+                       'network' => [Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS, ""],
                        'visible' => true, 'deleted' => false, 'moderated' => false, 'private' => false];
                $item = self::selectFirst(self::ITEM_FIELDLIST, ['id' => $itemid]);
                if (!DBA::isResult($item)) {
@@ -2166,7 +2167,7 @@ class Item extends BaseObject
                }
 
                // is it an entry from a connector? Only add an entry for natively connected networks
-               if (!in_array($item["network"], [NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS, ""])) {
+               if (!in_array($item["network"], [Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS, ""])) {
                        return;
                }
 
@@ -2256,7 +2257,7 @@ class Item extends BaseObject
 
                // If this was a comment to a Diaspora post we don't get our comment back.
                // This means that we have to distribute the comment by ourselves.
-               if ($origin && self::exists(['id' => $parent, 'network' => NETWORK_DIASPORA])) {
+               if ($origin && self::exists(['id' => $parent, 'network' => Protocol::DIASPORA])) {
                        self::distribute($public_shadow);
                }
        }
@@ -2355,7 +2356,7 @@ class Item extends BaseObject
                $update = (!$arr['private'] && ((defaults($arr, 'author-link', '') === defaults($arr, 'owner-link', '')) || ($arr["parent-uri"] === $arr["uri"])));
 
                // Is it a forum? Then we don't care about the rules from above
-               if (!$update && ($arr["network"] == NETWORK_DFRN) && ($arr["parent-uri"] === $arr["uri"])) {
+               if (!$update && ($arr["network"] == Protocol::DFRN) && ($arr["parent-uri"] === $arr["uri"])) {
                        if (DBA::exists('contact', ['id' => $arr['contact-id'], 'forum' => true])) {
                                $update = true;
                        }
@@ -2594,7 +2595,7 @@ class Item extends BaseObject
                }
 
                // Prevent the forwarding of posts that are forwarded
-               if (!empty($datarray["extid"]) && ($datarray["extid"] == NETWORK_DFRN)) {
+               if (!empty($datarray["extid"]) && ($datarray["extid"] == Protocol::DFRN)) {
                        logger('Already forwarded', LOGGER_DEBUG);
                        return false;
                }
@@ -2611,7 +2612,7 @@ class Item extends BaseObject
                        return false;
                }
 
-               if (($contact['network'] != NETWORK_FEED) && $datarray['private']) {
+               if (($contact['network'] != Protocol::FEED) && $datarray['private']) {
                        logger('Not public', LOGGER_DEBUG);
                        return false;
                }
@@ -2640,13 +2641,13 @@ class Item extends BaseObject
                                unset($datarray['author-id']);
                        }
 
-                       if ($contact['network'] != NETWORK_FEED) {
+                       if ($contact['network'] != Protocol::FEED) {
                                $datarray["guid"] = System::createGUID(32);
                                unset($datarray["plink"]);
                                $datarray["uri"] = self::newURI($contact['uid'], $datarray["guid"]);
                                $datarray["parent-uri"] = $datarray["uri"];
                                $datarray["thr-parent"] = $datarray["uri"];
-                               $datarray["extid"] = NETWORK_DFRN;
+                               $datarray["extid"] = Protocol::DFRN;
                                $urlpart = parse_url($datarray2['author-link']);
                                $datarray["app"] = $urlpart["host"];
                        } else {
@@ -2654,7 +2655,7 @@ class Item extends BaseObject
                        }
                }
 
-               if ($contact['network'] != NETWORK_FEED) {
+               if ($contact['network'] != Protocol::FEED) {
                        // Store the original post
                        $result = self::insert($datarray2, false, false);
                        logger('remote-self post original item - Contact '.$contact['url'].' return '.$result.' Item '.print_r($datarray2, true), LOGGER_DEBUG);
@@ -3076,7 +3077,7 @@ class Item extends BaseObject
                        'contact-id'    => $item_contact_id,
                        'wall'          => $item['wall'],
                        'origin'        => 1,
-                       'network'       => NETWORK_DFRN,
+                       'network'       => Protocol::DFRN,
                        'gravity'       => GRAVITY_ACTIVITY,
                        'parent'        => $item['id'],
                        'parent-uri'    => $item['uri'],
index 250400ef428d92d08b2aec9e32e078d2d9ebe192..c51f471d8585b4d84fb7fdbb582adebd8fef4785 100644 (file)
@@ -9,6 +9,7 @@ namespace Friendica\Model;
 use Friendica\BaseObject;
 use Friendica\Content\Text;
 use Friendica\Core\PConfig;
+use Friendica\Core\Protocol;
 
 require_once 'boot.php';
 require_once 'include/items.php';
@@ -68,11 +69,13 @@ class ItemContent extends BaseObject
                } else {// Try to guess the correct target network
                        switch ($htmlmode) {
                                case 8:
-                                       $abstract = Text\BBCode::getAbstract($item['body'], NETWORK_TWITTER);
+                                       $abstract = Text\BBCode::getAbstract($item['body'], Protocol::TWITTER);
                                        break;
+
                                case 7:
-                                       $abstract = Text\BBCode::getAbstract($item['body'], NETWORK_STATUSNET);
+                                       $abstract = Text\BBCode::getAbstract($item['body'], Protocol::STATUSNET);
                                        break;
+
                                default: // We don't know the exact target.
                                        // We fetch an abstract since there is a posting limit.
                                        if ($limit > 0) {
index 0f99379bc6c530a792523b866e61e749d64bbaa3..b6400a596cc5e5784d646c3a1b41723be06cfcb8 100644 (file)
@@ -13,6 +13,7 @@ use Friendica\Core\Cache;
 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;
@@ -136,7 +137,7 @@ class Profile
                $a->profile_uid = $pdata['profile_uid'];
 
                $a->profile['mobile-theme'] = PConfig::get($a->profile['profile_uid'], 'system', 'mobile_theme');
-               $a->profile['network'] = NETWORK_DFRN;
+               $a->profile['network'] = Protocol::DFRN;
 
                $a->page['title'] = $a->profile['name'] . ' @ ' . Config::get('config', 'sitename');
 
@@ -280,7 +281,7 @@ class Profile
 
                $profile['picdate'] = urlencode(defaults($profile, 'picdate', ''));
 
-               if (($profile['network'] != '') && ($profile['network'] != NETWORK_DFRN)) {
+               if (($profile['network'] != '') && ($profile['network'] != Protocol::DFRN)) {
                        $profile['network_name'] = format_network_name($profile['network'], $profile['url']);
                } else {
                        $profile['network_name'] = '';
@@ -321,7 +322,7 @@ class Profile
                        }
                }
 
-               if ($connect && ($profile['network'] != NETWORK_DFRN) && !isset($profile['remoteconnect'])) {
+               if ($connect && ($profile['network'] != Protocol::DFRN) && !isset($profile['remoteconnect'])) {
                        $connect = false;
                }
 
@@ -330,7 +331,7 @@ class Profile
                        $remoteconnect = $profile['remoteconnect'];
                }
 
-               if ($connect && ($profile['network'] == NETWORK_DFRN) && !isset($remoteconnect)) {
+               if ($connect && ($profile['network'] == Protocol::DFRN) && !isset($remoteconnect)) {
                        $subscribe_feed = L10n::t('Atom feed');
                } else {
                        $subscribe_feed = false;
@@ -471,9 +472,9 @@ class Profile
                                                AND NOT `hidden` AND NOT `archive`
                                                AND `network` IN ('%s', '%s', '%s', '')",
                                        intval($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)) {
                                        $contacts = intval($r[0]['total']);
@@ -1016,7 +1017,7 @@ class Profile
                                $urlparts = parse_url($my_url);
 
                                $result = Cache::get('gprobe:' . $urlparts['host']);
-                               if ((!is_null($result)) && (in_array($result['network'], [NETWORK_FEED, NETWORK_PHANTOM]))) {
+                               if ((!is_null($result)) && (in_array($result['network'], [Protocol::FEED, Protocol::PHANTOM]))) {
                                        logger('DDoS attempt detected for ' . $urlparts['host'] . ' by ' . $_SERVER['REMOTE_ADDR'] . '. server data: ' . print_r($_SERVER, true), LOGGER_DEBUG);
                                        return;
                                }
index 96f207c4acf9f9a97f43c2b7634d3f9eb2e7060d..46ffc138404650b30f0119320a85b5d2ad1dad95 100644 (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\Core\Worker;
 use Friendica\Database\DBA;
@@ -88,7 +89,7 @@ class User
        {
                $default_group = 0;
 
-               if ($network == NETWORK_OSTATUS) {
+               if ($network == Protocol::OSTATUS) {
                        $default_group = PConfig::get($uid, "ostatus", "default_group");
                }
 
index 75312fee9744c7006fbc0bf64239ab9ef1e1e5db..49c27fb4f2f93957b072dcc1740193a43ab7b354 100644 (file)
@@ -12,6 +12,7 @@ namespace Friendica\Network;
 use DOMDocument;
 use Friendica\Core\Cache;
 use Friendica\Core\Config;
+use Friendica\Core\Protocol;
 use Friendica\Core\System;
 use Friendica\Database\DBA;
 use Friendica\Model\Contact;
@@ -362,20 +363,20 @@ class Probe
                }
 
                if (empty($data["network"])) {
-                       $data["network"] = NETWORK_PHANTOM;
+                       $data["network"] = Protocol::PHANTOM;
                }
 
                $data = self::rearrangeData($data);
 
                // Only store into the cache if the value seems to be valid
-               if (!in_array($data['network'], [NETWORK_PHANTOM, NETWORK_MAIL])) {
+               if (!in_array($data['network'], [Protocol::PHANTOM, Protocol::MAIL])) {
                        Cache::set("Probe::uri:".$network.":".$uri, $data, CACHE_DAY);
 
                        /// @todo temporary fix - we need a real contact update function that updates only changing fields
                        /// The biggest problem is the avatar picture that could have a reduced image size.
                        /// It should only be updated if the existing picture isn't existing anymore.
                        /// We only update the contact when it is no probing for a specific network.
-                       if (($data['network'] != NETWORK_FEED)
+                       if (($data['network'] != Protocol::FEED)
                                && ($network == "")
                                && $data["name"]
                                && $data["nick"]
@@ -568,7 +569,7 @@ class Probe
                        }
 
                        if ($host == 'twitter.com') {
-                               return ["network" => NETWORK_TWITTER];
+                               return ["network" => Protocol::TWITTER];
                        }
                        $lrdd = self::hostMeta($host);
 
@@ -599,7 +600,7 @@ class Probe
                                return self::mail($uri, $uid);
                        }
 
-                       if ($network == NETWORK_MAIL) {
+                       if ($network == Protocol::MAIL) {
                                return self::mail($uri, $uid);
                        }
                        // Remove "acct:" from the URI
@@ -609,7 +610,7 @@ class Probe
                        $nick = substr($uri, 0, strpos($uri, '@'));
 
                        if (strpos($uri, '@twitter.com')) {
-                               return ["network" => NETWORK_TWITTER];
+                               return ["network" => Protocol::TWITTER];
                        }
                        $lrdd = self::hostMeta($host);
 
@@ -670,19 +671,19 @@ class Probe
 
                logger("Probing ".$uri, LOGGER_DEBUG);
 
-               if (in_array($network, ["", NETWORK_DFRN])) {
+               if (in_array($network, ["", Protocol::DFRN])) {
                        $result = self::dfrn($webfinger);
                }
-               if ((!$result && ($network == "")) || ($network == NETWORK_DIASPORA)) {
+               if ((!$result && ($network == "")) || ($network == Protocol::DIASPORA)) {
                        $result = self::diaspora($webfinger);
                }
-               if ((!$result && ($network == "")) || ($network == NETWORK_OSTATUS)) {
+               if ((!$result && ($network == "")) || ($network == Protocol::OSTATUS)) {
                        $result = self::ostatus($webfinger);
                }
-               if ((!$result && ($network == "")) || ($network == NETWORK_PUMPIO)) {
+               if ((!$result && ($network == "")) || ($network == Protocol::PUMPIO)) {
                        $result = self::pumpio($webfinger, $addr);
                }
-               if ((!$result && ($network == "")) || ($network == NETWORK_FEED)) {
+               if ((!$result && ($network == "")) || ($network == Protocol::FEED)) {
                        $result = self::feed($uri);
                } else {
                        // We overwrite the detected nick with our try if the previois routines hadn't detected it.
@@ -697,7 +698,7 @@ class Probe
                }
 
                if (empty($result["network"])) {
-                       $result["network"] = NETWORK_PHANTOM;
+                       $result["network"] = Protocol::PHANTOM;
                }
 
                if (empty($result["url"])) {
@@ -960,7 +961,7 @@ class Probe
                $data = [];
                foreach ($webfinger["links"] as $link) {
                        if (($link["rel"] == NAMESPACE_DFRN) && ($link["href"] != "")) {
-                               $data["network"] = NETWORK_DFRN;
+                               $data["network"] = Protocol::DFRN;
                        } elseif (($link["rel"] == NAMESPACE_FEED) && ($link["href"] != "")) {
                                $data["poll"] = $link["href"];
                        } elseif (($link["rel"] == "http://webfinger.net/rel/profile-page") && ($link["type"] == "text/html") && ($link["href"] != "")) {
@@ -1215,7 +1216,7 @@ class Probe
                        && isset($data["pubkey"])
                        && ($hcard_url != "")
                ) {
-                       $data["network"] = NETWORK_DIASPORA;
+                       $data["network"] = Protocol::DIASPORA;
 
                        // The Diaspora handle must always be lowercase
                        if (!empty($data["addr"])) {
@@ -1302,7 +1303,7 @@ class Probe
                        && isset($data["poll"])
                        && isset($data["url"])
                ) {
-                       $data["network"] = NETWORK_OSTATUS;
+                       $data["network"] = Protocol::OSTATUS;
                } else {
                        return false;
                }
@@ -1446,7 +1447,7 @@ class Probe
                        // So we unset all data that isn't used at the moment
                        unset($data["dialback"]);
 
-                       $data["network"] = NETWORK_PUMPIO;
+                       $data["network"] = Protocol::PUMPIO;
                } else {
                        return false;
                }
@@ -1569,7 +1570,7 @@ class Probe
                        $data["baseurl"] = $data["url"];
                }
 
-               $data["network"] = NETWORK_FEED;
+               $data["network"] = Protocol::FEED;
 
                return $data;
        }
@@ -1619,7 +1620,7 @@ class Probe
 
                $data = [];
                $data["addr"]    = $uri;
-               $data["network"] = NETWORK_MAIL;
+               $data["network"] = Protocol::MAIL;
                $data["name"]    = substr($uri, 0, strpos($uri, '@'));
                $data["nick"]    = $data["name"];
                $data["photo"]   = Network::lookupAvatarByEmail($uri);
index 05b21ebd4c7e2e23b571d3414b898b740ca91dd0..038ca270d79dddc35bce9158ebc404e631502e1a 100644 (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\Database\DBA;
 use Friendica\Model\Contact;
 use Friendica\Model\Item;
@@ -84,14 +85,14 @@ class Post extends BaseObject
                if (!empty($data['children'])) {
                        foreach ($data['children'] as $item) {
                                // Only add will be displayed
-                               if ($item['network'] === NETWORK_MAIL && local_user() != $item['uid']) {
+                               if ($item['network'] === Protocol::MAIL && local_user() != $item['uid']) {
                                        continue;
                                } elseif (!visible_activity($item)) {
                                        continue;
                                }
 
                                // You can always comment on Diaspora and OStatus items
-                               if (in_array($item['network'], [NETWORK_OSTATUS, NETWORK_DIASPORA]) && (local_user() == $item['uid'])) {
+                               if (in_array($item['network'], [Protocol::OSTATUS, Protocol::DIASPORA]) && (local_user() == $item['uid'])) {
                                        $item['writable'] = true;
                                }
 
@@ -323,17 +324,17 @@ class Post extends BaseObject
                $owner_name_e = $this->getOwnerName();
 
                // Disable features that aren't available in several networks
-               if (!in_array($item["network"], [NETWORK_DFRN, NETWORK_DIASPORA]) && isset($buttons["dislike"])) {
+               if (!in_array($item["network"], [Protocol::DFRN, Protocol::DIASPORA]) && isset($buttons["dislike"])) {
                        unset($buttons["dislike"]);
                        $isevent = false;
                        $tagger = '';
                }
 
-               if (($item["network"] == NETWORK_FEED) && isset($buttons["like"])) {
+               if (($item["network"] == Protocol::FEED) && isset($buttons["like"])) {
                        unset($buttons["like"]);
                }
 
-               if (($item["network"] == NETWORK_MAIL) && isset($buttons["like"])) {
+               if (($item["network"] == Protocol::MAIL) && isset($buttons["like"])) {
                        unset($buttons["like"]);
                }
 
@@ -489,7 +490,7 @@ class Post extends BaseObject
                /*
                 * Only add what will be displayed
                 */
-               if ($item->getDataValue('network') === NETWORK_MAIL && local_user() != $item->getDataValue('uid')) {
+               if ($item->getDataValue('network') === Protocol::MAIL && local_user() != $item->getDataValue('uid')) {
                        return false;
                } elseif (activity_match($item->getDataValue('verb'), ACTIVITY_LIKE) || activity_match($item->getDataValue('verb'), ACTIVITY_DISLIKE)) {
                        return false;
index 799029a28117ec8844481b76aa0c6651957e540a..e396d6cbc77f661a162626b1f1aa1391af219559 100644 (file)
@@ -5,6 +5,7 @@
 namespace Friendica\Object;
 
 use Friendica\BaseObject;
+use Friendica\Core\Protocol;
 use Friendica\Object\Post;
 
 require_once 'boot.php';
@@ -143,7 +144,7 @@ class Thread extends BaseObject
                /*
                 * Only add will be displayed
                 */
-               if ($item->getDataValue('network') === NETWORK_MAIL && local_user() != $item->getDataValue('uid')) {
+               if ($item->getDataValue('network') === Protocol::MAIL && local_user() != $item->getDataValue('uid')) {
                        logger('[WARN] Conversation::addThread : Thread is a mail ('. $item->getId() .').', LOGGER_DEBUG);
                        return false;
                }
@@ -176,7 +177,7 @@ class Thread extends BaseObject
                $i = 0;
 
                foreach ($this->parents as $item) {
-                       if ($item->getDataValue('network') === NETWORK_MAIL && local_user() != $item->getDataValue('uid')) {
+                       if ($item->getDataValue('network') === Protocol::MAIL && local_user() != $item->getDataValue('uid')) {
                                continue;
                        }
 
index 296949ddcdb4a1e72799ca744afd83c3a08a0398..55d635d2e0b0460f5b4b843f1419a6ce72ed1c55 100644 (file)
@@ -17,6 +17,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\Database\DBA;
 use Friendica\Model\Contact;
@@ -272,7 +273,7 @@ class DFRN
 
                foreach ($items as $item) {
                        // prevent private email from leaking.
-                       if ($item['network'] == NETWORK_MAIL) {
+                       if ($item['network'] == Protocol::MAIL) {
                                continue;
                        }
 
@@ -1533,7 +1534,7 @@ class DFRN
                $fields = ['id', 'uid', 'url', 'network', 'avatar-date', 'avatar', 'name-date', 'uri-date', 'addr',
                        'name', 'nick', 'about', 'location', 'keywords', 'xmpp', 'bdyear', 'bd', 'hidden', 'contact-type'];
                $condition = ["`uid` = ? AND `nurl` = ? AND `network` != ?",
-                       $importer["importer_uid"], normalise_link($author["link"]), NETWORK_STATUSNET];
+                       $importer["importer_uid"], normalise_link($author["link"]), Protocol::STATUSNET];
                $contact_old = DBA::selectFirst('contact', $fields, $condition);
 
                if (DBA::isResult($contact_old)) {
@@ -2822,7 +2823,7 @@ class DFRN
 
                $header = [];
                $header["uid"] = $importer["importer_uid"];
-               $header["network"] = NETWORK_DFRN;
+               $header["network"] = Protocol::DFRN;
                $header["wall"] = 0;
                $header["origin"] = 0;
                $header["contact-id"] = $importer["id"];
@@ -2956,7 +2957,7 @@ class DFRN
                        $r = q("SELECT * FROM contact WHERE nick = '%s'
                                        AND network = '%s' AND uid = %d  AND url LIKE '%%%s%%' LIMIT 1",
                                DBA::escape($contact_nick),
-                               DBA::escape(NETWORK_DFRN),
+                               DBA::escape(Protocol::DFRN),
                                intval(local_user()),
                                DBA::escape($baseurl)
                        );
index 5036aa357b7fc999d02ada9fb2ff26b972d3bf00..40e2780f829eab7acf5f49177223621bc5faadfd 100644 (file)
@@ -16,6 +16,7 @@ use Friendica\Core\Cache;
 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;
@@ -176,7 +177,7 @@ class Diaspora
        {
                $fields = ['created' => DateTimeFormat::utcNow(),
                        'name' => 'relay', 'nick' => 'relay',
-                       'url' => $server_url, 'network' => NETWORK_DIASPORA,
+                       'url' => $server_url, 'network' => Protocol::DIASPORA,
                        'batch' => $server_url . '/receive/public',
                        'rel' => Contact::FOLLOWER, 'blocked' => false,
                        'pending' => false, 'writable' => true];
@@ -899,7 +900,7 @@ class Diaspora
        {
                $update = false;
 
-               $person = DBA::selectFirst('fcontact', [], ['network' => NETWORK_DIASPORA, 'addr' => $handle]);
+               $person = DBA::selectFirst('fcontact', [], ['network' => Protocol::DIASPORA, 'addr' => $handle]);
                if (DBA::isResult($person)) {
                        logger("In cache " . print_r($person, true), LOGGER_DEBUG);
 
@@ -916,15 +917,15 @@ class Diaspora
 
                if (!DBA::isResult($person) || $update) {
                        logger("create or refresh", LOGGER_DEBUG);
-                       $r = Probe::uri($handle, NETWORK_DIASPORA);
+                       $r = Probe::uri($handle, Protocol::DIASPORA);
 
                        // Note that Friendica contacts will return a "Diaspora person"
                        // if Diaspora connectivity is enabled on their server
-                       if ($r && ($r["network"] === NETWORK_DIASPORA)) {
+                       if ($r && ($r["network"] === Protocol::DIASPORA)) {
                                self::updateFContact($r);
 
                                // Fetch the updated or added contact
-                               $person = DBA::selectFirst('fcontact', [], ['network' => NETWORK_DIASPORA, 'addr' => $handle]);
+                               $person = DBA::selectFirst('fcontact', [], ['network' => Protocol::DIASPORA, 'addr' => $handle]);
                                if (!DBA::isResult($person)) {
                                        $person = $r;
                                }
@@ -1017,7 +1018,7 @@ class Diaspora
 
                $r = q(
                        "SELECT `url` FROM `fcontact` WHERE `url` != '' AND `network` = '%s' AND `guid` = '%s'",
-                       DBA::escape(NETWORK_DIASPORA),
+                       DBA::escape(Protocol::DIASPORA),
                        DBA::escape($fcontact_guid)
                );
 
@@ -1419,7 +1420,7 @@ class Diaspora
                        $network = $contact["network"];
                } else {
                        $cid = $def_contact["id"];
-                       $network = NETWORK_DIASPORA;
+                       $network = Protocol::DIASPORA;
                }
 
                return ["cid" => $cid, "network" => $network];
@@ -1459,7 +1460,7 @@ class Diaspora
                        }
                }
 
-               if ($contact["network"] == NETWORK_DFRN) {
+               if ($contact["network"] == Protocol::DFRN) {
                        return str_replace("/profile/" . $contact["nick"] . "/", "/display/" . $guid, $contact["url"] . "/");
                }
 
@@ -1509,7 +1510,7 @@ class Diaspora
 
                // change the technical stuff in contact and gcontact
                $data = Probe::uri($new_handle);
-               if ($data['network'] == NETWORK_PHANTOM) {
+               if ($data['network'] == Protocol::PHANTOM) {
                        logger('Account for '.$new_handle." couldn't be probed.");
                        return false;
                }
@@ -2281,7 +2282,7 @@ class Diaspora
 
                DBA::update('contact', $fields, ['id' => $contact['id']]);
 
-               $gcontact = ["url" => $contact["url"], "network" => NETWORK_DIASPORA, "generation" => 2,
+               $gcontact = ["url" => $contact["url"], "network" => Protocol::DIASPORA, "generation" => 2,
                                        "photo" => $image_url, "name" => $name, "location" => $location,
                                        "about" => $about, "birthday" => $birthday, "gender" => $gender,
                                        "addr" => $author, "nick" => $nick, "keywords" => $keywords,
@@ -2392,7 +2393,7 @@ class Diaspora
 
                $ret = self::personByHandle($author);
 
-               if (!$ret || ($ret["network"] != NETWORK_DIASPORA)) {
+               if (!$ret || ($ret["network"] != Protocol::DIASPORA)) {
                        logger("Cannot resolve diaspora handle ".$author." for ".$recipient);
                        return false;
                }
@@ -2617,7 +2618,7 @@ class Diaspora
 
                $datarray["uid"] = $importer["uid"];
                $datarray["contact-id"] = $contact["id"];
-               $datarray["network"]  = NETWORK_DIASPORA;
+               $datarray["network"]  = Protocol::DIASPORA;
 
                $datarray["author-link"] = $contact["url"];
                $datarray["author-id"] = Contact::getIdForURL($contact["url"], 0);
@@ -2845,7 +2846,7 @@ class Diaspora
 
                $datarray["uid"] = $importer["uid"];
                $datarray["contact-id"] = $contact["id"];
-               $datarray["network"] = NETWORK_DIASPORA;
+               $datarray["network"] = Protocol::DIASPORA;
 
                $datarray["author-link"] = $contact["url"];
                $datarray["author-id"] = Contact::getIdForURL($contact["url"], 0);
@@ -3110,7 +3111,7 @@ class Diaspora
                        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);
+                               Queue::add($contact["id"], Protocol::DIASPORA, $envelope, $public_batch, $guid);
                        }
 
                        // The message could not be delivered. We mark the contact as "dead"
@@ -3167,7 +3168,7 @@ class Diaspora
                $envelope = self::buildMessage($msg, $owner, $contact, $owner['uprvkey'], $contact['pubkey'], $public_batch);
 
                if ($spool) {
-                       Queue::add($contact['id'], NETWORK_DIASPORA, $envelope, $public_batch, $guid);
+                       Queue::add($contact['id'], Protocol::DIASPORA, $envelope, $public_batch, $guid);
                        return true;
                } else {
                        $return_code = self::transmit($owner, $contact, $envelope, $public_batch, false, $guid);
@@ -3358,7 +3359,7 @@ class Diaspora
                }
 
                if (($guid != "") && $complete) {
-                       $condition = ['guid' => $guid, 'network' => [NETWORK_DFRN, NETWORK_DIASPORA]];
+                       $condition = ['guid' => $guid, 'network' => [Protocol::DFRN, Protocol::DIASPORA]];
                        $item = Item::selectFirst(['contact-id'], $condition);
                        if (DBA::isResult($item)) {
                                $ret= [];
@@ -4133,7 +4134,7 @@ class Diaspora
                        $recips = q(
                                "SELECT `id`,`name`,`network`,`pubkey`,`notify` FROM `contact` WHERE `network` = '%s'
                                AND `uid` = %d AND `rel` != %d",
-                               DBA::escape(NETWORK_DIASPORA),
+                               DBA::escape(Protocol::DIASPORA),
                                intval($uid),
                                intval(Contact::SHARING)
                        );
index 0963feb0d214db7e48c461bcf997ba629a26793e..00122e2eaeb3781b6463aaafb3c9b61815a3962f 100644 (file)
@@ -5,6 +5,7 @@
 namespace Friendica\Protocol;
 
 use Friendica\Content\Text\HTML;
+use Friendica\Core\Protocol;
 
 /**
  * @brief Email class
@@ -308,7 +309,7 @@ class Email
        }
 
        /**
-        * Function send is used by NETWORK_EMAIL and NETWORK_EMAIL2 code
+        * Function send is used by Protocol::EMAIL and Protocol::EMAIL2 code
         * (not to notify the user, but to send items to email contacts)
         *
         * @param string $addr    address
index 7bae9ef588894e6f7e467e7d823818933a33914a..c9c750a83fdfdb57e7f1953c26c9072de1f44bad 100644 (file)
@@ -9,6 +9,7 @@ namespace Friendica\Protocol;
 use DOMDocument;
 use DOMXPath;
 use Friendica\Content\Text\HTML;
+use Friendica\Core\Protocol;
 use Friendica\Core\System;
 use Friendica\Database\DBA;
 use Friendica\Model\Item;
@@ -187,7 +188,7 @@ class Feed {
 
                $header = [];
                $header["uid"] = $importer["uid"];
-               $header["network"] = NETWORK_FEED;
+               $header["network"] = Protocol::FEED;
                $header["wall"] = 0;
                $header["origin"] = 0;
                $header["gravity"] = GRAVITY_PARENT;
@@ -244,7 +245,7 @@ class Feed {
 
                        if (!$simulate) {
                                $condition = ["`uid` = ? AND `uri` = ? AND `network` IN (?, ?)",
-                                       $importer["uid"], $item["uri"], NETWORK_FEED, NETWORK_DFRN];
+                                       $importer["uid"], $item["uri"], Protocol::FEED, Protocol::DFRN];
                                $previous = Item::selectFirst(['id'], $condition);
                                if (DBA::isResult($previous)) {
                                        logger("Item with uri ".$item["uri"]." for user ".$importer["uid"]." already existed under id ".$previous["id"], LOGGER_DEBUG);
index bab85515bcd99290644af5d95d2aa88717153404..80c6edbe9f2b8614fe884b875f811f1aeda8a531 100644 (file)
@@ -12,6 +12,7 @@ use Friendica\Core\Cache;
 use Friendica\Core\Config;
 use Friendica\Core\L10n;
 use Friendica\Core\Lock;
+use Friendica\Core\Protocol;
 use Friendica\Core\System;
 use Friendica\Database\DBA;
 use Friendica\Model\Contact;
@@ -75,7 +76,7 @@ class OStatus
                $contact = null;
                if ($aliaslink != '') {
                        $condition = ["`uid` = ? AND `alias` = ? AND `network` != ? AND `rel` IN (?, ?)",
-                                       $importer["uid"], $aliaslink, NETWORK_STATUSNET,
+                                       $importer["uid"], $aliaslink, Protocol::STATUSNET,
                                        Contact::SHARING, Contact::FRIEND];
                        $contact = DBA::selectFirst('contact', [], $condition);
                }
@@ -87,13 +88,13 @@ 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::SHARING, Contact::FRIEND];
+                                       Protocol::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,
+                                       $importer["uid"], $addr, Protocol::STATUSNET,
                                        Contact::SHARING, Contact::FRIEND];
                        $contact = DBA::selectFirst('contact', [], $condition);
                }
@@ -135,7 +136,7 @@ class OStatus
                $author["owner-id"] = $author["author-id"];
 
                // Only update the contacts if it is an OStatus contact
-               if (DBA::isResult($contact) && ($contact['id'] > 0) && !$onlyfetch && ($contact["network"] == NETWORK_OSTATUS)) {
+               if (DBA::isResult($contact) && ($contact['id'] > 0) && !$onlyfetch && ($contact["network"] == Protocol::OSTATUS)) {
 
                        // Update contact data
                        $current = $contact;
@@ -345,7 +346,7 @@ class OStatus
 
                $header = [];
                $header["uid"] = $importer["uid"];
-               $header["network"] = NETWORK_OSTATUS;
+               $header["network"] = Protocol::OSTATUS;
                $header["wall"] = 0;
                $header["origin"] = 0;
                $header["gravity"] = GRAVITY_COMMENT;
@@ -799,7 +800,7 @@ class OStatus
                        $conv_data = [];
 
                        $conv_data['protocol'] = Conversation::PARCEL_SPLIT_CONVERSATION;
-                       $conv_data['network'] = NETWORK_OSTATUS;
+                       $conv_data['network'] = Protocol::OSTATUS;
                        $conv_data['uri'] = XML::getFirstNodeValue($xpath, 'atom:id/text()', $entry);
 
                        $inreplyto = $xpath->query('thr:in-reply-to', $entry);
@@ -1647,7 +1648,7 @@ class OStatus
                $title = self::entryHeader($doc, $entry, $owner, $item, $toplevel);
 
                $condition = ['uid' => $owner["uid"], 'guid' => $repeated_guid, 'private' => false,
-                       'network' => [NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS]];
+                       'network' => [Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS]];
                $repeated_item = Item::selectFirst([], $condition);
                if (!DBA::isResult($repeated_item)) {
                        return false;
@@ -1745,7 +1746,7 @@ class OStatus
                $object = $doc->createElement("activity:object");
                XML::addElement($doc, $object, "activity:object-type", ACTIVITY_OBJ_PERSON);
 
-               if ($contact['network'] == NETWORK_PHANTOM) {
+               if ($contact['network'] == Protocol::PHANTOM) {
                        XML::addElement($doc, $object, "id", $contact['url']);
                        return $object;
                }
@@ -2161,7 +2162,7 @@ class OStatus
 
                $condition = ["`uid` = ? AND `created` > ? AND NOT `deleted`
                        AND NOT `private` AND `visible` AND `wall` AND `parent-network` IN (?, ?)",
-                       $owner["uid"], $check_date, NETWORK_OSTATUS, NETWORK_DFRN];
+                       $owner["uid"], $check_date, Protocol::OSTATUS, Protocol::DFRN];
 
                if ($filter === 'comments') {
                        $condition[0] .= " AND `object-type` = ? ";
index a94affd0470398e8f898ba66cb51147ca04a1eb4..1c44947f58052823a0a28598341f2a1fa76b977a 100644 (file)
@@ -14,6 +14,7 @@ use DOMXPath;
 use Exception;
 use Friendica\Content\Text\HTML;
 use Friendica\Core\Config;
+use Friendica\Core\Protocol;
 use Friendica\Core\Worker;
 use Friendica\Database\DBA;
 use Friendica\Model\GContact;
@@ -228,7 +229,7 @@ class PortableContact
                        $friendica = preg_replace("=(https?://)(.*)/profile/(.*)=ism", "$1$2", $profile);
                        if ($friendica != $profile) {
                                $server_url = $friendica;
-                               $network = NETWORK_DFRN;
+                               $network = Protocol::DFRN;
                        }
                }
 
@@ -236,7 +237,7 @@ class PortableContact
                        $diaspora = preg_replace("=(https?://)(.*)/u/(.*)=ism", "$1$2", $profile);
                        if ($diaspora != $profile) {
                                $server_url = $diaspora;
-                               $network = NETWORK_DIASPORA;
+                               $network = Protocol::DIASPORA;
                        }
                }
 
@@ -244,7 +245,7 @@ class PortableContact
                        $red = preg_replace("=(https?://)(.*)/channel/(.*)=ism", "$1$2", $profile);
                        if ($red != $profile) {
                                $server_url = $red;
-                               $network = NETWORK_DIASPORA;
+                               $network = Protocol::DIASPORA;
                        }
                }
 
@@ -253,7 +254,7 @@ class PortableContact
                        $mastodon = preg_replace("=(https?://)(.*)/users/(.*)=ism", "$1$2", $profile);
                        if ($mastodon != $profile) {
                                $server_url = $mastodon;
-                               $network = NETWORK_OSTATUS;
+                               $network = Protocol::OSTATUS;
                        }
                }
 
@@ -262,7 +263,7 @@ class PortableContact
                        $ostatus = preg_replace("=(https?://)(.*)/user/(.*)=ism", "$1$2", $profile);
                        if ($ostatus != $profile) {
                                $server_url = $ostatus;
-                               $network = NETWORK_OSTATUS;
+                               $network = Protocol::OSTATUS;
                        }
                }
 
@@ -271,7 +272,7 @@ class PortableContact
                        $base = preg_replace("=(https?://)(.*?)/(.*)=ism", "$1$2", $profile);
                        if ($base != $profile) {
                                $server_url = $base;
-                               $network = NETWORK_PHANTOM;
+                               $network = Protocol::PHANTOM;
                        }
                }
 
@@ -332,7 +333,7 @@ class PortableContact
                        $server_url = normalise_link(self::detectServer($profile));
                }
 
-               if (!in_array($gcontacts[0]["network"], [NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_FEED, NETWORK_OSTATUS, ""])) {
+               if (!in_array($gcontacts[0]["network"], [Protocol::DFRN, Protocol::DIASPORA, Protocol::FEED, Protocol::OSTATUS, ""])) {
                        logger("Profile ".$profile.": Network type ".$gcontacts[0]["network"]." can't be checked", LOGGER_DEBUG);
                        return false;
                }
@@ -350,7 +351,7 @@ class PortableContact
                        $contact['server_url'] = $server_url;
                }
 
-               if (in_array($gcontacts[0]["network"], ["", NETWORK_FEED])) {
+               if (in_array($gcontacts[0]["network"], ["", Protocol::FEED])) {
                        $server = q(
                                "SELECT `network` FROM `gserver` WHERE `nurl` = '%s' AND `network` != ''",
                                DBA::escape(normalise_link($server_url))
@@ -445,7 +446,7 @@ class PortableContact
 
                // Is the profile link the alternate OStatus link notation? (http://domain.tld/user/4711)
                // Then check the other link and delete this one
-               if (($data["network"] == NETWORK_OSTATUS) && self::alternateOStatusUrl($profile)
+               if (($data["network"] == Protocol::OSTATUS) && self::alternateOStatusUrl($profile)
                        && (normalise_link($profile) == normalise_link($data["alias"]))
                        && (normalise_link($profile) != normalise_link($data["url"]))
                ) {
@@ -469,7 +470,7 @@ class PortableContact
                        return false;
                }
 
-               if (($data["poll"] == "") || (in_array($data["network"], [NETWORK_FEED, NETWORK_PHANTOM]))) {
+               if (($data["poll"] == "") || (in_array($data["network"], [Protocol::FEED, Protocol::PHANTOM]))) {
                        $fields = ['last_failure' => DateTimeFormat::utcNow()];
                        DBA::update('gcontact', $fields, ['nurl' => normalise_link($profile)]);
 
@@ -629,7 +630,7 @@ class PortableContact
                        if ($url['type'] == 'zot') {
                                $server = [];
                                $server["platform"] = 'Hubzilla';
-                               $server["network"] = NETWORK_DIASPORA;
+                               $server["network"] = Protocol::DIASPORA;
                                return $server;
                        }
                }
@@ -757,13 +758,13 @@ class PortableContact
                }
 
                if ($gnusocial) {
-                       $server['network'] = NETWORK_OSTATUS;
+                       $server['network'] = Protocol::OSTATUS;
                }
                if ($diaspora) {
-                       $server['network'] = NETWORK_DIASPORA;
+                       $server['network'] = Protocol::DIASPORA;
                }
                if ($friendica) {
-                       $server['network'] = NETWORK_DFRN;
+                       $server['network'] = Protocol::DFRN;
                }
 
                if (!$server) {
@@ -838,11 +839,11 @@ class PortableContact
                }
 
                if ($gnusocial) {
-                       $server['network'] = NETWORK_OSTATUS;
+                       $server['network'] = Protocol::OSTATUS;
                } elseif ($diaspora) {
-                       $server['network'] = NETWORK_DIASPORA;
+                       $server['network'] = Protocol::DIASPORA;
                } elseif ($friendica) {
-                       $server['network'] = NETWORK_DFRN;
+                       $server['network'] = Protocol::DFRN;
                }
 
                if (empty($server)) {
@@ -883,7 +884,7 @@ class PortableContact
                                                $server = [];
                                                $server["platform"] = $version_part[0];
                                                $server["version"] = $version_part[1];
-                                               $server["network"] = NETWORK_DFRN;
+                                               $server["network"] = Protocol::DFRN;
                                        }
                                }
                        }
@@ -903,7 +904,7 @@ class PortableContact
                                        $server = [];
                                        $server["platform"] = $attr['content'];
                                        $server["version"] = "";
-                                       $server["network"] = NETWORK_DIASPORA;
+                                       $server["network"] = Protocol::DIASPORA;
                                }
                        }
                }
@@ -1106,14 +1107,14 @@ class PortableContact
                                                        $platform = "Diaspora";
                                                        $version = trim(str_replace("X-Diaspora-Version:", "", $line));
                                                        $version = trim(str_replace("x-diaspora-version:", "", $version));
-                                                       $network = NETWORK_DIASPORA;
+                                                       $network = Protocol::DIASPORA;
                                                        $versionparts = explode("-", $version);
                                                        $version = $versionparts[0];
                                                }
 
                                                if (stristr($line, 'Server: Mastodon')) {
                                                        $platform = "Mastodon";
-                                                       $network = NETWORK_OSTATUS;
+                                                       $network = Protocol::OSTATUS;
                                                }
                                        }
                                }
@@ -1132,7 +1133,7 @@ class PortableContact
                                // Remove junk that some GNU Social servers return
                                $version = str_replace(chr(239).chr(187).chr(191), "", $serverret["body"]);
                                $version = trim($version, '"');
-                               $network = NETWORK_OSTATUS;
+                               $network = Protocol::OSTATUS;
                        }
 
                        // Test for GNU Social
@@ -1144,7 +1145,7 @@ class PortableContact
                                // Remove junk that some GNU Social servers return
                                $version = str_replace(chr(239) . chr(187) . chr(191), "", $serverret["body"]);
                                $version = trim($version, '"');
-                               $network = NETWORK_OSTATUS;
+                               $network = Protocol::OSTATUS;
                        }
 
                        // Test for Mastodon
@@ -1159,7 +1160,7 @@ class PortableContact
                                        $version = $data['version'];
                                        $site_name = $data['title'];
                                        $info = $data['description'];
-                                       $network = NETWORK_OSTATUS;
+                                       $network = Protocol::OSTATUS;
                                }
 
                                if (!empty($data['stats']['user_count'])) {
@@ -1183,7 +1184,7 @@ class PortableContact
                                if (isset($data['url'])) {
                                        $platform = $data['platform'];
                                        $version = $data['version'];
-                                       $network = NETWORK_DIASPORA;
+                                       $network = Protocol::DIASPORA;
                                }
 
                                if (!empty($data['site_name'])) {
@@ -1221,19 +1222,19 @@ class PortableContact
                                                if (isset($data['site']['platform'])) {
                                                        $platform = $data['site']['platform']['PLATFORM_NAME'];
                                                        $version = $data['site']['platform']['STD_VERSION'];
-                                                       $network = NETWORK_DIASPORA;
+                                                       $network = Protocol::DIASPORA;
                                                }
 
                                                if (isset($data['site']['BlaBlaNet'])) {
                                                        $platform = $data['site']['BlaBlaNet']['PLATFORM_NAME'];
                                                        $version = $data['site']['BlaBlaNet']['STD_VERSION'];
-                                                       $network = NETWORK_DIASPORA;
+                                                       $network = Protocol::DIASPORA;
                                                }
 
                                                if (isset($data['site']['hubzilla'])) {
                                                        $platform = $data['site']['hubzilla']['PLATFORM_NAME'];
                                                        $version = $data['site']['hubzilla']['RED_VERSION'];
-                                                       $network = NETWORK_DIASPORA;
+                                                       $network = Protocol::DIASPORA;
                                                }
 
                                                if (isset($data['site']['redmatrix'])) {
@@ -1244,13 +1245,13 @@ class PortableContact
                                                        }
 
                                                        $version = $data['site']['redmatrix']['RED_VERSION'];
-                                                       $network = NETWORK_DIASPORA;
+                                                       $network = Protocol::DIASPORA;
                                                }
 
                                                if (isset($data['site']['friendica'])) {
                                                        $platform = $data['site']['friendica']['FRIENDICA_PLATFORM'];
                                                        $version = $data['site']['friendica']['FRIENDICA_VERSION'];
-                                                       $network = NETWORK_DFRN;
+                                                       $network = Protocol::DFRN;
                                                }
 
                                                $site_name = $data['site']['name'];
@@ -1306,7 +1307,7 @@ class PortableContact
                                }
 
                                if ($platform == "Diaspora") {
-                                       $network = NETWORK_DIASPORA;
+                                       $network = Protocol::DIASPORA;
                                }
 
                                if (!empty($data['registrations_open']) && $data['registrations_open']) {
@@ -1348,7 +1349,7 @@ class PortableContact
 
                // Check for noscrape
                // Friendica servers could be detected as OStatus servers
-               if (!$failure && in_array($network, [NETWORK_DFRN, NETWORK_OSTATUS])) {
+               if (!$failure && in_array($network, [Protocol::DFRN, Protocol::OSTATUS])) {
                        $serverret = Network::curl($server_url . "/friendica/json");
 
                        if (!$serverret["success"]) {
@@ -1359,7 +1360,7 @@ class PortableContact
                                $data = json_decode($serverret["body"], true);
 
                                if (isset($data['version'])) {
-                                       $network = NETWORK_DFRN;
+                                       $network = Protocol::DFRN;
 
                                        if (!empty($data['no_scrape_url'])) {
                                                $noscrape = $data['no_scrape_url'];
@@ -1423,7 +1424,7 @@ class PortableContact
                        DBA::insert('gserver', $fields);
                }
 
-               if (!$failure && in_array($fields['network'], [NETWORK_DFRN, NETWORK_DIASPORA])) {
+               if (!$failure && in_array($fields['network'], [Protocol::DFRN, Protocol::DIASPORA])) {
                        self::discoverRelay($server_url);
                }
 
@@ -1485,7 +1486,7 @@ class PortableContact
                $fields = [];
                if (isset($data['protocols'])) {
                        if (isset($data['protocols']['diaspora'])) {
-                               $fields['network'] = NETWORK_DIASPORA;
+                               $fields['network'] = Protocol::DIASPORA;
 
                                if (isset($data['protocols']['diaspora']['receive'])) {
                                        $fields['batch'] = $data['protocols']['diaspora']['receive'];
@@ -1495,7 +1496,7 @@ class PortableContact
                        }
 
                        if (isset($data['protocols']['dfrn'])) {
-                               $fields['network'] = NETWORK_DFRN;
+                               $fields['network'] = Protocol::DFRN;
 
                                if (isset($data['protocols']['dfrn']['receive'])) {
                                        $fields['batch'] = $data['protocols']['dfrn']['receive'];
@@ -1518,9 +1519,9 @@ class PortableContact
                        WHERE `network` IN ('%s', '%s', '%s') AND `last_contact` > `last_failure`
                        ORDER BY `last_contact`
                        LIMIT 1000",
-                       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)) {
index edd3e22ef41361d5295c3856ed8a9bc01c4073c7..61077ae734f2d69a20498f905a7f6c466b61ed2c 100644 (file)
@@ -7,6 +7,7 @@ namespace Friendica\Worker;
 use Friendica\BaseObject;
 use Friendica\Core\Addon;
 use Friendica\Core\Config;
+use Friendica\Core\Protocol;
 use Friendica\Core\Worker;
 use Friendica\Database\DBA;
 use Friendica\Model\Contact;
@@ -188,11 +189,11 @@ class Cron
                                        AND `contact`.`network` IN ('%s', '%s', '%s', '%s', '%s') $sql_extra
                                        AND NOT `contact`.`self` AND NOT `contact`.`blocked`
                                WHERE NOT `user`.`account_expired` AND NOT `user`.`account_removed` $abandon_sql",
-                       DBA::escape(NETWORK_DFRN),
-                       DBA::escape(NETWORK_OSTATUS),
-                       DBA::escape(NETWORK_DIASPORA),
-                       DBA::escape(NETWORK_FEED),
-                       DBA::escape(NETWORK_MAIL)
+                       DBA::escape(Protocol::DFRN),
+                       DBA::escape(Protocol::OSTATUS),
+                       DBA::escape(Protocol::DIASPORA),
+                       DBA::escape(Protocol::FEED),
+                       DBA::escape(Protocol::MAIL)
                );
 
                if (!DBA::isResult($contacts)) {
@@ -206,11 +207,11 @@ class Cron
                        }
 
                        // Friendica and OStatus are checked once a day
-                       if (in_array($contact['network'], [NETWORK_DFRN, NETWORK_OSTATUS])) {
+                       if (in_array($contact['network'], [Protocol::DFRN, Protocol::OSTATUS])) {
                                $contact['priority'] = 2;
                        }
 
-                       if ($contact['subhub'] && in_array($contact['network'], [NETWORK_DFRN, NETWORK_OSTATUS])) {
+                       if ($contact['subhub'] && in_array($contact['network'], [Protocol::DFRN, Protocol::OSTATUS])) {
                                /*
                                 * We should be getting everything via a hub. But just to be sure, let's check once a day.
                                 * (You can make this more or less frequent if desired by setting 'pushpoll_frequency' appropriately)
@@ -222,7 +223,7 @@ class Cron
                        }
 
                        // Check Diaspora contacts or followers once a week
-                       if (($contact["network"] == NETWORK_DIASPORA) || ($contact["rel"] == Contact::FOLLOWER)) {
+                       if (($contact["network"] == Protocol::DIASPORA) || ($contact["rel"] == Contact::FOLLOWER)) {
                                $contact['priority'] = 4;
                        }
 
@@ -277,7 +278,7 @@ class Cron
                                }
                        }
 
-                       if (($contact['network'] == NETWORK_FEED) && ($contact['priority'] <= 3)) {
+                       if (($contact['network'] == Protocol::FEED) && ($contact['priority'] <= 3)) {
                                $priority = PRIORITY_MEDIUM;
                        } elseif ($contact['archive']) {
                                $priority = PRIORITY_NEGLIGIBLE;
index 19e6fbaf737e07efd146d7c5f6faf6a157392133..a3916ad973f0dce20230023247bab9feaa790937 100644 (file)
@@ -8,6 +8,7 @@ use Friendica\App;
 use Friendica\BaseObject;
 use Friendica\Core\Cache;
 use Friendica\Core\Config;
+use Friendica\Core\Protocol;
 use Friendica\Database\DBA;
 use Friendica\Database\PostUpdate;
 use Friendica\Model\Contact;
@@ -231,12 +232,12 @@ class CronJobs
 
                $r = q("SELECT `id`, `url` FROM `contact`
                        WHERE `network` = '%s' AND (`batch` = '' OR `notify` = '' OR `poll` = '' OR pubkey = '')
-                               ORDER BY RAND() LIMIT 50", DBA::escape(NETWORK_DIASPORA));
+                               ORDER BY RAND() LIMIT 50", DBA::escape(Protocol::DIASPORA));
                if (!DBA::isResult($r)) {
                        return;
                }
 
-               foreach ($r AS $contact) {
+               foreach ($r as $contact) {
                        // Quit the loop after 3 minutes
                        if (time() > ($starttime + 180)) {
                                return;
@@ -247,7 +248,7 @@ class CronJobs
                        }
 
                        $data = Probe::uri($contact["url"]);
-                       if ($data["network"] != NETWORK_DIASPORA) {
+                       if ($data["network"] != Protocol::DIASPORA) {
                                continue;
                        }
 
index 32bcdfcc40c137b8cea6d42fa32d11fc5d73c256..f47487015326a513d2da703eac33e37af4999917 100644 (file)
@@ -7,6 +7,7 @@ namespace Friendica\Worker;
 use Friendica\BaseObject;
 use Friendica\Core\Config;
 use Friendica\Core\L10n;
+use Friendica\Core\Protocol;
 use Friendica\Core\System;
 use Friendica\Database\DBA;
 use Friendica\Model\Contact;
@@ -156,23 +157,23 @@ class Delivery extends BaseObject
 
                // Transmit via Diaspora if the thread had started as Diaspora post
                // This is done since the uri wouldn't match (Diaspora doesn't transmit it)
-               if (isset($parent) && ($parent['network'] == NETWORK_DIASPORA) && ($contact['network'] == NETWORK_DFRN)) {
-                       $contact['network'] = NETWORK_DIASPORA;
+               if (isset($parent) && ($parent['network'] == Protocol::DIASPORA) && ($contact['network'] == Protocol::DFRN)) {
+                       $contact['network'] = Protocol::DIASPORA;
                }
 
                logger("Delivering " . $cmd . " followup=$followup - via network " . $contact['network']);
 
                switch ($contact['network']) {
 
-                       case NETWORK_DFRN:
+                       case Protocol::DFRN:
                                self::deliverDFRN($cmd, $contact, $owner, $items, $target_item, $public_message, $top_level, $followup);
                                break;
 
-                       case NETWORK_DIASPORA:
+                       case Protocol::DIASPORA:
                                self::deliverDiaspora($cmd, $contact, $owner, $items, $target_item, $public_message, $top_level, $followup);
                                break;
 
-                       case NETWORK_OSTATUS:
+                       case Protocol::OSTATUS:
                                // Do not send to otatus if we are not configured to send to public networks
                                if ($owner['prvnets']) {
                                        break;
@@ -185,7 +186,7 @@ class Delivery extends BaseObject
                                // This is done in "notifier.php" (See "url_recipients" and "push_notify")
                                break;
 
-                       case NETWORK_MAIL:
+                       case Protocol::MAIL:
                                self::deliverMail($cmd, $contact, $owner, $target_item);
                                break;
 
@@ -316,7 +317,7 @@ class Delivery extends BaseObject
 
                if ($deliver_status < 0) {
                        logger('Delivery failed: queuing message ' . $target_item["guid"] );
-                       Queue::add($contact['id'], NETWORK_DFRN, $atom, false, $target_item['guid']);
+                       Queue::add($contact['id'], Protocol::DFRN, $atom, false, $target_item['guid']);
                }
 
                if (($deliver_status >= 200) && ($deliver_status <= 299)) {
index 89b3a0a115f1ea4a57f8cd71c5ea3e3bc3da9d6f..bf1c2a64a718806c5626354993c5b900ff975b6e 100644 (file)
@@ -6,6 +6,7 @@ namespace Friendica\Worker;
 
 use Friendica\Core\Cache;
 use Friendica\Core\Config;
+use Friendica\Core\Protocol;
 use Friendica\Core\Worker;
 use Friendica\Database\DBA;
 use Friendica\Model\GContact;
@@ -147,8 +148,8 @@ class DiscoverPoCo
                                WHERE `last_contact` < UTC_TIMESTAMP - INTERVAL 1 MONTH AND
                                        `last_failure` < UTC_TIMESTAMP - INTERVAL 1 MONTH AND
                                        `network` IN ('%s', '%s', '%s', '%s', '') ORDER BY rand()",
-                               DBA::escape(NETWORK_DFRN), DBA::escape(NETWORK_DIASPORA),
-                               DBA::escape(NETWORK_OSTATUS), DBA::escape(NETWORK_FEED));
+                               DBA::escape(Protocol::DFRN), DBA::escape(Protocol::DIASPORA),
+                               DBA::escape(Protocol::OSTATUS), DBA::escape(Protocol::FEED));
 
                if (!$users) {
                        return;
@@ -159,13 +160,13 @@ class DiscoverPoCo
 
                        $urlparts = parse_url($user["url"]);
                        if (!isset($urlparts["scheme"])) {
-                               DBA::update('gcontact', ['network' => NETWORK_PHANTOM],
+                               DBA::update('gcontact', ['network' => Protocol::PHANTOM],
                                        ['nurl' => normalise_link($user["url"])]);
                                continue;
                         }
 
                        if (in_array($urlparts["host"], ["twitter.com", "identi.ca"])) {
-                               $networks = ["twitter.com" => NETWORK_TWITTER, "identi.ca" => NETWORK_PUMPIO];
+                               $networks = ["twitter.com" => Protocol::TWITTER, "identi.ca" => Protocol::PUMPIO];
 
                                DBA::update('gcontact', ['network' => $networks[$urlparts["host"]]],
                                        ['nurl' => normalise_link($user["url"])]);
@@ -182,7 +183,7 @@ class DiscoverPoCo
                                $server_url = $user["server_url"];
                        }
 
-                       if ((($server_url == "") && ($user["network"] == NETWORK_FEED)) || $force_update || PortableContact::checkServer($server_url, $user["network"])) {
+                       if ((($server_url == "") && ($user["network"] == Protocol::FEED)) || $force_update || PortableContact::checkServer($server_url, $user["network"])) {
                                logger('Check profile '.$user["url"]);
                                Worker::add(PRIORITY_LOW, "DiscoverPoCo", "check_profile", $user["url"]);
 
@@ -241,7 +242,7 @@ class DiscoverPoCo
                                }
 
                                $data = Probe::uri($jj->url);
-                               if ($data["network"] == NETWORK_DFRN) {
+                               if ($data["network"] == Protocol::DFRN) {
                                        logger("Profile ".$jj->url." is reachable (".$search.")", LOGGER_DEBUG);
                                        logger("Add profile ".$jj->url." to local directory (".$search.")", LOGGER_DEBUG);
 
@@ -288,7 +289,7 @@ class DiscoverPoCo
                /// @TODO find all those and convert to all lower-case which is a keyword then
                foreach ($contacts->data AS $user) {
                        $contact = Probe::uri($user->site_address."/".$user->name);
-                       if ($contact["network"] != NETWORK_PHANTOM) {
+                       if ($contact["network"] != Protocol::PHANTOM) {
                                $contact["about"] = $user->description;
                                GContact::update($contact);
                        }
index dfe309cf64c71c7e6b6a26c03542ecc46c74c75b..116ca207025d90cad7677b96cf8bb957d60bf2fa 100644 (file)
@@ -6,6 +6,7 @@
 namespace Friendica\Worker;
 
 use Friendica\Core\Cache;
+use Friendica\Core\Protocol;
 use Friendica\Database\DBA;
 use Friendica\Model\GContact;
 use Friendica\Network\Probe;
@@ -31,7 +32,7 @@ class GProbe {
 
                        $result = Cache::get("gprobe:".$urlparts["host"]);
                        if (!is_null($result)) {
-                               if (in_array($result["network"], [NETWORK_FEED, NETWORK_PHANTOM])) {
+                               if (in_array($result["network"], [Protocol::FEED, Protocol::PHANTOM])) {
                                        logger("DDoS attempt detected for ".$urlparts["host"]." by ".$_SERVER["REMOTE_ADDR"].". server data: ".print_r($_SERVER, true), LOGGER_DEBUG);
                                        return;
                                }
@@ -43,7 +44,7 @@ class GProbe {
                                Cache::set("gprobe:".$urlparts["host"], $arr);
                        }
 
-                       if (!in_array($arr["network"], [NETWORK_FEED, NETWORK_PHANTOM])) {
+                       if (!in_array($arr["network"], [Protocol::FEED, Protocol::PHANTOM])) {
                                GContact::update($arr);
                        }
 
@@ -54,7 +55,7 @@ class GProbe {
                }
                if (DBA::isResult($r)) {
                        // Check for accessibility and do a poco discovery
-                       if (PortableContact::lastUpdated($r[0]['url'], true) && ($r[0]["network"] == NETWORK_DFRN)) {
+                       if (PortableContact::lastUpdated($r[0]['url'], true) && ($r[0]["network"] == Protocol::DFRN)) {
                                PortableContact::loadWorker(0, 0, $r[0]['id'], str_replace('/profile/', '/poco/', $r[0]['url']));
                        }
                }
index a1ac094116015e32d1525d57d7020e6f6bb58ca5..401178ec26664090aa6478314d8812d9470113ae 100644 (file)
@@ -7,6 +7,7 @@ namespace Friendica\Worker;
 use Friendica\BaseObject;
 use Friendica\Core\Addon;
 use Friendica\Core\Config;
+use Friendica\Core\Protocol;
 use Friendica\Core\Worker;
 use Friendica\Database\DBA;
 use Friendica\Model\Contact;
@@ -103,7 +104,7 @@ class Notifier
                        $uid = $item_id;
 
                        $recipients_relocate = q("SELECT * FROM `contact` WHERE `uid` = %d AND NOT `self` AND `network` IN ('%s', '%s')",
-                                               intval($uid), NETWORK_DFRN, NETWORK_DIASPORA);
+                                               intval($uid), Protocol::DFRN, Protocol::DIASPORA);
                } else {
                        // find ancestors
                        $condition = ['id' => $item_id, 'visible' => true, 'moderated' => false];
@@ -250,15 +251,15 @@ class Notifier
                                                $target_item['deny_cid'].$target_item['deny_gid']) == 0))
                                        $push_notify = true;
 
-                               if (($thr_parent && ($thr_parent['network'] == NETWORK_OSTATUS)) || ($parent['network'] == NETWORK_OSTATUS)) {
+                               if (($thr_parent && ($thr_parent['network'] == Protocol::OSTATUS)) || ($parent['network'] == Protocol::OSTATUS)) {
                                        $push_notify = true;
 
-                                       if ($parent["network"] == NETWORK_OSTATUS) {
+                                       if ($parent["network"] == Protocol::OSTATUS) {
                                                // Distribute the message to the DFRN contacts as if this wasn't a followup since OStatus can't relay comments
                                                // Currently it is work at progress
                                                $r = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `network` = '%s' AND NOT `blocked` AND NOT `pending` AND NOT `archive`",
                                                        intval($uid),
-                                                       DBA::escape(NETWORK_DFRN)
+                                                       DBA::escape(Protocol::DFRN)
                                                );
                                                if (DBA::isResult($r)) {
                                                        foreach ($r as $rr) {
@@ -336,7 +337,7 @@ class Notifier
 
                        // If the thread parent is OStatus then do some magic to distribute the messages.
                        // We have not only to look at the parent, since it could be a Friendica thread.
-                       if (($thr_parent && ($thr_parent['network'] == NETWORK_OSTATUS)) || ($parent['network'] == NETWORK_OSTATUS)) {
+                       if (($thr_parent && ($thr_parent['network'] == Protocol::OSTATUS)) || ($parent['network'] == Protocol::OSTATUS)) {
                                $diaspora_delivery = false;
 
                                logger('Some parent is OStatus for '.$target_item["guid"]." - Author: ".$thr_parent['author-id']." - Owner: ".$thr_parent['owner-id'], LOGGER_DEBUG);
@@ -370,9 +371,9 @@ class Notifier
                                }
 
                                // It only makes sense to distribute answers to OStatus messages to Friendica and OStatus - but not Diaspora
-                               $networks = [NETWORK_OSTATUS, NETWORK_DFRN];
+                               $networks = [Protocol::OSTATUS, Protocol::DFRN];
                        } else {
-                               $networks = [NETWORK_OSTATUS, NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_MAIL];
+                               $networks = [Protocol::OSTATUS, Protocol::DFRN, Protocol::DIASPORA, Protocol::MAIL];
                        }
                } else {
                        $public_message = false;
@@ -385,7 +386,7 @@ class Notifier
                                && intval($target_item['pubmail'])) {
                                $r = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `network` = '%s'",
                                        intval($uid),
-                                       DBA::escape(NETWORK_MAIL)
+                                       DBA::escape(Protocol::MAIL)
                                );
                                if (DBA::isResult($r)) {
                                        foreach ($r as $rr) {
@@ -440,7 +441,7 @@ class Notifier
                                $r1 = q("SELECT `batch`, ANY_VALUE(`id`) AS `id`, ANY_VALUE(`name`) AS `name`, ANY_VALUE(`network`) AS `network`
                                        FROM `contact` WHERE `network` = '%s' AND `batch` != ''
                                        AND `uid` = %d AND `rel` != %d AND NOT `blocked` AND NOT `pending` AND NOT `archive` GROUP BY `batch`",
-                                       DBA::escape(NETWORK_DIASPORA),
+                                       DBA::escape(Protocol::DIASPORA),
                                        intval($owner['uid']),
                                        intval(Contact::SHARING)
                                );
@@ -455,7 +456,7 @@ class Notifier
                                }
                        }
 
-                       $condition = ['network' => NETWORK_DFRN, 'uid' => $owner['uid'], 'blocked' => false,
+                       $condition = ['network' => Protocol::DFRN, 'uid' => $owner['uid'], 'blocked' => false,
                                'pending' => false, 'archive' => false, 'rel' => [Contact::FOLLOWER, Contact::FRIEND]];
 
                        $r2 = DBA::toArray(DBA::select('contact', ['id', 'name', 'network'], $condition));
@@ -469,7 +470,7 @@ class Notifier
                                        // except for Diaspora batch jobs
                                        // Don't deliver to folks who have already been delivered to
 
-                                       if (($rr['network'] !== NETWORK_DIASPORA) && (in_array($rr['id'], $conversants))) {
+                                       if (($rr['network'] !== Protocol::DIASPORA) && (in_array($rr['id'], $conversants))) {
                                                logger('notifier: already delivered id=' . $rr['id']);
                                                continue;
                                        }
index b3af0b7018ac77b6ddc70e039f2f7e82bb248814..7f60ddc56898bbd754f139453f33367532f12f24 100644 (file)
@@ -8,6 +8,7 @@ use Friendica\BaseObject;
 use Friendica\Content\Text\BBCode;
 use Friendica\Core\Config;
 use Friendica\Core\PConfig;
+use Friendica\Core\Protocol;
 use Friendica\Database\DBA;
 use Friendica\Model\Contact;
 use Friendica\Model\Item;
@@ -68,7 +69,7 @@ class OnePoll
                }
 
                // Diaspora users, archived users and followers are only checked if they still exist.
-               if ($contact['archive'] || ($contact["network"] == NETWORK_DIASPORA) || ($contact["rel"] == Contact::FOLLOWER)) {
+               if ($contact['archive'] || ($contact["network"] == Protocol::DIASPORA) || ($contact["rel"] == Contact::FOLLOWER)) {
                        $last_updated = PortableContact::lastUpdated($contact["url"], true);
                        $updated = DateTimeFormat::utcNow();
 
@@ -114,7 +115,7 @@ class OnePoll
                );
 
                // Update the contact entry
-               if (($contact['network'] === NETWORK_OSTATUS) || ($contact['network'] === NETWORK_DIASPORA) || ($contact['network'] === NETWORK_DFRN)) {
+               if (($contact['network'] === Protocol::OSTATUS) || ($contact['network'] === Protocol::DIASPORA) || ($contact['network'] === Protocol::DFRN)) {
                        if (!PortableContact::reachable($contact['url'])) {
                                logger("Skipping probably dead contact ".$contact['url']);
 
@@ -160,7 +161,7 @@ class OnePoll
 
                logger("poll: ({$contact['network']}-{$contact['id']}) IMPORTER: {$importer['name']}, CONTACT: {$contact['name']}");
 
-               if ($contact['network'] === NETWORK_DFRN) {
+               if ($contact['network'] === Protocol::DFRN) {
                        $idtosend = $orig_id = (($contact['dfrn-id']) ? $contact['dfrn-id'] : $contact['issued-id']);
                        if (intval($contact['duplex']) && $contact['dfrn-id']) {
                                $idtosend = '0:' . $orig_id;
@@ -289,9 +290,9 @@ class OnePoll
 
                        $xml = Network::post($contact['poll'], $postvars);
 
-               } elseif (($contact['network'] === NETWORK_OSTATUS)
-                       || ($contact['network'] === NETWORK_DIASPORA)
-                       || ($contact['network'] === NETWORK_FEED)) {
+               } elseif (($contact['network'] === Protocol::OSTATUS)
+                       || ($contact['network'] === Protocol::DIASPORA)
+                       || ($contact['network'] === Protocol::FEED)) {
 
                        // Upgrading DB fields from an older Friendica version
                        // Will only do this once per notify-enabled OStatus contact
@@ -300,7 +301,7 @@ class OnePoll
                        $stat_writeable = ((($contact['notify']) && ($contact['rel'] == Contact::FOLLOWER || $contact['rel'] == Contact::FRIEND)) ? 1 : 0);
 
                        // Contacts from OStatus are always writable
-                       if ($contact['network'] === NETWORK_OSTATUS) {
+                       if ($contact['network'] === Protocol::OSTATUS) {
                                $stat_writeable = 1;
                        }
 
@@ -330,7 +331,7 @@ class OnePoll
 
                        $xml = $ret['body'];
 
-               } elseif ($contact['network'] === NETWORK_MAIL) {
+               } elseif ($contact['network'] === Protocol::MAIL) {
                        logger("Mail: Fetching for ".$contact['addr'], LOGGER_DEBUG);
 
                        $mail_disabled = ((function_exists('imap_open') && (! Config::get('system', 'imap_disabled'))) ? 0 : 1);
@@ -383,7 +384,7 @@ class OnePoll
                                                        $datarray = [];
                                                        $datarray['verb'] = ACTIVITY_POST;
                                                        $datarray['object-type'] = ACTIVITY_OBJ_NOTE;
-                                                       $datarray['network'] = NETWORK_MAIL;
+                                                       $datarray['network'] = Protocol::MAIL;
                                                        // $meta = Email::messageMeta($mbox, $msg_uid);
 
                                                        $datarray['uri'] = Email::msgid2iri(trim($meta->message_id, '<>'));
@@ -472,7 +473,7 @@ class OnePoll
 
                                                        // If it seems to be a reply but a header couldn't be found take the last message with matching subject
                                                        if (empty($datarray['parent-uri']) && $reply) {
-                                                               $condition = ['title' => $datarray['title'], 'uid' => importer_uid, 'network' => NETWORK_MAIL];
+                                                               $condition = ['title' => $datarray['title'], 'uid' => importer_uid, 'network' => Protocol::MAIL];
                                                                $params = ['order' => ['created' => true]];
                                                                $parent = Item::selectFirst(['parent-uri'], $condition, $params);
                                                                if (DBA::isResult($parent)) {
@@ -529,7 +530,7 @@ class OnePoll
                                                        if ($datarray['parent-uri'] === $datarray['uri']) {
                                                                $datarray['private'] = 1;
                                                        }
-                                                       if (($contact['network'] === NETWORK_MAIL) && (!PConfig::get($importer_uid, 'system', 'allow_public_email_replies'))) {
+                                                       if (($contact['network'] === Protocol::MAIL) && (!PConfig::get($importer_uid, 'system', 'allow_public_email_replies'))) {
                                                                $datarray['private'] = 1;
                                                                $datarray['allow_cid'] = '<' . $contact['id'] . '>';
                                                        }
@@ -584,16 +585,16 @@ class OnePoll
                        consume_feed($xml, $importer, $contact, $hub);
 
                        // do it a second time for DFRN so that any children find their parents.
-                       if ($contact['network'] === NETWORK_DFRN) {
+                       if ($contact['network'] === Protocol::DFRN) {
                                consume_feed($xml, $importer, $contact, $hub);
                        }
 
                        $hubmode = 'subscribe';
-                       if ($contact['network'] === NETWORK_DFRN || $contact['blocked']) {
+                       if ($contact['network'] === Protocol::DFRN || $contact['blocked']) {
                                $hubmode = 'unsubscribe';
                        }
 
-                       if (($contact['network'] === NETWORK_OSTATUS ||  $contact['network'] == NETWORK_FEED) && (! $contact['hub-verify'])) {
+                       if (($contact['network'] === Protocol::OSTATUS ||  $contact['network'] == Protocol::FEED) && (! $contact['hub-verify'])) {
                                $hub_update = true;
                        }
 
@@ -603,7 +604,7 @@ class OnePoll
 
                        logger("Contact ".$contact['id']." returned hub: ".$hub." Network: ".$contact['network']." Relation: ".$contact['rel']." Update: ".$hub_update);
 
-                       if (strlen($hub) && $hub_update && (($contact['rel'] != Contact::FOLLOWER) || $contact['network'] == NETWORK_FEED)) {
+                       if (strlen($hub) && $hub_update && (($contact['rel'] != Contact::FOLLOWER) || $contact['network'] == Protocol::FEED)) {
                                logger('hub ' . $hubmode . ' : ' . $hub . ' contact name : ' . $contact['name'] . ' local user : ' . $importer['name']);
                                $hubs = explode(',', $hub);
                                if (count($hubs)) {
@@ -622,7 +623,7 @@ class OnePoll
                        self::updateContact($contact, ['last-update' => $updated, 'success_update' => $updated]);
                        DBA::update('gcontact', ['last_contact' => $updated], ['nurl' => $contact['nurl']]);
                        Contact::unmarkForArchival($contact);
-               } elseif (in_array($contact["network"], [NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS, NETWORK_FEED])) {
+               } elseif (in_array($contact["network"], [Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS, Protocol::FEED])) {
                        $updated = DateTimeFormat::utcNow();
 
                        self::updateContact($contact, ['last-update' => $updated, 'failure_update' => $updated]);
index 375267aae2ac3de85a34d499bb10204a978d43b0..b27a776c7a9e65b7a62a93208a2db98f52699ea9 100644 (file)
@@ -7,6 +7,7 @@ namespace Friendica\Worker;
 use Friendica\Core\Addon;
 use Friendica\Core\Cache;
 use Friendica\Core\Config;
+use Friendica\Core\Protocol;
 use Friendica\Core\Worker;
 use Friendica\Database\DBA;
 use Friendica\Model\Contact;
@@ -110,7 +111,7 @@ class Queue
                $deliver_status = 0;
 
                switch ($contact['network']) {
-                       case NETWORK_DFRN:
+                       case Protocol::DFRN:
                                logger('queue: dfrndelivery: item ' . $q_item['id'] . ' for ' . $contact['name'] . ' <' . $contact['url'] . '>');
                                $deliver_status = DFRN::deliver($owner, $contact, $data);
 
@@ -121,7 +122,8 @@ class Queue
                                        Cache::set($cachekey_deadguy . $contact['notify'], true, CACHE_MINUTE);
                                }
                                break;
-                       case NETWORK_OSTATUS:
+
+                       case Protocol::OSTATUS:
                                logger('queue: slapdelivery: item ' . $q_item['id'] . ' for ' . $contact['name'] . ' <' . $contact['url'] . '>');
                                $deliver_status = Salmon::slapper($owner, $contact['notify'], $data);
 
@@ -132,7 +134,8 @@ class Queue
                                        QueueModel::removeItem($q_item['id']);
                                }
                                break;
-                       case NETWORK_DIASPORA:
+
+                       case Protocol::DIASPORA:
                                logger('queue: diaspora_delivery: item ' . $q_item['id'] . ' for ' . $contact['name'] . ' <' . $contact['url'] . '>');
                                $deliver_status = Diaspora::transmit($owner, $contact, $data, $public, true, 'Queue:' . $q_item['id'], true);
 
index 55c91a12718a8a17fca8d748c008064a7e43615e..f2919e4a750e148e0e8531171d9b786e8a1dc3c5 100644 (file)
@@ -6,6 +6,7 @@
 
 namespace Friendica\Worker;
 
+use Friendica\Core\Protocol;
 use Friendica\Database\DBA;
 use Friendica\Network\Probe;
 use Friendica\Protocol\PortableContact;
@@ -28,13 +29,13 @@ class UpdateGContact
                        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])) {
                        return;
                }
 
                $data = Probe::uri($r[0]["url"]);
 
-               if (!in_array($data["network"], [NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS])) {
+               if (!in_array($data["network"], [Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS])) {
                        if ($r[0]["server_url"] != "") {
                                PortableContact::checkServer($r[0]["server_url"], $r[0]["network"]);
                        }