]> git.mxchange.org Git - friendica.git/blobdiff - mod/dfrn_confirm.php
associative array + adding mysql value + removing table header
[friendica.git] / mod / dfrn_confirm.php
index a2871b3b39e751ecc78f8b30fe356605e1d274dc..41b5e0ef54f16587dae6e2935ad40916b801e519 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.
@@ -201,11 +202,11 @@ function dfrn_confirm_post(App $a, $handsfree = null)
                                $params['duplex'] = 1;
                        }
 
-                       if ($user['page-flags'] == PAGE_COMMUNITY) {
+                       if ($user['page-flags'] == Contact::PAGE_COMMUNITY) {
                                $params['page'] = 1;
                        }
 
-                       if ($user['page-flags'] == PAGE_PRVGROUP) {
+                       if ($user['page-flags'] == Contact::PAGE_PRVGROUP) {
                                $params['page'] = 2;
                        }
 
@@ -246,6 +247,7 @@ function dfrn_confirm_post(App $a, $handsfree = null)
 
                        if (stristr($res, "<status") === false) {
                                // wrong xml! stop here!
+                               logger('Unexpected response posting to ' . $dfrn_confirm);
                                notice(L10n::t('Unexpected response from remote site: ') . EOL . htmlspecialchars($res) . EOL);
                                return;
                        }
@@ -304,13 +306,14 @@ 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;
+               if ($network === Protocol::DFRN) {
+                       $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;
                        }
 
@@ -328,12 +331,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,14 +348,14 @@ 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_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,8 +394,8 @@ 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 (DBA::isResult($contact) && ($contact['network'] === NETWORK_DIASPORA)) {
+               if ((isset($new_relation) && $new_relation == Contact::FRIEND)) {
+                       if (DBA::isResult($contact) && ($contact['network'] === Protocol::DIASPORA)) {
                                $ret = Diaspora::sendShare($user, $contact);
                                logger('share returns: ' . $ret);
                        }
@@ -547,12 +550,13 @@ 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;
                }
 
@@ -573,7 +577,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
@@ -598,7 +602,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'],