]> git.mxchange.org Git - friendica.git/commitdiff
Moved CONTACT_* constants to Friendica\Model\Contact class, lesser in global namespac...
authorRoland Häder <Quix0r@users.noreply.github.com>
Wed, 25 Jul 2018 02:53:46 +0000 (04:53 +0200)
committerHypolite Petovan <mrpetovan@eml.cc>
Wed, 25 Jul 2018 02:53:46 +0000 (22:53 -0400)
* Rewrite:
- moved all CONTACT_* constants from boot.php to Contact class

* CR request:
- renamed Contact::CONTACT_IS_* -> Contact::* ;-)

26 files changed:
boot.php
include/api.php
include/conversation.php
include/security.php
mod/contacts.php
mod/dfrn_confirm.php
mod/dfrn_notify.php
mod/dfrn_request.php
mod/follow.php
mod/network.php
mod/pubsub.php
mod/repair_ostatus.php
mod/salmon.php
mod/unfollow.php
src/Core/ACL.php
src/Model/Contact.php
src/Model/Item.php
src/Model/Profile.php
src/Network/Probe.php
src/Protocol/DFRN.php
src/Protocol/Diaspora.php
src/Protocol/OStatus.php
src/Worker/Cron.php
src/Worker/Delivery.php
src/Worker/Notifier.php
src/Worker/OnePoll.php

index 767f4eae6105dfa95534598d7b5e1dae0ad30f8f..426d0b1d7952fb6b2a03ecb94eb62f27b3130772 100644 (file)
--- a/boot.php
+++ b/boot.php
@@ -152,19 +152,6 @@ define('REGISTER_OPEN',          2);
  * @}
 */
 
-/**
- * @name Contact_is
- *
- * Relationship types
- * @{
- */
-define('CONTACT_IS_FOLLOWER', 1);
-define('CONTACT_IS_SHARING',  2);
-define('CONTACT_IS_FRIEND',   3);
-/**
- *  @}
- */
-
 /**
  * @name Update
  *
@@ -181,10 +168,10 @@ define('UPDATE_FAILED',  1);
  * @name page/profile types
  *
  * PAGE_NORMAL is a typical personal profile account
- * PAGE_SOAPBOX automatically approves all friend requests as CONTACT_IS_SHARING, (readonly)
- * PAGE_COMMUNITY automatically approves all friend requests as CONTACT_IS_SHARING, but with
+ * PAGE_SOAPBOX automatically approves all friend requests as Contact::SHARING, (readonly)
+ * PAGE_COMMUNITY automatically approves all friend requests as Contact::SHARING, but with
  *      write access to wall and comments (no email and not included in page owner's ACL lists)
- * PAGE_FREELOVE automatically approves all friend requests as full friends (CONTACT_IS_FRIEND).
+ * PAGE_FREELOVE automatically approves all friend requests as full friends (Contact::FRIEND).
  *
  * @{
  */
index 35e2c480ccb0e49a41d04692823302cc0da82441..c00578cdf04bd2bd8fcfcda6c656d98f049256ce 100644 (file)
@@ -753,7 +753,7 @@ function api_get_user(App $a, $contact_id = null)
                'contributors_enabled' => false,
                'is_translator' => false,
                'is_translation_enabled' => false,
-               'following' => (($uinfo[0]['rel'] == CONTACT_IS_FOLLOWER) || ($uinfo[0]['rel'] == CONTACT_IS_FRIEND)),
+               'following' => (($uinfo[0]['rel'] == Contact::FOLLOWER) || ($uinfo[0]['rel'] == Contact::FRIEND)),
                'follow_request_sent' => false,
                'statusnet_blocking' => false,
                'notifications' => false,
@@ -3186,9 +3186,9 @@ function api_statuses_f($qtype)
 
        $sql_extra = '';
        if ($qtype == 'friends') {
-               $sql_extra = sprintf(" AND ( `rel` = %d OR `rel` = %d ) ", intval(CONTACT_IS_SHARING), intval(CONTACT_IS_FRIEND));
+               $sql_extra = sprintf(" AND ( `rel` = %d OR `rel` = %d ) ", intval(Contact::SHARING), intval(Contact::FRIEND));
        } elseif ($qtype == 'followers') {
-               $sql_extra = sprintf(" AND ( `rel` = %d OR `rel` = %d ) ", intval(CONTACT_IS_FOLLOWER), intval(CONTACT_IS_FRIEND));
+               $sql_extra = sprintf(" AND ( `rel` = %d OR `rel` = %d ) ", intval(Contact::FOLLOWER), intval(Contact::FRIEND));
        }
 
        // friends and followers only for self
index 93788399aa3eb8077093409e7304b967e5c8502b..89bc4b54786089d7287a7c1dc34df316187092b8 100644 (file)
@@ -866,7 +866,7 @@ function item_photo_menu($item) {
                        $menu[L10n::t("Poke")] = $poke_link;
                }
 
-               if ((($cid == 0) || ($rel == CONTACT_IS_FOLLOWER)) &&
+               if ((($cid == 0) || ($rel == Contact::FOLLOWER)) &&
                        in_array($item['network'], [NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_DIASPORA])) {
                        $menu[L10n::t('Connect/Follow')] = 'follow?url=' . urlencode($item['author-link']);
                }
index cd24279119c889cae44814caadd0ef11c659d7cd..82cac3f97c976407c46ab46db58364371753c7ed 100644 (file)
@@ -9,6 +9,7 @@ use Friendica\Core\L10n;
 use Friendica\Core\PConfig;
 use Friendica\Core\System;
 use Friendica\Database\DBA;
+use Friendica\Model\Contact;
 use Friendica\Model\Group;
 use Friendica\Util\DateTimeFormat;
 
@@ -241,8 +242,8 @@ function can_write_wall($owner)
                                AND `user`.`blockwall` = 0 AND `readonly` = 0  AND ( `contact`.`rel` IN ( %d , %d ) OR `user`.`page-flags` = %d ) LIMIT 1",
                                intval($owner),
                                intval($cid),
-                               intval(CONTACT_IS_SHARING),
-                               intval(CONTACT_IS_FRIEND),
+                               intval(Contact::SHARING),
+                               intval(Contact::FRIEND),
                                intval(PAGE_COMMUNITY)
                        );
 
index 52363d742c78a7392f434be494c4ff223ae953d3..ae23974e039dc41fabc8699b0107fe39129aa08e 100644 (file)
@@ -514,18 +514,21 @@ function contacts_content(App $a)
                $dir_icon = '';
                $relation_text = '';
                switch ($contact['rel']) {
-                       case CONTACT_IS_FRIEND:
+                       case Contact::FRIEND:
                                $dir_icon = 'images/lrarrow.gif';
                                $relation_text = L10n::t('You are mutual friends with %s');
                                break;
-                       case CONTACT_IS_FOLLOWER;
+
+                       case Contact::FOLLOWER;
                                $dir_icon = 'images/larrow.gif';
                                $relation_text = L10n::t('You are sharing with %s');
                                break;
-                       case CONTACT_IS_SHARING;
+
+                       case Contact::SHARING;
                                $dir_icon = 'images/rarrow.gif';
                                $relation_text = L10n::t('%s is sharing with you');
                                break;
+
                        default:
                                break;
                }
@@ -590,10 +593,10 @@ function contacts_content(App $a)
                $follow = '';
                $follow_text = '';
                if (in_array($contact['network'], [NETWORK_DIASPORA, NETWORK_OSTATUS, NETWORK_DFRN])) {
-                       if ($contact['rel'] == CONTACT_IS_FOLLOWER) {
+                       if ($contact['rel'] == Contact::FOLLOWER) {
                                $follow = System::baseUrl(true) . "/follow?url=" . urlencode($contact["url"]);
                                $follow_text = L10n::t("Connect/Follow");
-                       } elseif ($contact['rel'] == CONTACT_IS_FRIEND) {
+                       } elseif ($contact['rel'] == Contact::FRIEND) {
                                $follow = System::baseUrl(true) . "/unfollow?url=" . urlencode($contact["url"]);
                                $follow_text = L10n::t("Disconnect/Unfollow");
                        }
@@ -781,7 +784,7 @@ function contacts_content(App $a)
                $sql_extra .= sprintf(" AND network = '%s' ", DBA::escape($nets));
        }
 
-       $sql_extra2 = ((($sort_type > 0) && ($sort_type <= CONTACT_IS_FRIEND)) ? sprintf(" AND `rel` = %d ", intval($sort_type)) : '');
+       $sql_extra2 = ((($sort_type > 0) && ($sort_type <= Contact::FRIEND)) ? sprintf(" AND `rel` = %d ", intval($sort_type)) : '');
 
        $r = q("SELECT COUNT(*) AS `total` FROM `contact`
                WHERE `uid` = %d AND `self` = 0 AND `pending` = 0 $sql_extra $sql_extra2 ",
@@ -905,11 +908,12 @@ function contacts_tab($a, $contact_id, $active_tab)
        return $tab_str;
 }
 
-function contact_posts($a, $contact_id)
+function contact_posts(App $a, $contact_id)
 {
        $o = contacts_tab($a, $contact_id, 1);
 
        $contact = DBA::selectFirst('contact', ['url'], ['id' => $contact_id]);
+
        if (DBA::isResult($contact)) {
                $a->page['aside'] = "";
                Profile::load($a, "", 0, Contact::getDetailsByURL($contact["url"]));
@@ -919,28 +923,33 @@ function contact_posts($a, $contact_id)
        return $o;
 }
 
-function _contact_detail_for_template($rr)
+function _contact_detail_for_template(array $rr)
 {
        $dir_icon = '';
        $alt_text = '';
+
        switch ($rr['rel']) {
-               case CONTACT_IS_FRIEND:
+               case Contact::FRIEND:
                        $dir_icon = 'images/lrarrow.gif';
                        $alt_text = L10n::t('Mutual Friendship');
                        break;
-               case CONTACT_IS_FOLLOWER;
+
+               case Contact::FOLLOWER;
                        $dir_icon = 'images/larrow.gif';
                        $alt_text = L10n::t('is a fan of yours');
                        break;
-               case CONTACT_IS_SHARING;
+
+               case Contact::SHARING;
                        $dir_icon = 'images/rarrow.gif';
                        $alt_text = L10n::t('you are a fan of');
                        break;
+
                default:
                        break;
        }
 
        $url = Contact::magicLink($rr['url']);
+
        if (strpos($url, 'redir/') === 0) {
                $sparkle = ' class="sparkle" ';
        } else {
index a2871b3b39e751ecc78f8b30fe356605e1d274dc..f2d9dd8385539dc94e9d1af8121a26a7e9ad3b45 100644 (file)
@@ -305,12 +305,12 @@ function dfrn_confirm_post(App $a, $handsfree = null)
                logger('dfrn_confirm: confirm - imported photos');
 
                if ($network === NETWORK_DFRN) {
-                       $new_relation = CONTACT_IS_FOLLOWER;
-                       if (($relation == CONTACT_IS_SHARING) || ($duplex)) {
-                               $new_relation = CONTACT_IS_FRIEND;
+                       $new_relation = Contact::FOLLOWER;
+                       if (($relation == Contact::SHARING) || ($duplex)) {
+                               $new_relation = Contact::FRIEND;
                        }
 
-                       if (($relation == CONTACT_IS_SHARING) && ($duplex)) {
+                       if (($relation == Contact::SHARING) && ($duplex)) {
                                $duplex = 0;
                        }
 
@@ -347,12 +347,12 @@ function dfrn_confirm_post(App $a, $handsfree = null)
 
                        if ($network === NETWORK_DIASPORA) {
                                if ($duplex) {
-                                       $new_relation = CONTACT_IS_FRIEND;
+                                       $new_relation = Contact::FRIEND;
                                } else {
-                                       $new_relation = CONTACT_IS_FOLLOWER;
+                                       $new_relation = Contact::FOLLOWER;
                                }
 
-                               if ($new_relation != CONTACT_IS_FOLLOWER) {
+                               if ($new_relation != Contact::FOLLOWER) {
                                        $writable = 1;
                                }
                        }
@@ -391,7 +391,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_IS_FRIEND)) {
+               if ((isset($new_relation) && $new_relation == Contact::FRIEND)) {
                        if (DBA::isResult($contact) && ($contact['network'] === NETWORK_DIASPORA)) {
                                $ret = Diaspora::sendShare($user, $contact);
                                logger('share returns: ' . $ret);
@@ -547,12 +547,12 @@ function dfrn_confirm_post(App $a, $handsfree = null)
 
                logger('dfrn_confirm: request - photos imported');
 
-               $new_relation = CONTACT_IS_SHARING;
-               if (($relation == CONTACT_IS_FOLLOWER) || ($duplex)) {
-                       $new_relation = CONTACT_IS_FRIEND;
+               $new_relation = Contact::SHARING;
+               if (($relation == Contact::FOLLOWER) || ($duplex)) {
+                       $new_relation = Contact::FRIEND;
                }
 
-               if (($relation == CONTACT_IS_FOLLOWER) && ($duplex)) {
+               if (($relation == Contact::FOLLOWER) && ($duplex)) {
                        $duplex = 0;
                }
 
@@ -598,7 +598,7 @@ function dfrn_confirm_post(App $a, $handsfree = null)
                        $combined = $r[0];
 
                        if ($combined['notify-flags'] & NOTIFY_CONFIRM) {
-                               $mutual = ($new_relation == CONTACT_IS_FRIEND);
+                               $mutual = ($new_relation == Contact::FRIEND);
                                notification([
                                        'type'         => NOTIFY_CONFIRM,
                                        'notify_flags' => $combined['notify-flags'],
index 6f03bc6c15f6f5a0c04f15b025034b057d785339..3595df9c916ce71f92219398f134a8d2b93307d7 100644 (file)
@@ -375,7 +375,7 @@ function dfrn_notify_content(App $a) {
                        $rino = $rino_remote;
                }
 
-               if (($r[0]['rel'] && ($r[0]['rel'] != CONTACT_IS_SHARING)) || ($r[0]['page-flags'] == PAGE_COMMUNITY)) {
+               if (($r[0]['rel'] && ($r[0]['rel'] != Contact::SHARING)) || ($r[0]['page-flags'] == PAGE_COMMUNITY)) {
                        $perm = 'rw';
                } else {
                        $perm = 'r';
index ede469e1ffa9b0d0ecf91062b23e770fddf05d2a..566ee152b10fdbcb812b67e0ae6f2c6594f26173 100644 (file)
@@ -309,7 +309,7 @@ function dfrn_request_post(App $a)
                                if (strlen($ret[0]['issued-id'])) {
                                        notice(L10n::t('You have already introduced yourself here.') . EOL);
                                        return;
-                               } elseif ($ret[0]['rel'] == CONTACT_IS_FRIEND) {
+                               } elseif ($ret[0]['rel'] == Contact::FRIEND) {
                                        notice(L10n::t('Apparently you are already friends with %s.', $a->profile['name']) . EOL);
                                        return;
                                } else {
index df1977aba99dae3d8b8317f14d138c3f2bf45c4d..6f938ebbbea77a1f770b396a9b347cd09269e52b 100644 (file)
@@ -65,7 +65,7 @@ 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_IS_FOLLOWER), DBA::escape(NETWORK_DFRN), DBA::escape(normalise_link($url)),
+               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));
 
        if ($r) {
index aec992756dfdee03726eddf83310973a105c696e..b96ba96e17d109971f8fd05a5977a22c10d04378 100644 (file)
@@ -776,8 +776,8 @@ function networkThreadedView(App $a, $update, $parent)
                        AND NOT `item`.`moderated` AND $sql_extra4
                        $sql_extra3 $sql_extra $sql_range $sql_nets
                        ORDER BY `order_date` DESC LIMIT 100",
-                       intval(CONTACT_IS_SHARING),
-                       intval(CONTACT_IS_FRIEND),
+                       intval(Contact::SHARING),
+                       intval(Contact::FRIEND),
                        intval(local_user()),
                        intval(local_user())
                );
@@ -796,8 +796,8 @@ function networkThreadedView(App $a, $update, $parent)
                        AND (`user-item`.`hidden` IS NULL OR NOT `user-item`.`hidden`)
                        $sql_extra2 $sql_extra3 $sql_range $sql_extra $sql_nets
                        ORDER BY `order_date` DESC $pager_sql",
-                       intval(CONTACT_IS_SHARING),
-                       intval(CONTACT_IS_FRIEND),
+                       intval(Contact::SHARING),
+                       intval(Contact::FRIEND),
                        intval(local_user()),
                        intval(local_user())
                );
index 5fc40f83d8cb43262014c24a5774419912388f91..ef97bb7f7f625fbfef87d3355bd719b9c4ce11e7 100644 (file)
@@ -2,6 +2,7 @@
 
 use Friendica\App;
 use Friendica\Database\DBA;
+use Friendica\Model\Contact;
 use Friendica\Protocol\OStatus;
 
 require_once('include/security.php');
@@ -113,7 +114,7 @@ function pubsub_post(App $a)
                }
        }
 
-       if (!in_array($contact['rel'], [CONTACT_IS_SHARING, CONTACT_IS_FRIEND]) && ($contact['network'] != NETWORK_FEED)) {
+       if (!in_array($contact['rel'], [Contact::SHARING, Contact::FRIEND]) && ($contact['network'] != NETWORK_FEED)) {
                logger('Contact ' . $contact['id'] . ' is not expected to share with us - ignored.');
                hub_post_return();
        }
index 44d9fbd44a2ab93960026b86b09c464690eb44cb..7531ad35c23e811af063df354f239d48ad579b5f 100644 (file)
@@ -29,8 +29,8 @@ function repair_ostatus_content(App $a) {
                 `uid` = %d AND `network` = '%s' AND `rel` IN (%d, %d)",
                 intval($uid),
                 DBA::escape(NETWORK_OSTATUS),
-                intval(CONTACT_IS_FRIEND),
-                intval(CONTACT_IS_SHARING));
+                intval(Contact::FRIEND),
+                intval(Contact::SHARING));
 
        if (!$r)
                return($o.L10n::t("Error"));
@@ -43,8 +43,8 @@ function repair_ostatus_content(App $a) {
                LIMIT %d, 1",
                 intval($uid),
                 DBA::escape(NETWORK_OSTATUS),
-                intval(CONTACT_IS_FRIEND),
-                intval(CONTACT_IS_SHARING), $counter++);
+                intval(Contact::FRIEND),
+                intval(Contact::SHARING), $counter++);
 
        if (!$r) {
                $o .= L10n::t("Done");
index becdd7475308687968dbfed3019d6af08044f9bd..d1f9cf9a31e6934e4f7440c81b9cf89f26f9c9ca 100644 (file)
@@ -171,7 +171,7 @@ function salmon_post(App $a, $xml = '') {
        // Have we ignored the person?
        // If so we can not accept this post.
 
-       //if((DBA::isResult($r)) && (($r[0]['readonly']) || ($r[0]['rel'] == CONTACT_IS_FOLLOWER) || ($r[0]['blocked']))) {
+       //if((DBA::isResult($r)) && (($r[0]['readonly']) || ($r[0]['rel'] == Contact::FOLLOWER) || ($r[0]['blocked']))) {
        if (DBA::isResult($r) && $r[0]['blocked']) {
                logger('Ignoring this author.');
                System::httpExit(202);
index e92653360963cb101a95d83b7062cd36bfd861e8..f4e4316d6a09b0d729394caa1c89cc33ce508dda 100644 (file)
@@ -27,7 +27,7 @@ function unfollow_post(App $a)
        $return_url = $_SESSION['return_url'];
 
        $condition = ["`uid` = ? AND `rel` = ? AND (`nurl` = ? OR `alias` = ? OR `alias` = ?) AND `network` != ?",
-                       $uid, CONTACT_IS_FRIEND, normalise_link($url),
+                       $uid, Contact::FRIEND, normalise_link($url),
                        normalise_link($url), $url, NETWORK_STATUSNET];
        $contact = DBA::selectFirst('contact', [], $condition);
 
@@ -43,7 +43,7 @@ function unfollow_post(App $a)
                                Contact::terminateFriendship($r[0], $contact);
                        }
                }
-               DBA::update('contact', ['rel' => CONTACT_IS_FOLLOWER], ['id' => $contact['id']]);
+               DBA::update('contact', ['rel' => Contact::FOLLOWER], ['id' => $contact['id']]);
 
                info(L10n::t('Contact unfollowed').EOL);
                goaway(System::baseUrl().'/contacts/'.$contact['id']);
@@ -66,7 +66,7 @@ function unfollow_content(App $a)
        $submit = L10n::t('Submit Request');
 
        $condition = ["`uid` = ? AND `rel` = ? AND (`nurl` = ? OR `alias` = ? OR `alias` = ?) AND `network` != ?",
-                       local_user(), CONTACT_IS_FRIEND, normalise_link($url),
+                       local_user(), Contact::FRIEND, normalise_link($url),
                        normalise_link($url), $url, NETWORK_STATUSNET];
        $contact = DBA::selectFirst('contact', ['url', 'network', 'addr', 'name'], $condition);
 
index 415978bae079340410f576eb782ddbd5647ad84c..99bda66a5d2c786f343d74d8a0e440e1ec0ed988 100644 (file)
@@ -75,7 +75,7 @@ class ACL extends BaseObject
                $sql_extra = '';
 
                if (!empty($x['mutual'])) {
-                       $sql_extra .= sprintf(" AND `rel` = %d ", intval(CONTACT_IS_FRIEND));
+                       $sql_extra .= sprintf(" AND `rel` = %d ", intval(Contact::FRIEND));
                }
 
                if (!empty($x['exclude'])) {
@@ -151,7 +151,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_IS_FRIEND));
+               $sql_extra = sprintf(" AND `rel` = %d ", intval(Contact::FRIEND));
                $sql_extra .= sprintf(" AND `network` IN ('%s' , '%s') ", NETWORK_DFRN, NETWORK_DIASPORA);
 
                $tabindex_attr = !empty($tabindex) ? ' tabindex="' . intval($tabindex) . '"' : '';
index b9164837a1fed506df58e8e93ccd07269ded798c..90c30ef93f533e7aeacccb291759015d0c27e83c 100644 (file)
@@ -30,6 +30,19 @@ require_once 'include/text.php';
  */
 class Contact extends BaseObject
 {
+       /**
+        * @name Contact_is
+        *
+        * Relationship types
+        * @{
+        */
+       const FOLLOWER = 1;
+       const SHARING  = 2;
+       const FRIEND   = 3;
+       /**
+        * @}
+        */
+
        /**
         * @brief Returns a list of contacts belonging in a group
         *
@@ -849,7 +862,7 @@ class Contact extends BaseObject
                                'about'     => $data["about"],
                                'network'   => $data["network"],
                                'pubkey'    => $data["pubkey"],
-                               'rel'       => CONTACT_IS_SHARING,
+                               'rel'       => self::SHARING,
                                'priority'  => $data["priority"],
                                'batch'     => $data["batch"],
                                'request'   => $data["request"],
@@ -1374,12 +1387,12 @@ class Contact extends BaseObject
 
                if (DBA::isResult($r)) {
                        // update contact
-                       $new_relation = (($r[0]['rel'] == CONTACT_IS_FOLLOWER) ? CONTACT_IS_FRIEND : CONTACT_IS_SHARING);
+                       $new_relation = (($r[0]['rel'] == self::FOLLOWER) ? self::FRIEND : self::SHARING);
 
                        $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])) ? CONTACT_IS_FRIEND : CONTACT_IS_SHARING);
+                       $new_relation = ((in_array($ret['network'], [NETWORK_MAIL])) ? self::FRIEND : self::SHARING);
 
                        // create contact record
                        DBA::insert('contact', [
@@ -1500,9 +1513,9 @@ class Contact extends BaseObject
                }
 
                if (is_array($contact)) {
-                       if (($contact['rel'] == CONTACT_IS_SHARING)
-                               || ($sharing && $contact['rel'] == CONTACT_IS_FOLLOWER)) {
-                               DBA::update('contact', ['rel' => CONTACT_IS_FRIEND, 'writable' => true],
+                       if (($contact['rel'] == self::SHARING)
+                               || ($sharing && $contact['rel'] == self::FOLLOWER)) {
+                               DBA::update('contact', ['rel' => self::FRIEND, 'writable' => true],
                                                ['id' => $contact['id'], 'uid' => $importer['uid']]);
                        }
                        // send email notification to owner?
@@ -1524,7 +1537,7 @@ class Contact extends BaseObject
                                DBA::escape($nick),
                                DBA::escape($photo),
                                DBA::escape(NETWORK_OSTATUS),
-                               intval(CONTACT_IS_FOLLOWER)
+                               intval(self::FOLLOWER)
                        );
 
                        $contact_record = [
@@ -1580,19 +1593,19 @@ class Contact extends BaseObject
                }
        }
 
-       public static function removeFollower($importer, $contact, array $datarray = [], $item = "") {
-
-               if (($contact['rel'] == CONTACT_IS_FRIEND) || ($contact['rel'] == CONTACT_IS_SHARING)) {
-                       DBA::update('contact', ['rel' => CONTACT_IS_SHARING], ['id' => $contact['id']]);
+       public static function removeFollower($importer, $contact, array $datarray = [], $item = "")
+       {
+               if (($contact['rel'] == self::FRIEND) || ($contact['rel'] == self::SHARING)) {
+                       DBA::update('contact', ['rel' => self::SHARING], ['id' => $contact['id']]);
                } else {
                        Contact::remove($contact['id']);
                }
        }
 
-       public static function removeSharer($importer, $contact, array $datarray = [], $item = "") {
-
-               if (($contact['rel'] == CONTACT_IS_FRIEND) || ($contact['rel'] == CONTACT_IS_FOLLOWER)) {
-                       DBA::update('contact', ['rel' => CONTACT_IS_FOLLOWER], ['id' => $contact['id']]);
+       public static function removeSharer($importer, $contact, array $datarray = [], $item = "")
+       {
+               if (($contact['rel'] == self::FRIEND) || ($contact['rel'] == self::FOLLOWER)) {
+                       DBA::update('contact', ['rel' => self::FOLLOWER], ['id' => $contact['id']]);
                } else {
                        Contact::remove($contact['id']);
                }
index 8c803fff963e21ff30d62e2096d251c502f5fa79..e2dc28e8339620424f215a19e6b65c514884ab39 100644 (file)
@@ -15,6 +15,7 @@ use Friendica\Core\PConfig;
 use Friendica\Core\System;
 use Friendica\Core\Worker;
 use Friendica\Database\DBA;
+use Friendica\Model\Contact;
 use Friendica\Object\Image;
 use Friendica\Protocol\Diaspora;
 use Friendica\Protocol\OStatus;
@@ -600,7 +601,7 @@ class Item extends BaseObject
                                STRAIGHT_JOIN `contact` AS `author` ON `author`.`id` = $master_table.`author-id` AND NOT `author`.`blocked`
                                STRAIGHT_JOIN `contact` AS `owner` ON `owner`.`id` = $master_table.`owner-id` AND NOT `owner`.`blocked`
                                LEFT JOIN `user-item` ON `user-item`.`iid` = $master_table_key AND `user-item`.`uid` = %d",
-                               CONTACT_IS_SHARING, CONTACT_IS_FRIEND, GRAVITY_PARENT, intval($uid));
+                               Contact::SHARING, Contact::FRIEND, GRAVITY_PARENT, intval($uid));
                } else {
                        if (strpos($sql_commands, "`contact`.") !== false) {
                                $joins .= "LEFT JOIN `contact` ON `contact`.`id` = $master_table.`contact-id`";
@@ -2025,8 +2026,10 @@ class Item extends BaseObject
                $users = [];
 
                $condition = ["`nurl` IN (SELECT `nurl` FROM `contact` WHERE `id` = ?) AND `uid` != 0 AND NOT `blocked` AND `rel` IN (?, ?)",
-                       $parent['owner-id'], CONTACT_IS_SHARING,  CONTACT_IS_FRIEND];
+                       $parent['owner-id'], Contact::SHARING,  Contact::FRIEND];
+
                $contacts = DBA::select('contact', ['uid'], $condition);
+
                while ($contact = DBA::fetch($contacts)) {
                        $users[$contact['uid']] = $contact['uid'];
                }
index 1bd7a97027303a1e80f46f512883909516a0bb15..15ad83ed85f60dd916ff528c6fb27a7afd497af0 100644 (file)
@@ -16,6 +16,7 @@ use Friendica\Core\PConfig;
 use Friendica\Core\System;
 use Friendica\Core\Worker;
 use Friendica\Database\DBA;
+use Friendica\Model\Contact;
 use Friendica\Protocol\Diaspora;
 use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Network;
@@ -340,14 +341,14 @@ class Profile
                                        "SELECT `url` FROM `contact` WHERE `uid` = %d AND `id` = '%s' AND `rel` = %d",
                                        intval($profile['uid']),
                                        intval(remote_user()),
-                                       intval(CONTACT_IS_FRIEND)
+                                       intval(Contact::FRIEND)
                                );
                        } else {
                                $r = q(
                                        "SELECT `url` FROM `contact` WHERE `uid` = %d AND `nurl` = '%s' AND `rel` = %d",
                                        intval($profile['uid']),
                                        DBA::escape(normalise_link(self::getMyURL())),
-                                       intval(CONTACT_IS_FRIEND)
+                                       intval(Contact::FRIEND)
                                );
                        }
                        if ($r) {
index 3ad33662a79211b83d052ee3812c9bf40b8a3d5e..385ab9dec163093db60db3ee97906de5bf049140 100644 (file)
@@ -14,6 +14,7 @@ use Friendica\Core\Cache;
 use Friendica\Core\Config;
 use Friendica\Core\System;
 use Friendica\Database\DBA;
+use Friendica\Model\Contact;
 use Friendica\Model\Profile;
 use Friendica\Protocol\Email;
 use Friendica\Protocol\Feed;
@@ -447,7 +448,7 @@ class Probe
                                                'pubkey' => $data['pubkey'],
                                                'priority' => $data['priority'],
                                                'writable' => true,
-                                               'rel' => CONTACT_IS_SHARING];
+                                               'rel' => Contact::SHARING];
 
                                $fieldnames = [];
 
index 928f44e9c732421db901dd1450ec4119073b5536..eda85023fd2a03dfef8dac278adf2f3fd0a55bc7 100644 (file)
@@ -1260,7 +1260,7 @@ class DFRN
 
                if (($contact['duplex'] && strlen($contact['pubkey']))
                        || ($owner['page-flags'] == PAGE_COMMUNITY && strlen($contact['pubkey']))
-                       || ($contact['rel'] == CONTACT_IS_SHARING && strlen($contact['pubkey']))
+                       || ($contact['rel'] == Contact::SHARING && strlen($contact['pubkey']))
                ) {
                        openssl_public_decrypt($sent_dfrn_id, $final_dfrn_id, $contact['pubkey']);
                        openssl_public_decrypt($challenge, $postvars['challenge'], $contact['pubkey']);
@@ -1288,7 +1288,7 @@ class DFRN
                        $postvars['dissolve'] = '1';
                }
 
-               if ((($contact['rel']) && ($contact['rel'] != CONTACT_IS_SHARING) && (! $contact['blocked'])) || ($owner['page-flags'] == PAGE_COMMUNITY)) {
+               if ((($contact['rel']) && ($contact['rel'] != Contact::SHARING) && (! $contact['blocked'])) || ($owner['page-flags'] == PAGE_COMMUNITY)) {
                        $postvars['data'] = $atom;
                        $postvars['perm'] = 'rw';
                } else {
@@ -1323,7 +1323,7 @@ class DFRN
                        if ($dfrn_version >= 2.1) {
                                if (($contact['duplex'] && strlen($contact['pubkey']))
                                        || ($owner['page-flags'] == PAGE_COMMUNITY && strlen($contact['pubkey']))
-                                       || ($contact['rel'] == CONTACT_IS_SHARING && strlen($contact['pubkey']))
+                                       || ($contact['rel'] == Contact::SHARING && strlen($contact['pubkey']))
                                ) {
                                        openssl_public_encrypt($key, $postvars['key'], $contact['pubkey']);
                                } else {
@@ -2712,7 +2712,7 @@ class DFRN
                                $item["owner-id"] = Contact::getIdForURL($importer["url"], 0);
                        }
 
-                       if (($importer["rel"] == CONTACT_IS_FOLLOWER) && (!self::tgroupCheck($importer["importer_uid"], $item))) {
+                       if (($importer["rel"] == Contact::FOLLOWER) && (!self::tgroupCheck($importer["importer_uid"], $item))) {
                                logger("Contact ".$importer["id"]." is only follower and tgroup check was negative.", LOGGER_DEBUG);
                                return;
                        }
index c0b57dafaf4923d7f0a70c64fabc3105d1721f26..372f8a6f7f223cb964a435443ef938f337f9247d 100644 (file)
@@ -177,7 +177,7 @@ class Diaspora
                        'name' => 'relay', 'nick' => 'relay',
                        'url' => $server_url, 'network' => NETWORK_DIASPORA,
                        'batch' => $server_url . '/receive/public',
-                       'rel' => CONTACT_IS_FOLLOWER, 'blocked' => false,
+                       'rel' => Contact::FOLLOWER, 'blocked' => false,
                        'pending' => false, 'writable' => true];
 
                $fields = array_merge($fields, $network_fields);
@@ -1079,14 +1079,14 @@ class Diaspora
                 */
                // It is deactivated by now, due to side effects. See issue https://github.com/friendica/friendica/pull/4033
                // It is not removed by now. Possibly the code is needed?
-               //if (!$is_comment && $contact["rel"] == CONTACT_IS_FOLLOWER && in_array($importer["page-flags"], array(PAGE_FREELOVE))) {
+               //if (!$is_comment && $contact["rel"] == Contact::FOLLOWER && in_array($importer["page-flags"], array(PAGE_FREELOVE))) {
                //      dba::update(
                //              'contact',
-               //              array('rel' => CONTACT_IS_FRIEND, 'writable' => true),
+               //              array('rel' => Contact::FRIEND, 'writable' => true),
                //              array('id' => $contact["id"], 'uid' => $contact["uid"])
                //      );
                //
-               //      $contact["rel"] = CONTACT_IS_FRIEND;
+               //      $contact["rel"] = Contact::FRIEND;
                //      logger("defining user ".$contact["nick"]." as friend");
                //}
 
@@ -1095,11 +1095,11 @@ class Diaspora
                        // Maybe blocked, don't accept.
                        return false;
                        // We are following this person?
-               } elseif (($contact["rel"] == CONTACT_IS_SHARING) || ($contact["rel"] == CONTACT_IS_FRIEND)) {
+               } elseif (($contact["rel"] == Contact::SHARING) || ($contact["rel"] == Contact::FRIEND)) {
                        // Yes, then it is fine.
                        return true;
                        // Is it a post to a community?
-               } elseif (($contact["rel"] == CONTACT_IS_FOLLOWER) && in_array($importer["page-flags"], [PAGE_COMMUNITY, PAGE_PRVGROUP])) {
+               } elseif (($contact["rel"] == Contact::FOLLOWER) && in_array($importer["page-flags"], [PAGE_COMMUNITY, PAGE_PRVGROUP])) {
                        // That's good
                        return true;
                        // Is the message a global user or a comment?
@@ -2305,10 +2305,10 @@ class Diaspora
        {
                $a = get_app();
 
-               if ($contact["rel"] == CONTACT_IS_SHARING) {
+               if ($contact["rel"] == Contact::SHARING) {
                        DBA::update(
                                'contact',
-                               ['rel' => CONTACT_IS_FRIEND, 'writable' => true],
+                               ['rel' => Contact::FRIEND, 'writable' => true],
                                ['id' => $contact["id"], 'uid' => $importer["uid"]]
                        );
                }
@@ -2359,7 +2359,7 @@ class Diaspora
 
                                // If we are now friends, we are sending a share message.
                                // Normally we needn't to do so, but the first message could have been vanished.
-                               if (in_array($contact["rel"], [CONTACT_IS_FRIEND])) {
+                               if (in_array($contact["rel"], [Contact::FRIEND])) {
                                        $u = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1", intval($importer["uid"]));
                                        if ($u) {
                                                logger("Sending share message to author ".$author." - Contact: ".$contact["id"]." - User: ".$importer["uid"], LOGGER_DEBUG);
@@ -2455,16 +2455,16 @@ class Diaspora
 
                        Contact::updateAvatar($contact_record["photo"], $importer["uid"], $contact_record["id"]);
 
-                       // technically they are sharing with us (CONTACT_IS_SHARING),
+                       // technically they are sharing with us (Contact::SHARING),
                        // but if our page-type is PAGE_COMMUNITY or PAGE_SOAPBOX
                        // we are going to change the relationship and make them a follower.
 
                        if (($importer["page-flags"] == PAGE_FREELOVE) && $sharing && $following) {
-                               $new_relation = CONTACT_IS_FRIEND;
+                               $new_relation = Contact::FRIEND;
                        } elseif (($importer["page-flags"] == PAGE_FREELOVE) && $sharing) {
-                               $new_relation = CONTACT_IS_SHARING;
+                               $new_relation = Contact::SHARING;
                        } else {
-                               $new_relation = CONTACT_IS_FOLLOWER;
+                               $new_relation = Contact::FOLLOWER;
                        }
 
                        $r = q(
@@ -3269,13 +3269,15 @@ class Diaspora
 
                /*
                switch ($contact["rel"]) {
-                       case CONTACT_IS_FRIEND:
+                       case Contact::FRIEND:
                                $following = true;
                                $sharing = true;
-                       case CONTACT_IS_SHARING:
+
+                       case Contact::SHARING:
                                $following = false;
                                $sharing = true;
-                       case CONTACT_IS_FOLLOWER:
+
+                       case Contact::FOLLOWER:
                                $following = true;
                                $sharing = false;
                }
@@ -4131,7 +4133,7 @@ class Diaspora
                                AND `uid` = %d AND `rel` != %d",
                                DBA::escape(NETWORK_DIASPORA),
                                intval($uid),
-                               intval(CONTACT_IS_SHARING)
+                               intval(Contact::SHARING)
                        );
                }
 
index 7c6f7f1ce41176e8b8bc3cbf76b86112cb7e4a8c..33d251fd6113641de1bdc3022e1b2b926432d9e8 100644 (file)
@@ -76,7 +76,7 @@ class OStatus
                if ($aliaslink != '') {
                        $condition = ["`uid` = ? AND `alias` = ? AND `network` != ? AND `rel` IN (?, ?)",
                                        $importer["uid"], $aliaslink, NETWORK_STATUSNET,
-                                       CONTACT_IS_SHARING, CONTACT_IS_FRIEND];
+                                       Contact::SHARING, Contact::FRIEND];
                        $contact = DBA::selectFirst('contact', [], $condition);
                }
 
@@ -87,14 +87,14 @@ class OStatus
 
                        $condition = ["`uid` = ? AND `nurl` IN (?, ?) AND `network` != ? AND `rel` IN (?, ?)",
                                        $importer["uid"], normalise_link($author["author-link"]), normalise_link($aliaslink),
-                                       NETWORK_STATUSNET, CONTACT_IS_SHARING, CONTACT_IS_FRIEND];
+                                       NETWORK_STATUSNET, Contact::SHARING, Contact::FRIEND];
                        $contact = DBA::selectFirst('contact', [], $condition);
                }
 
                if (!DBA::isResult($contact) && ($addr != '')) {
                        $condition = ["`uid` = ? AND `addr` = ? AND `network` != ? AND `rel` IN (?, ?)",
                                        $importer["uid"], $addr, NETWORK_STATUSNET,
-                                       CONTACT_IS_SHARING, CONTACT_IS_FRIEND];
+                                       Contact::SHARING, Contact::FRIEND];
                        $contact = DBA::selectFirst('contact', [], $condition);
                }
 
index b28c4216198e454c5cafe998435b2c0949481dfa..edd3e22ef41361d5295c3856ed8a9bc01c4073c7 100644 (file)
@@ -9,6 +9,7 @@ use Friendica\Core\Addon;
 use Friendica\Core\Config;
 use Friendica\Core\Worker;
 use Friendica\Database\DBA;
+use Friendica\Model\Contact;
 use Friendica\Util\DateTimeFormat;
 
 require_once 'include/dba.php';
@@ -221,7 +222,7 @@ class Cron
                        }
 
                        // Check Diaspora contacts or followers once a week
-                       if (($contact["network"] == NETWORK_DIASPORA) || ($contact["rel"] == CONTACT_IS_FOLLOWER)) {
+                       if (($contact["network"] == NETWORK_DIASPORA) || ($contact["rel"] == Contact::FOLLOWER)) {
                                $contact['priority'] = 4;
                        }
 
index 022faa2d7ac26a07e5d0a14be27b8f49baa6a47c..a996f85feed6b4d725ab999f280fbd31327d2465 100644 (file)
@@ -424,7 +424,7 @@ class Delivery extends BaseObject
 
                // only expose our real email address to true friends
 
-               if (($contact['rel'] == CONTACT_IS_FRIEND) && !$contact['blocked']) {
+               if (($contact['rel'] == Contact::FRIEND) && !$contact['blocked']) {
                        if ($reply_to) {
                                $headers  = 'From: ' . Email::encodeHeader($local_user['username'],'UTF-8') . ' <' . $reply_to.'>' . "\n";
                                $headers .= 'Sender: ' . $local_user['email'] . "\n";
index 61b05a1b197bcc38d37eba82f43176f0d1932c61..a1ac094116015e32d1525d57d7020e6f6bb58ca5 100644 (file)
@@ -442,7 +442,7 @@ class Notifier
                                        AND `uid` = %d AND `rel` != %d AND NOT `blocked` AND NOT `pending` AND NOT `archive` GROUP BY `batch`",
                                        DBA::escape(NETWORK_DIASPORA),
                                        intval($owner['uid']),
-                                       intval(CONTACT_IS_SHARING)
+                                       intval(Contact::SHARING)
                                );
 
                                // Fetch the participation list
@@ -456,7 +456,8 @@ class Notifier
                        }
 
                        $condition = ['network' => NETWORK_DFRN, 'uid' => $owner['uid'], 'blocked' => false,
-                               'pending' => false, 'archive' => false, 'rel' => [CONTACT_IS_FOLLOWER, CONTACT_IS_FRIEND]];
+                               'pending' => false, 'archive' => false, 'rel' => [Contact::FOLLOWER, Contact::FRIEND]];
+
                        $r2 = DBA::toArray(DBA::select('contact', ['id', 'name', 'network'], $condition));
 
                        $r = array_merge($r2, $r1);
index 890d06682678706d643da50c06a2a99f8960d92f..b3af0b7018ac77b6ddc70e039f2f7e82bb248814 100644 (file)
@@ -68,9 +68,10 @@ 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_IS_FOLLOWER)) {
+               if ($contact['archive'] || ($contact["network"] == NETWORK_DIASPORA) || ($contact["rel"] == Contact::FOLLOWER)) {
                        $last_updated = PortableContact::lastUpdated($contact["url"], true);
                        $updated = DateTimeFormat::utcNow();
+
                        if ($last_updated) {
                                logger('Contact '.$contact['id'].' had last update on '.$last_updated, LOGGER_DEBUG);
 
@@ -87,6 +88,7 @@ class OnePoll
                                Contact::markForArchival($contact);
                                logger('Contact '.$contact['id'].' is marked for archival', LOGGER_DEBUG);
                        }
+
                        return;
                }
 
@@ -197,7 +199,6 @@ class OnePoll
 
                        logger('handshake with url ' . $url . ' returns xml: ' . $handshake_xml, LOGGER_DATA);
 
-
                        if (!strlen($handshake_xml) || ($html_code >= 400) || !$html_code) {
                                logger("$url appears to be dead - marking for death ");
 
@@ -296,7 +297,7 @@ class OnePoll
                        // Will only do this once per notify-enabled OStatus contact
                        // or if relationship changes
 
-                       $stat_writeable = ((($contact['notify']) && ($contact['rel'] == CONTACT_IS_FOLLOWER || $contact['rel'] == CONTACT_IS_FRIEND)) ? 1 : 0);
+                       $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) {
@@ -310,7 +311,7 @@ class OnePoll
 
                        // Are we allowed to import from this person?
 
-                       if ($contact['rel'] == CONTACT_IS_FOLLOWER || $contact['blocked']) {
+                       if ($contact['rel'] == Contact::FOLLOWER || $contact['blocked']) {
                                // set the last-update so we don't keep polling
                                DBA::update('contact', ['last-update' => DateTimeFormat::utcNow()], ['id' => $contact['id']]);
                                return;
@@ -330,7 +331,6 @@ class OnePoll
                        $xml = $ret['body'];
 
                } elseif ($contact['network'] === NETWORK_MAIL) {
-
                        logger("Mail: Fetching for ".$contact['addr'], LOGGER_DEBUG);
 
                        $mail_disabled = ((function_exists('imap_open') && (! Config::get('system', 'imap_disabled'))) ? 0 : 1);
@@ -371,6 +371,7 @@ class OnePoll
                                        logger("Mail: Parsing ".count($msgs)." mails from ".$contact['addr']." for ".$mailconf['user'], LOGGER_DEBUG);
 
                                        $metas = Email::messageMeta($mbox, implode(',', $msgs));
+
                                        if (count($metas) != count($msgs)) {
                                                logger("for " . $mailconf['user'] . " there are ". count($msgs) . " messages but received " . count($metas) . " metas", LOGGER_DEBUG);
                                        } else {
@@ -602,7 +603,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_IS_FOLLOWER) || $contact['network'] == NETWORK_FEED)) {
+                       if (strlen($hub) && $hub_update && (($contact['rel'] != Contact::FOLLOWER) || $contact['network'] == NETWORK_FEED)) {
                                logger('hub ' . $hubmode . ' : ' . $hub . ' contact name : ' . $contact['name'] . ' local user : ' . $importer['name']);
                                $hubs = explode(',', $hub);
                                if (count($hubs)) {