Merge remote-tracking branch 'upstream/develop' into rewrites/coding-convention-split2-6-2

Signed-off-by: Roland Häder <roland@mxchange.org>
This commit is contained in:
Roland Häder 2017-06-13 23:26:06 +02:00
commit 4e49939421
No known key found for this signature in database
GPG key ID: B72F8185C6C7BD78
165 changed files with 63565 additions and 40577 deletions

View file

@ -416,7 +416,7 @@ class Diaspora {
$fields = $postdata['fields'];
// Is it a an action (comment, like, ...) for our own post?
if (isset($fields->parent_guid) AND !$postdata["relayed"]) {
if (isset($fields->parent_guid) && !$postdata["relayed"]) {
$guid = notags(unxmlify($fields->parent_guid));
$importer = self::importer_for_guid($guid);
if (is_array($importer)) {
@ -612,9 +612,9 @@ class Diaspora {
}
}
if (($fieldname == "author_signature") AND ($entry != ""))
if (($fieldname == "author_signature") && ($entry != ""))
$author_signature = base64_decode($entry);
elseif (($fieldname == "parent_author_signature") AND ($entry != ""))
elseif (($fieldname == "parent_author_signature") && ($entry != ""))
$parent_author_signature = base64_decode($entry);
elseif (!in_array($fieldname, array("author_signature", "parent_author_signature", "target_author_signature"))) {
if ($signed_data != "") {
@ -624,7 +624,7 @@ class Diaspora {
$signed_data .= $entry;
}
if (!in_array($fieldname, array("parent_author_signature", "target_author_signature")) OR
if (!in_array($fieldname, array("parent_author_signature", "target_author_signature")) ||
($orig_type == "relayable_retraction"))
xml::copy($entry, $fields, $fieldname);
}
@ -714,13 +714,13 @@ class Diaspora {
$update = true;
}
if (!$person OR $update) {
if (!$person || $update) {
logger("create or refresh", LOGGER_DEBUG);
$r = probe_url($handle, PROBE_DIASPORA);
// Note that Friendica contacts will return a "Diaspora person"
// if Diaspora connectivity is enabled on their server
if ($r AND ($r["network"] === NETWORK_DIASPORA)) {
if ($r && ($r["network"] === NETWORK_DIASPORA)) {
self::add_fcontact($r, $update);
$person = $r;
}
@ -1151,7 +1151,7 @@ class Diaspora {
// Fetch the author - for the old and the new Diaspora version
if ($source_xml->post->status_message->diaspora_handle)
$author = (string)$source_xml->post->status_message->diaspora_handle;
elseif ($source_xml->author AND ($source_xml->getName() == "status_message"))
elseif ($source_xml->author && ($source_xml->getName() == "status_message"))
$author = (string)$source_xml->author;
// If this isn't a "status_message" then quit
@ -1403,7 +1403,7 @@ class Diaspora {
$message_id = self::message_exists($importer["uid"], $guid);
if ($message_id) {
return $message_id;
return true;
}
$parent_item = self::parent_item($importer["uid"], $parent_guid, $author, $contact);
@ -1462,12 +1462,16 @@ class Diaspora {
$message_id = item_store($datarray);
if ($message_id <= 0) {
return false;
}
if ($message_id) {
logger("Stored comment ".$datarray["guid"]." with message id ".$message_id, LOGGER_DEBUG);
}
// If we are the origin of the parent we store the original data and notify our followers
if ($message_id AND $parent_item["origin"]) {
if ($message_id && $parent_item["origin"]) {
// Formerly we stored the signed text, the signature and the author in different fields.
// We now store the raw data so that we are more flexible.
@ -1480,7 +1484,7 @@ class Diaspora {
proc_run(PRIORITY_HIGH, "include/notifier.php", "comment-import", $message_id);
}
return $message_id;
return true;
}
/**
@ -1631,7 +1635,7 @@ class Diaspora {
}
if (!$conversation) {
logger("unable to create conversation.");
return;
return false;
}
foreach ($messages as $mesg)
@ -1709,7 +1713,7 @@ class Diaspora {
$message_id = self::message_exists($importer["uid"], $guid);
if ($message_id)
return $message_id;
return true;
$parent_item = self::parent_item($importer["uid"], $parent_guid, $author, $contact);
if (!$parent_item)
@ -1762,11 +1766,16 @@ class Diaspora {
$message_id = item_store($datarray);
if ($message_id)
if ($message_id <= 0) {
return false;
}
if ($message_id) {
logger("Stored like ".$datarray["guid"]." with message id ".$message_id, LOGGER_DEBUG);
}
// If we are the origin of the parent we store the original data and notify our followers
if ($message_id AND $parent_item["origin"]) {
if ($message_id && $parent_item["origin"]) {
// Formerly we stored the signed text, the signature and the author in different fields.
// We now store the raw data so that we are more flexible.
@ -1779,7 +1788,7 @@ class Diaspora {
proc_run(PRIORITY_HIGH, "include/notifier.php", "comment-import", $message_id);
}
return $message_id;
return true;
}
/**
@ -2115,7 +2124,7 @@ class Diaspora {
// perhaps we were already sharing with this person. Now they're sharing with us.
// That makes us friends.
if ($contact) {
if ($following AND $sharing) {
if ($following && $sharing) {
logger("Author ".$author." (Contact ".$contact["id"].") wants to have a bidirectional conection.", LOGGER_DEBUG);
self::receive_request_make_friend($importer, $contact);
@ -2138,17 +2147,17 @@ class Diaspora {
}
}
if (!$following AND $sharing AND in_array($importer["page-flags"], array(PAGE_SOAPBOX, PAGE_NORMAL))) {
if (!$following && $sharing && in_array($importer["page-flags"], array(PAGE_SOAPBOX, PAGE_NORMAL))) {
logger("Author ".$author." wants to share with us - but doesn't want to listen. Request is ignored.", LOGGER_DEBUG);
return false;
} elseif (!$following AND !$sharing) {
} elseif (!$following && !$sharing) {
logger("Author ".$author." doesn't want anything - and we don't know the author. Request is ignored.", LOGGER_DEBUG);
return false;
} elseif (!$following AND $sharing) {
} elseif (!$following && $sharing) {
logger("Author ".$author." wants to share with us.", LOGGER_DEBUG);
} elseif ($following AND $sharing) {
} elseif ($following && $sharing) {
logger("Author ".$author." wants to have a bidirectional conection.", LOGGER_DEBUG);
} elseif ($following AND !$sharing) {
} elseif ($following && !$sharing) {
logger("Author ".$author." wants to listen to us.", LOGGER_DEBUG);
}
@ -2226,9 +2235,9 @@ class Diaspora {
// 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) AND $sharing AND $following)
if (($importer["page-flags"] == PAGE_FREELOVE) && $sharing && $following)
$new_relation = CONTACT_IS_FRIEND;
elseif (($importer["page-flags"] == PAGE_FREELOVE) AND $sharing)
elseif (($importer["page-flags"] == PAGE_FREELOVE) && $sharing)
$new_relation = CONTACT_IS_SHARING;
else
$new_relation = CONTACT_IS_FOLLOWER;
@ -2356,7 +2365,7 @@ class Diaspora {
$message_id = self::message_exists($importer["uid"], $guid);
if ($message_id) {
return $message_id;
return true;
}
$original_item = self::original_item($root_guid, $root_author, $author);
@ -2407,9 +2416,10 @@ class Diaspora {
if ($message_id) {
logger("Stored reshare ".$datarray["guid"]." with message id ".$message_id, LOGGER_DEBUG);
return true;
} else {
return false;
}
return $message_id;
}
/**
@ -2450,7 +2460,7 @@ class Diaspora {
intval($r[0]["parent"]));
// Only delete it if the parent author really fits
if (!link_compare($p[0]["author-link"], $contact["url"]) AND !link_compare($r[0]["author-link"], $contact["url"])) {
if (!link_compare($p[0]["author-link"], $contact["url"]) && !link_compare($r[0]["author-link"], $contact["url"])) {
logger("Thread author ".$p[0]["author-link"]." and item author ".$r[0]["author-link"]." don't fit to expected contact ".$contact["url"], LOGGER_DEBUG);
return false;
}
@ -2487,7 +2497,7 @@ class Diaspora {
$target_type = notags(unxmlify($data->target_type));
$contact = self::contact_by_handle($importer["uid"], $sender);
if (!$contact AND (in_array($target_type, array("Contact", "Person")))) {
if (!$contact && (in_array($target_type, array("Contact", "Person")))) {
logger("cannot find contact for sender: ".$sender." and user ".$importer["uid"]);
return false;
}
@ -2540,7 +2550,7 @@ class Diaspora {
$message_id = self::message_exists($importer["uid"], $guid);
if ($message_id) {
return $message_id;
return true;
}
$address = array();
@ -2615,7 +2625,7 @@ class Diaspora {
$datarray["location"] = $address["address"];
}
if (isset($address["lat"]) AND isset($address["lng"])) {
if (isset($address["lat"]) && isset($address["lng"])) {
$datarray["coord"] = $address["lat"]." ".$address["lng"];
}
@ -2624,9 +2634,10 @@ class Diaspora {
if ($message_id) {
logger("Stored item ".$datarray["guid"]." with message id ".$message_id, LOGGER_DEBUG);
return true;
} else {
return false;
}
return $message_id;
}
/* ************************************************************************************** *
@ -2927,7 +2938,7 @@ class Diaspora {
// The message could not be delivered. We mark the contact as "dead"
mark_for_death($contact);
}
} elseif (($return_code >= 200) AND ($return_code <= 299)) {
} elseif (($return_code >= 200) && ($return_code <= 299)) {
// We successfully delivered a message, the contact is alive
unmark_for_death($contact);
}
@ -3037,7 +3048,7 @@ class Diaspora {
// Skip if it isn't a pure repeated messages
// Does it start with a share?
if ((strpos($body, "[share") > 0) AND $complete)
if ((strpos($body, "[share") > 0) && $complete)
return(false);
// Does it end with a share?
@ -3085,7 +3096,7 @@ class Diaspora {
$ret= array();
$ret["root_handle"] = preg_replace("=https?://(.*)/u/(.*)=ism", "$2@$1", $profile);
if (($ret["root_handle"] == $profile) OR ($ret["root_handle"] == ""))
if (($ret["root_handle"] == $profile) || ($ret["root_handle"] == ""))
return(false);
$link = "";
@ -3098,7 +3109,7 @@ class Diaspora {
$link = $matches[1];
$ret["root_guid"] = preg_replace("=https?://(.*)/posts/(.*)=ism", "$2", $link);
if (($ret["root_guid"] == $link) OR (trim($ret["root_guid"]) == ""))
if (($ret["root_guid"] == $link) || (trim($ret["root_guid"]) == ""))
return(false);
return($ret);
@ -3158,7 +3169,7 @@ class Diaspora {
if ($event['start']) {
$eventdata['start'] = datetime_convert($eventdata['timezone'], "UTC", $event['start'], $mask);
}
if ($event['finish'] AND !$event['nofinish']) {
if ($event['finish'] && !$event['nofinish']) {
$eventdata['end'] = datetime_convert($eventdata['timezone'], "UTC", $event['finish'], $mask);
}
if ($event['summary']) {
@ -3204,7 +3215,7 @@ class Diaspora {
$created = datetime_convert("UTC", "UTC", $item["created"], 'Y-m-d\TH:i:s\Z');
// Detect a share element and do a reshare
if (!$item['private'] AND ($ret = self::is_reshare($item["body"]))) {
if (!$item['private'] && ($ret = self::is_reshare($item["body"]))) {
$message = array("root_diaspora_id" => $ret["root_handle"],
"root_guid" => $ret["root_guid"],
"guid" => $item["guid"],
@ -3254,7 +3265,7 @@ class Diaspora {
"provider_display_name" => $item["app"]);
// Diaspora rejects messages when they contain a location without "lat" or "lng"
if (!isset($location["lat"]) OR !isset($location["lng"])) {
if (!isset($location["lat"]) || !isset($location["lng"])) {
unset($message["location"]);
}
@ -3529,7 +3540,7 @@ class Diaspora {
// Old way - is used by the internal Friendica functions
/// @todo Change all signatur storing functions to the new format
if ($signature['signed_text'] AND $signature['signature'] AND $signature['signer'])
if ($signature['signed_text'] && $signature['signature'] && $signature['signer'])
$message = self::message_from_signature($item, $signature);
else {// New way
$msg = json_decode($signature['signed_text'], true);
@ -3581,7 +3592,7 @@ class Diaspora {
$target_type = "StatusMessage";
}
if ($relay AND ($item["uri"] !== $item["parent-uri"]))
if ($relay && ($item["uri"] !== $item["parent-uri"]))
$signature = "parent_author_signature";
else
$signature = "target_author_signature";
@ -3761,7 +3772,7 @@ class Diaspora {
public static function store_like_signature($contact, $post_id) {
// Is the contact the owner? Then fetch the private key
if (!$contact['self'] OR ($contact['uid'] == 0)) {
if (!$contact['self'] || ($contact['uid'] == 0)) {
logger("No owner post, so not storing signature", LOGGER_DEBUG);
return false;
}