]> git.mxchange.org Git - friendica.git/blobdiff - include/dfrn.php
added more spaces #3254
[friendica.git] / include / dfrn.php
index 1240228f06f19bd55d67608499c393dba606835d..8b230f03d9d085b852ac73898f9d4ea911957628 100644 (file)
@@ -217,7 +217,7 @@ class dfrn {
                );
 
                if (!dbm::is_result($r)) {
-                       logger("Query failed to execute, no result returned in " . __FUNCTION__);
+                       /// @TODO Some logging?
                        killme();
                }
 
@@ -870,7 +870,7 @@ class dfrn {
 
                // The signed text contains the content in Markdown, the sender handle and the signatur for the content
                // It is needed for relayed comments to Diaspora.
-               if ($item['signed_text']) {
+               if($item['signed_text']) {
                        $sign = base64_encode(json_encode(array('signed_text' => $item['signed_text'],'signature' => $item['signature'],'signer' => $item['signer'])));
                        xml::add_element($doc, $entry, "dfrn:diaspora_signature", $sign);
                }
@@ -967,8 +967,8 @@ class dfrn {
                $rino = intval($rino);
 
                // use RINO1 if mcrypt isn't installed and RINO2 was selected
-               if ($rino == 2 and !function_exists('mcrypt_create_iv')) {
-                       $rino = 1;
+               if ($rino==2 and !function_exists('mcrypt_create_iv')) {
+                       $rino=1;
                }
 
                logger("Local rino version: ". $rino, LOGGER_DEBUG);
@@ -1095,7 +1095,7 @@ class dfrn {
                }
 
 
-               if ($rino > 0 && $rino_remote_version > 0 && (! $dissolve)) {
+               if ($rino>0 && $rino_remote_version>0 && (! $dissolve)) {
                        logger('rino version: '. $rino_remote_version);
 
                        switch($rino_remote_version) {
@@ -1137,9 +1137,9 @@ class dfrn {
 
 
                        if ($dfrn_version >= 2.1) {
-                               if (($contact['duplex'] && strlen($contact['pubkey']))
+                               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_IS_SHARING && strlen($contact['pubkey'])))
 
                                        openssl_public_encrypt($key,$postvars['key'],$contact['pubkey']);
                                } else {
@@ -1182,7 +1182,7 @@ class dfrn {
                        return 3;
                }
 
-               if ($contact['term-date'] != '0000-00-00 00:00:00') {
+               if ($contact['term-date'] > NULL_DATE) {
                        logger("dfrn_deliver: $url back from the dead - removing mark for death");
                        require_once('include/Contact.php');
                        unmark_for_death($contact);
@@ -1277,7 +1277,7 @@ class dfrn {
                        $href = "";
                        $width = 0;
                        foreach ($avatar->attributes AS $attributes) {
-                               /// @TODO Rewrite these similar if () to one switch
+                               /// @TODO Rewrite these similar if() to one switch
                                if ($attributes->name == "href") {
                                        $href = $attributes->textContent;
                                }
@@ -1608,9 +1608,8 @@ class dfrn {
                        dbesc(normalise_link($suggest["url"])),
                        intval($suggest["uid"])
                );
-
+               /// @TODO Really abort on valid result??? Maybe missed ! here?
                if (dbm::is_result($r)) {
-                       // Has already friend matching description
                        return false;
                }
 
@@ -1731,7 +1730,6 @@ class dfrn {
                        intval($importer["importer_uid"]));
 
                if (!dbm::is_result($r)) {
-                       /// @todo Don't die quietly
                        killme();
                }
 
@@ -1811,10 +1809,8 @@ class dfrn {
                                                $n, dbesc($f[1]),
                                                $n, dbesc($f[0]),
                                                intval($importer["importer_uid"]));
-
-                               if ($x === false) {
-                                       return false;
-                               }
+                                       if ($x === false)
+                                               return false;
                        }
                }
 
@@ -1840,7 +1836,7 @@ class dfrn {
                if (edited_timestamp_is_newer($current, $item)) {
 
                        // do not accept (ignore) an earlier edit than one we currently have.
-                       if (datetime_convert("UTC","UTC",$item["edited"]) < $current["edited"])
+                       if(datetime_convert("UTC","UTC",$item["edited"]) < $current["edited"])
                                return(false);
 
                        $r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `tag` = '%s', `edited` = '%s', `changed` = '%s' WHERE `uri` = '%s' AND `uid` = %d",
@@ -1891,7 +1887,7 @@ class dfrn {
                if ($item["parent-uri"] != $item["uri"]) {
                        $community = false;
 
-                       if ($importer["page-flags"] == PAGE_COMMUNITY || $importer["page-flags"] == PAGE_PRVGROUP) {
+                       if($importer["page-flags"] == PAGE_COMMUNITY || $importer["page-flags"] == PAGE_PRVGROUP) {
                                $sql_extra = "";
                                $community = true;
                                logger("possible community action");
@@ -1978,7 +1974,7 @@ class dfrn {
                                }
                        }
 
-                       if ($Blink && link_compare($Blink,App::get_baseurl()."/profile/".$importer["nickname"])) {
+                       if($Blink && link_compare($Blink,App::get_baseurl()."/profile/".$importer["nickname"])) {
 
                                // send a notification
                                notification(array(
@@ -2047,7 +2043,7 @@ class dfrn {
                                return false;
                        }
                } else {
-                       if (($item["verb"] == ACTIVITY_LIKE)
+                       if(($item["verb"] == ACTIVITY_LIKE)
                                || ($item["verb"] == ACTIVITY_DISLIKE)
                                || ($item["verb"] == ACTIVITY_ATTEND)
                                || ($item["verb"] == ACTIVITY_ATTENDNO)
@@ -2126,7 +2122,7 @@ class dfrn {
                $title = "";
                foreach ($links AS $link) {
                        foreach ($link->attributes AS $attributes) {
-                               /// @TODO Rewrite these repeated (same) if () statements to a switch()
+                               /// @TODO Rewrite these repeated (same) if() statements to a switch()
                                if ($attributes->name == "href") {
                                        $href = $attributes->textContent;
                                }
@@ -2374,7 +2370,7 @@ class dfrn {
                        // When activated, forums don't work.
                        // And: Why should we disallow commenting by followers?
                        // the behaviour is now similar to the Diaspora part.
-                       //if ($importer["rel"] == CONTACT_IS_FOLLOWER) {
+                       //if($importer["rel"] == CONTACT_IS_FOLLOWER) {
                        //      logger("Contact ".$importer["id"]." is only follower. Quitting", LOGGER_DEBUG);
                        //      return;
                        //}
@@ -2423,7 +2419,7 @@ class dfrn {
 
                // Update content if 'updated' changes
                if (dbm::is_result($current)) {
-                       if (self::update_content($r[0], $item, $importer, $entrytype))
+                       if (self::update_content($r[0], $item, $importer, $entrytype)) {
                                logger("Item ".$item["uri"]." was updated.", LOGGER_DEBUG);
                        } else {
                                logger("Item ".$item["uri"]." already existed.", LOGGER_DEBUG);
@@ -2496,7 +2492,7 @@ class dfrn {
 
                        logger("Item was stored with id ".$posted_id, LOGGER_DEBUG);
 
-                       if (stristr($item["verb"],ACTIVITY_POKE))
+                       if(stristr($item["verb"],ACTIVITY_POKE))
                                self::do_poke($item, $importer, $posted_id);
                }
        }
@@ -2598,7 +2594,7 @@ class dfrn {
                                }
                        }
 
-                       if ($entrytype == DFRN_TOP_LEVEL) {
+                       if($entrytype == DFRN_TOP_LEVEL) {
                                $r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s',
                                                `body` = '', `title` = ''
                                        WHERE `parent-uri` = '%s' AND `uid` = %d",
@@ -2622,7 +2618,7 @@ class dfrn {
                                create_tags_from_itemuri($uri, $importer["uid"]);
                                create_files_from_itemuri($uri, $importer["uid"]);
                                update_thread_uri($uri, $importer["importer_uid"]);
-                               if ($item["last-child"]) {
+                               if($item["last-child"]) {
                                        // ensure that last-child is set in case the comment that had it just got wiped.
                                        q("UPDATE `item` SET `last-child` = 0, `changed` = '%s' WHERE `parent-uri` = '%s' AND `uid` = %d ",
                                                dbesc(datetime_convert()),
@@ -2643,7 +2639,7 @@ class dfrn {
                                }
                                // if this is a relayed delete, propagate it to other recipients
 
-                               if ($entrytype == DFRN_REPLY_RC) {
+                               if($entrytype == DFRN_REPLY_RC) {
                                        logger("Notifying followers about deletion of post ".$item["id"], LOGGER_DEBUG);
                                        proc_run(PRIORITY_HIGH, "include/notifier.php","drop", $item["id"]);
                                }
@@ -2663,7 +2659,7 @@ class dfrn {
                if ($xml == "")
                        return;
 
-               if ($importer["readonly"]) {
+               if($importer["readonly"]) {
                        // We aren't receiving stuff from this person. But we will quietly ignore them
                        // rather than a blatant "go away" message.
                        logger('ignoring contact '.$importer["id"]);
@@ -2696,14 +2692,12 @@ class dfrn {
                // Update the contact table if the data has changed
 
                // The "atom:author" is only present in feeds
-               if ($xpath->query("/atom:feed/atom:author")->length > 0) {
+               if ($xpath->query("/atom:feed/atom:author")->length > 0)
                        self::fetchauthor($xpath, $doc->firstChild, $importer, "atom:author", false, $xml);
-               }
 
                // Only the "dfrn:owner" in the head section contains all data
-               if ($xpath->query("/atom:feed/dfrn:owner")->length > 0) {
+               if ($xpath->query("/atom:feed/dfrn:owner")->length > 0)
                        self::fetchauthor($xpath, $doc->firstChild, $importer, "dfrn:owner", false, $xml);
-               }
 
                logger("Import DFRN message for user ".$importer["uid"]." from contact ".$importer["id"], LOGGER_DEBUG);
 
@@ -2711,24 +2705,22 @@ class dfrn {
                if ($xpath->query("/atom:feed/dfrn:account_type")->length > 0) {
                        $accounttype = intval($xpath->evaluate("/atom:feed/dfrn:account_type/text()", $context)->item(0)->nodeValue);
 
-                       if ($accounttype != $importer["contact-type"]) {
+                       if ($accounttype != $importer["contact-type"])
                                q("UPDATE `contact` SET `contact-type` = %d WHERE `id` = %d",
                                        intval($accounttype),
                                        intval($importer["id"])
                                );
-                       }
                }
 
                // is it a public forum? Private forums aren't supported with this method
                // This is deprecated since 3.5.1
                $forum = intval($xpath->evaluate("/atom:feed/dfrn:community/text()", $context)->item(0)->nodeValue);
 
-               if ($forum != $importer["forum"]) {
+               if ($forum != $importer["forum"])
                        q("UPDATE `contact` SET `forum` = %d WHERE `forum` != %d AND `id` = %d",
                                intval($forum), intval($forum),
                                intval($importer["id"])
                        );
-               }
 
                $mails = $xpath->query("/atom:feed/dfrn:mail");
                foreach ($mails AS $mail) {