src Standards

This basically completes coding standards changes for the entire src directory, with the exception of App.php
This commit is contained in:
Adam Magness 2017-11-23 14:01:58 -05:00
parent 057984c69e
commit 609a4de5d0
15 changed files with 370 additions and 338 deletions

View file

@ -4291,7 +4291,7 @@ function api_share_as_retweet(&$item)
{
$body = trim($item["body"]);
if (Diaspora::is_reshare($body, false)===false) {
if (Diaspora::isReshare($body, false)===false) {
return false;
}
@ -4299,7 +4299,7 @@ function api_share_as_retweet(&$item)
$attributes = preg_replace("/\[share(.*?)\]\s?(.*?)\s?\[\/share\]\s?/ism", "$1", $body);
/*
* Skip if there is no shared message in there
* we already checked this in diaspora::is_reshare()
* we already checked this in diaspora::isReshare()
* but better one more than one less...
*/
if ($body == $attributes) {

View file

@ -272,7 +272,7 @@ function new_contact($uid, $url, $interactive = false, $network = '') {
}
if ($contact['network'] == NETWORK_DIASPORA) {
$ret = Diaspora::send_share($a->user,$contact);
$ret = Diaspora::sendShare($a->user, $contact);
logger('share returns: '.$ret);
}
}

View file

@ -247,7 +247,7 @@ EOT;
}
// Save the author information for the like in case we need to relay to Diaspora
Diaspora::store_like_signature($item_contact, $new_item_id);
Diaspora::storeLikeSignature($item_contact, $new_item_id);
$new_item['id'] = $new_item_id;

View file

@ -440,7 +440,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
if ((isset($new_relation) && $new_relation == CONTACT_IS_FRIEND)) {
if (($contact) && ($contact['network'] === NETWORK_DIASPORA)) {
$ret = Diaspora::send_share($user[0],$r[0]);
$ret = Diaspora::sendShare($user[0],$r[0]);
logger('share returns: ' . $ret);
}

View file

@ -175,7 +175,7 @@ function dfrn_notify_post(App $a) {
*we got a key. old code send only the key, without RINO version.
* we assume RINO 1 if key and no RINO version
*/
$data = DFRN::aes_decrypt(hex2bin($data), $final_key);
$data = DFRN::aesDecrypt(hex2bin($data), $final_key);
break;
case 2:
try {

View file

@ -68,12 +68,12 @@ function fetch_init(App $a)
}
$user = $r[0];
$status = Diaspora::build_status($item[0], $user);
$xml = Diaspora::build_post_xml($status["type"], $status["message"]);
$status = Diaspora::buildStatus($item[0], $user);
$xml = Diaspora::buildPostXml($status["type"], $status["message"]);
// Send the envelope
header("Content-Type: application/magic-envelope+xml; charset=utf-8");
echo Diaspora::build_magic_envelope($xml, $user);
echo Diaspora::buildMagicEnvelope($xml, $user);
killme();
}

View file

@ -985,7 +985,7 @@ function item_post(App $a) {
// Store the comment signature information in case we need to relay to Diaspora
Diaspora::store_comment_signature($datarray, $author, ($self ? $user['prvkey'] : false), $post_id);
Diaspora::storeCommentSignature($datarray, $author, ($self ? $user['prvkey'] : false), $post_id);
} else {
$parent = $post_id;

View file

@ -58,8 +58,8 @@ function p_init($a){
}
$user = $r[0];
$status = Diaspora::build_status($item[0], $user);
$xml = Diaspora::build_post_xml($status["type"], $status["message"]);
$status = Diaspora::buildStatus($item[0], $user);
$xml = Diaspora::buildPostXml($status["type"], $status["message"]);
header("Content-Type: application/xml; charset=utf-8");
echo $xml;

View file

@ -49,14 +49,14 @@ function receive_post(App $a) {
}
logger('mod-diaspora: message is in the new format', LOGGER_DEBUG);
$msg = Diaspora::decode_raw($importer, $postdata);
$msg = Diaspora::decodeRaw($importer, $postdata);
} else {
logger('mod-diaspora: decode message in the old format', LOGGER_DEBUG);
$msg = Diaspora::decode($importer, $xml);
if ($public && !$msg) {
logger('mod-diaspora: decode message in the new format', LOGGER_DEBUG);
$msg = Diaspora::decode_raw($importer, $xml);
$msg = Diaspora::decodeRaw($importer, $xml);
}
}
@ -72,7 +72,7 @@ function receive_post(App $a) {
$ret = true;
if ($public) {
Diaspora::dispatch_public($msg);
Diaspora::dispatchPublic($msg);
} else {
$ret = Diaspora::dispatch($importer, $msg);
}

View file

@ -60,7 +60,7 @@ class DFRN
$doc = new DOMDocument('1.0', 'utf-8');
$doc->formatOutput = true;
$root = self::add_header($doc, $owner, "dfrn:owner", "", false);
$root = self::addHeader($doc, $owner, "dfrn:owner", "", false);
if (! count($items)) {
return trim($doc->saveXML());
@ -258,7 +258,7 @@ class DFRN
$author = "author";
}
$root = self::add_header($doc, $owner, $author, $alternatelink, true);
$root = self::addHeader($doc, $owner, $author, $alternatelink, true);
/// @TODO This hook can't work anymore
// call_hooks('atom_feed', $atom);
@ -370,7 +370,7 @@ class DFRN
$root->setAttribute("xmlns:ostatus", NAMESPACE_OSTATUS);
$root->setAttribute("xmlns:statusnet", NAMESPACE_STATUSNET);
//$root = self::add_header($doc, $owner, "dfrn:owner", "", false);
//$root = self::addHeader($doc, $owner, "dfrn:owner", "", false);
foreach ($items as $item) {
$entry = self::entry($doc, $type, $item, $owner, true, 0);
@ -398,7 +398,7 @@ class DFRN
$doc = new DOMDocument('1.0', 'utf-8');
$doc->formatOutput = true;
$root = self::add_header($doc, $owner, "dfrn:owner", "", false);
$root = self::addHeader($doc, $owner, "dfrn:owner", "", false);
$mail = $doc->createElement("dfrn:mail");
$sender = $doc->createElement("dfrn:sender");
@ -411,7 +411,7 @@ class DFRN
XML::addElement($doc, $mail, "dfrn:id", $item['uri']);
XML::addElement($doc, $mail, "dfrn:in-reply-to", $item['parent-uri']);
XML::addElement($doc, $mail, "dfrn:sentdate", datetime_convert('UTC', 'UTC', $item['created'] . '+00:00' , ATOM_TIME));
XML::addElement($doc, $mail, "dfrn:sentdate", datetime_convert('UTC', 'UTC', $item['created'] . '+00:00', ATOM_TIME));
XML::addElement($doc, $mail, "dfrn:subject", $item['title']);
XML::addElement($doc, $mail, "dfrn:content", $item['body']);
@ -434,7 +434,7 @@ class DFRN
$doc = new DOMDocument('1.0', 'utf-8');
$doc->formatOutput = true;
$root = self::add_header($doc, $owner, "dfrn:owner", "", false);
$root = self::addHeader($doc, $owner, "dfrn:owner", "", false);
$suggest = $doc->createElement("dfrn:suggest");
@ -486,7 +486,7 @@ class DFRN
$doc = new DOMDocument('1.0', 'utf-8');
$doc->formatOutput = true;
$root = self::add_header($doc, $owner, "dfrn:owner", "", false);
$root = self::addHeader($doc, $owner, "dfrn:owner", "", false);
$relocate = $doc->createElement("dfrn:relocate");
@ -501,7 +501,7 @@ class DFRN
XML::addElement($doc, $relocate, "dfrn:confirm", $owner['confirm']);
XML::addElement($doc, $relocate, "dfrn:notify", $owner['notify']);
XML::addElement($doc, $relocate, "dfrn:poll", $owner['poll']);
XML::addElement($doc, $relocate, "dfrn:sitepubkey", Config::get('system','site_pubkey'));
XML::addElement($doc, $relocate, "dfrn:sitepubkey", Config::get('system', 'site_pubkey'));
$root->appendChild($relocate);
@ -520,7 +520,7 @@ class DFRN
* @return object XML root object
* @todo Add type-hints
*/
private static function add_header($doc, $owner, $authorelement, $alternatelink = "", $public = false)
private static function addHeader($doc, $owner, $authorelement, $alternatelink = "", $public = false)
{
if ($alternatelink == "") {
@ -579,7 +579,7 @@ class DFRN
XML::addElement($doc, $root, "updated", datetime_convert("UTC", "UTC", "now", ATOM_TIME));
$author = self::add_author($doc, $owner, $authorelement, $public);
$author = self::addAuthor($doc, $owner, $authorelement, $public);
$root->appendChild($author);
return $root;
@ -591,11 +591,12 @@ class DFRN
* @param object $doc XML document
* @param array $owner Owner record
* @param string $authorelement Element name for the author
* @param boolean $public boolean
*
* @return object XML author object
* @todo Add type-hints
*/
private static function add_author($doc, $owner, $authorelement, $public)
private static function addAuthor($doc, $owner, $authorelement, $public)
{
// Is the profile hidden or shouldn't be published in the net? Then add the "hide" element
$r = q(
@ -739,7 +740,7 @@ class DFRN
* @return object XML author object
* @todo Add type-hints
*/
private static function add_entry_author($doc, $element, $contact_url, $item)
private static function addEntryAuthor($doc, $element, $contact_url, $item)
{
$contact = Contact::getDetailsByURL($contact_url, $item["uid"]);
@ -780,7 +781,7 @@ class DFRN
* @return object XML activity object
* @todo Add type-hints
*/
private static function create_activity($doc, $element, $activity)
private static function createActivity($doc, $element, $activity)
{
if ($activity) {
$entry = $doc->createElement($element);
@ -810,7 +811,7 @@ class DFRN
// XML does need a single element as root element so we add a dummy element here
$data = parse_xml_string("<dummy>" . $r->link . "</dummy>", false);
if (is_object($data)) {
foreach ($data->link AS $link) {
foreach ($data->link as $link) {
$attributes = array();
foreach ($link->attributes() as $parameter => $value) {
$attributes[$parameter] = $value;
@ -843,7 +844,7 @@ class DFRN
* @return object XML attachment object
* @todo Add type-hints
*/
private static function get_attachment($doc, $root, $item)
private static function getAttachment($doc, $root, $item)
{
$arr = explode('[/attach],', $item['attach']);
if (count($arr)) {
@ -932,10 +933,10 @@ class DFRN
$htmlbody = bbcode($htmlbody, false, false, 7);
}
$author = self::add_entry_author($doc, "author", $item["author-link"], $item);
$author = self::addEntryAuthor($doc, "author", $item["author-link"], $item);
$entry->appendChild($author);
$dfrnowner = self::add_entry_author($doc, "dfrn:owner", $item["owner-link"], $item);
$dfrnowner = self::addEntryAuthor($doc, "dfrn:owner", $item["owner-link"], $item);
$entry->appendChild($dfrnowner);
if (($item['parent'] != $item['id']) || ($item['parent-uri'] !== $item['uri']) || (($item['thr-parent'] !== '') && ($item['thr-parent'] !== $item['uri']))) {
@ -1041,12 +1042,12 @@ class DFRN
XML::addElement($doc, $entry, "activity:object-type", ACTIVITY_OBJ_COMMENT);
}
$actobj = self::create_activity($doc, "activity:object", $item['object']);
$actobj = self::createActivity($doc, "activity:object", $item['object']);
if ($actobj) {
$entry->appendChild($actobj);
}
$actarg = self::create_activity($doc, "activity:target", $item['target']);
$actarg = self::createActivity($doc, "activity:target", $item['target']);
if ($actarg) {
$entry->appendChild($actarg);
}
@ -1099,7 +1100,7 @@ class DFRN
}
}
self::get_attachment($doc, $entry, $item);
self::getAttachment($doc, $entry, $item);
return $entry;
}
@ -1112,7 +1113,7 @@ class DFRN
*
* @return string encrypted data
*/
private static function aes_encrypt($data, $key)
private static function aesEncrypt($data, $key)
{
return openssl_encrypt($data, 'aes-128-ecb', $key, OPENSSL_RAW_DATA);
}
@ -1125,7 +1126,7 @@ class DFRN
*
* @return string decrypted data
*/
public static function aes_decrypt($encrypted, $key)
public static function aesDecrypt($encrypted, $key)
{
return openssl_decrypt($encrypted, 'aes-128-ecb', $key, OPENSSL_RAW_DATA);
}
@ -1291,7 +1292,7 @@ class DFRN
case 1:
// Deprecated rino version!
$key = openssl_random_pseudo_bytes(16);
$data = self::aes_encrypt($postvars['data'], $key);
$data = self::aesEncrypt($postvars['data'], $key);
break;
case 2:
// RINO 2 based on php-encryption
@ -1392,9 +1393,10 @@ class DFRN
*
* @param array $contact Contact record
* @param string $birthday Birthday of the contact
* @return void
* @todo Add array type-hint for $contact
*/
private static function birthday_event($contact, $birthday)
private static function birthdayEvent($contact, $birthday)
{
// Check for duplicates
$r = q(
@ -1412,7 +1414,7 @@ class DFRN
logger("updating birthday: ".$birthday." for contact ".$contact["id"]);
$bdtext = sprintf(t("%s\'s birthday"), $contact["name"]);
$bdtext2 = sprintf(t("Happy Birthday %s"), " [url=".$contact["url"]."]".$contact["name"]."[/url]") ;
$bdtext2 = sprintf(t("Happy Birthday %s"), " [url=".$contact["url"]."]".$contact["name"]."[/url]");
$r = q(
"INSERT INTO `event` (`uid`,`cid`,`created`,`edited`,`start`,`finish`,`summary`,`desc`,`type`)
@ -1437,6 +1439,7 @@ class DFRN
* @param array $importer Record of the importer user mixed with contact of the content
* @param string $element Element name from which the data is fetched
* @param bool $onlyfetch Should the data only be fetched or should it update the contact record as well
* @param string $xml optional, default empty
*
* @return Returns an array with relevant data of the author
* @todo Find good type-hints for all parameter
@ -1474,10 +1477,10 @@ class DFRN
$avatarlist = array();
/// @todo check if "avatar" or "photo" would be the best field in the specification
$avatars = $xpath->query($element."/atom:link[@rel='avatar']", $context);
foreach ($avatars AS $avatar) {
foreach ($avatars as $avatar) {
$href = "";
$width = 0;
foreach ($avatar->attributes AS $attributes) {
foreach ($avatar->attributes as $attributes) {
/// @TODO Rewrite these similar if () to one switch
if ($attributes->name == "href") {
$href = $attributes->textContent;
@ -1505,14 +1508,14 @@ class DFRN
// When was the last change to name or uri?
$name_element = $xpath->query($element . "/atom:name", $context)->item(0);
foreach ($name_element->attributes AS $attributes) {
foreach ($name_element->attributes as $attributes) {
if ($attributes->name == "updated") {
$poco["name-date"] = $attributes->textContent;
}
}
$link_element = $xpath->query($element . "/atom:link", $context)->item(0);
foreach ($link_element->attributes AS $attributes) {
foreach ($link_element->attributes as $attributes) {
if ($attributes->name == "updated") {
$poco["uri-date"] = $attributes->textContent;
}
@ -1571,7 +1574,7 @@ class DFRN
// Save the keywords into the contact table
$tags = array();
$tagelements = $xpath->evaluate($element . "/poco:tags/text()", $context);
foreach ($tagelements AS $tag) {
foreach ($tagelements as $tag) {
$tags[$tag->nodeValue] = $tag->nodeValue;
}
@ -1608,12 +1611,12 @@ class DFRN
$contact = array_merge($contact, $poco);
if ($old_bdyear != $contact["bdyear"]) {
self::birthday_event($contact, $birthday);
self::birthdayEvent($contact, $birthday);
}
// Get all field names
$fields = array();
foreach ($r[0] AS $field => $data) {
foreach ($r[0] as $field => $data) {
$fields[$field] = $data;
}
@ -1626,14 +1629,14 @@ class DFRN
// Update check for this field has to be done differently
$datefields = array("name-date", "uri-date");
foreach ($datefields AS $field) {
foreach ($datefields as $field) {
if (strtotime($contact[$field]) > strtotime($r[0][$field])) {
logger("Difference for contact " . $contact["id"] . " in field '" . $field . "'. New value: '" . $contact[$field] . "', old value '" . $r[0][$field] . "'", LOGGER_DEBUG);
$update = true;
}
}
foreach ($fields AS $field => $data) {
foreach ($fields as $field => $data) {
if ($contact[$field] != $r[0][$field]) {
logger("Difference for contact " . $contact["id"] . " in field '" . $field . "'. New value: '" . $contact[$field] . "', old value '" . $r[0][$field] . "'", LOGGER_DEBUG);
$update = true;
@ -1692,7 +1695,7 @@ class DFRN
* @return string XML string
* @todo Find good type-hints for all parameter
*/
private static function transform_activity($xpath, $activity, $element)
private static function transformActivity($xpath, $activity, $element)
{
if (!is_object($activity)) {
return "";
@ -1743,9 +1746,10 @@ class DFRN
* @param object $xpath XPath object
* @param object $mail mail elements
* @param array $importer Record of the importer user mixed with contact of the content
* @return void
* @todo Find good type-hints for all parameter
*/
private static function process_mail($xpath, $mail, $importer)
private static function processMail($xpath, $mail, $importer)
{
logger("Processing mails");
@ -1794,9 +1798,10 @@ class DFRN
* @param object $xpath XPath object
* @param object $suggestion suggestion elements
* @param array $importer Record of the importer user mixed with contact of the content
* @return boolean
* @todo Find good type-hints for all parameter
*/
private static function process_suggestion($xpath, $suggestion, $importer)
private static function processSuggestion($xpath, $suggestion, $importer)
{
$a = get_app();
@ -1903,7 +1908,8 @@ class DFRN
intval(0)
);
notification(array(
notification(
array(
"type" => NOTIFY_SUGGEST,
"notify_flags" => $importer["notify-flags"],
"language" => $importer["language"],
@ -1928,9 +1934,10 @@ class DFRN
* @param object $xpath XPath object
* @param object $relocation relocation elements
* @param array $importer Record of the importer user mixed with contact of the content
* @return boolean
* @todo Find good type-hints for all parameter
*/
private static function process_relocation($xpath, $relocation, $importer)
private static function processRelocation($xpath, $relocation, $importer)
{
logger("Processing relocations");
@ -2080,9 +2087,10 @@ class DFRN
* @param array $item the new item record
* @param array $importer Record of the importer user mixed with contact of the content
* @param int $entrytype Is it a toplevel entry, a comment or a relayed comment?
* @return mixed
* @todo set proper type-hints (array?)
*/
private static function update_content($current, $item, $importer, $entrytype)
private static function updateContent($current, $item, $importer, $entrytype)
{
$changed = false;
@ -2137,7 +2145,7 @@ class DFRN
* @return int Is it a toplevel entry, a comment or a relayed comment?
* @todo set proper type-hints (array?)
*/
private static function get_entry_type($importer, $item)
private static function getEntryType($importer, $item)
{
if ($item["parent-uri"] != $item["uri"]) {
$community = false;
@ -2208,9 +2216,10 @@ class DFRN
* @param array $item the new item record
* @param array $importer Record of the importer user mixed with contact of the content
* @param int $posted_id The record number of item record that was just posted
* @return void
* @todo set proper type-hints (array?)
*/
private static function do_poke($item, $importer, $posted_id)
private static function doPoke($item, $importer, $posted_id)
{
$verb = urldecode(substr($item["verb"], strpos($item["verb"], "#")+1));
if (!$verb) {
@ -2245,7 +2254,7 @@ class DFRN
"link" => System::baseUrl()."/display/".urlencode(get_item_guid($posted_id)),
"source_name" => stripslashes($item["author-name"]),
"source_link" => $item["author-link"],
"source_photo" => ((link_compare($item["author-link"],$importer["url"]))
"source_photo" => ((link_compare($item["author-link"], $importer["url"]))
? $importer["thumb"] : $item["author-avatar"]),
"verb" => $item["verb"],
"otype" => "person",
@ -2267,7 +2276,7 @@ class DFRN
* @return bool Should the processing of the entries be continued?
* @todo set proper type-hints (array?)
*/
private static function process_verbs($entrytype, $importer, &$item, &$is_like)
private static function processVerbs($entrytype, $importer, &$item, &$is_like)
{
logger("Process verb ".$item["verb"]." and object-type ".$item["object-type"]." for entrytype ".$entrytype, LOGGER_DEBUG);
@ -2338,7 +2347,6 @@ class DFRN
}
if (($item["verb"] == ACTIVITY_TAG) && ($item["object-type"] == ACTIVITY_OBJ_TAGTERM)) {
$xo = parse_xml_string($item["object"], false);
$xt = parse_xml_string($item["target"], false);
@ -2356,8 +2364,9 @@ class DFRN
// extract tag, if not duplicate, add to parent item
if ($xo->content) {
if (!(stristr($r[0]["tag"],trim($xo->content)))) {
q("UPDATE `item` SET `tag` = '%s' WHERE `id` = %d",
if (!(stristr($r[0]["tag"], trim($xo->content)))) {
q(
"UPDATE `item` SET `tag` = '%s' WHERE `id` = %d",
dbesc($r[0]["tag"] . (strlen($r[0]["tag"]) ? ',' : '') . '#[url=' . $xo->id . ']'. $xo->content . '[/url]'),
intval($r[0]["id"])
);
@ -2375,17 +2384,18 @@ class DFRN
*
* @param object $links link elements
* @param array $item the item record
* @return void
* @todo set proper type-hints
*/
private static function parse_links($links, &$item)
private static function parseLinks($links, &$item)
{
$rel = "";
$href = "";
$type = "";
$length = "0";
$title = "";
foreach ($links AS $link) {
foreach ($link->attributes AS $attributes) {
foreach ($links as $link) {
foreach ($link->attributes as $attributes) {
/// @TODO Rewrite these repeated (same) if () statements to a switch()
if ($attributes->name == "href") {
$href = $attributes->textContent;
@ -2428,9 +2438,11 @@ class DFRN
* @param object $xpath XPath object
* @param object $entry entry elements
* @param array $importer Record of the importer user mixed with contact of the content
* @param object $xml xml
* @return void
* @todo Add type-hints
*/
private static function process_entry($header, $xpath, $entry, $importer, $xml)
private static function processEntry($header, $xpath, $entry, $importer, $xml)
{
logger("Processing entries");
@ -2527,7 +2539,7 @@ class DFRN
$notice_info = $xpath->query("statusnet:notice_info", $entry);
if ($notice_info && ($notice_info->length > 0)) {
foreach ($notice_info->item(0)->attributes AS $attributes) {
foreach ($notice_info->item(0)->attributes as $attributes) {
if ($attributes->name == "source") {
$item["app"] = strip_tags($attributes->textContent);
}
@ -2549,7 +2561,7 @@ class DFRN
}
$object = $xpath->query("activity:object", $entry)->item(0);
$item["object"] = self::transform_activity($xpath, $object, "object");
$item["object"] = self::transformActivity($xpath, $object, "object");
if (trim($item["object"]) != "") {
$r = parse_xml_string($item["object"], false);
@ -2559,14 +2571,14 @@ class DFRN
}
$target = $xpath->query("activity:target", $entry)->item(0);
$item["target"] = self::transform_activity($xpath, $target, "target");
$item["target"] = self::transformActivity($xpath, $target, "target");
$categories = $xpath->query("atom:category", $entry);
if ($categories) {
foreach ($categories AS $category) {
foreach ($categories as $category) {
$term = "";
$scheme = "";
foreach ($category->attributes AS $attributes) {
foreach ($category->attributes as $attributes) {
if ($attributes->name == "term") {
$term = $attributes->textContent;
}
@ -2596,14 +2608,14 @@ class DFRN
$links = $xpath->query("atom:link", $entry);
if ($links) {
self::parse_links($links, $item);
self::parseLinks($links, $item);
}
$item['conversation-uri'] = $xpath->query('ostatus:conversation/text()', $entry)->item(0)->nodeValue;
$conv = $xpath->query('ostatus:conversation', $entry);
if (is_object($conv->item(0))) {
foreach ($conv->item(0)->attributes AS $attributes) {
foreach ($conv->item(0)->attributes as $attributes) {
if ($attributes->name == "ref") {
$item['conversation-uri'] = $attributes->textContent;
}
@ -2618,7 +2630,7 @@ class DFRN
$inreplyto = $xpath->query("thr:in-reply-to", $entry);
if (is_object($inreplyto->item(0))) {
foreach ($inreplyto->item(0)->attributes AS $attributes) {
foreach ($inreplyto->item(0)->attributes as $attributes) {
if ($attributes->name == "ref") {
$item["parent-uri"] = $attributes->textContent;
}
@ -2626,7 +2638,7 @@ class DFRN
}
// Get the type of the item (Top level post, reply or remote reply)
$entrytype = self::get_entry_type($importer, $item);
$entrytype = self::getEntryType($importer, $item);
// Now assign the rest of the values that depend on the type of the message
if (in_array($entrytype, array(DFRN_REPLY, DFRN_REPLY_RC))) {
@ -2699,14 +2711,14 @@ class DFRN
}
}
if (!self::process_verbs($entrytype, $importer, $item, $is_like)) {
logger("Exiting because 'process_verbs' told us so", LOGGER_DEBUG);
if (!self::processVerbs($entrytype, $importer, $item, $is_like)) {
logger("Exiting because 'processVerbs' told us so", LOGGER_DEBUG);
return;
}
// Update content if 'updated' changes
if (DBM::is_result($current)) {
if (self::update_content($r[0], $item, $importer, $entrytype)) {
if (self::updateContent($r[0], $item, $importer, $entrytype)) {
logger("Item ".$item["uri"]." was updated.", LOGGER_DEBUG);
} else {
logger("Item ".$item["uri"]." already existed.", LOGGER_DEBUG);
@ -2783,8 +2795,9 @@ class DFRN
logger("Item was stored with id ".$posted_id, LOGGER_DEBUG);
if (stristr($item["verb"],ACTIVITY_POKE))
self::do_poke($item, $importer, $posted_id);
if (stristr($item["verb"], ACTIVITY_POKE)) {
self::doPoke($item, $importer, $posted_id);
}
}
}
@ -2794,13 +2807,14 @@ class DFRN
* @param object $xpath XPath object
* @param object $deletion deletion elements
* @param array $importer Record of the importer user mixed with contact of the content
* @return void
* @todo set proper type-hints
*/
private static function process_deletion($xpath, $deletion, $importer)
private static function processDeletion($xpath, $deletion, $importer)
{
logger("Processing deletions");
foreach ($deletion->attributes AS $attributes) {
foreach ($deletion->attributes as $attributes) {
if ($attributes->name == "ref") {
$uri = $attributes->textContent;
}
@ -2832,7 +2846,7 @@ class DFRN
} else {
$item = $r[0];
$entrytype = self::get_entry_type($importer, $item);
$entrytype = self::getEntryType($importer, $item);
if (!$item["deleted"]) {
logger('deleting item '.$item["id"].' uri='.$uri, LOGGER_DEBUG);
@ -2846,7 +2860,6 @@ class DFRN
}
if (($item["verb"] == ACTIVITY_TAG) && ($item["object-type"] == ACTIVITY_OBJ_TAGTERM)) {
$xo = parse_xml_string($item["object"], false);
$xt = parse_xml_string($item["target"], false);
@ -3017,8 +3030,8 @@ class DFRN
// We are processing relocations even if we are ignoring a contact
$relocations = $xpath->query("/atom:feed/dfrn:relocate");
foreach ($relocations AS $relocation) {
self::process_relocation($xpath, $relocation, $importer);
foreach ($relocations as $relocation) {
self::processRelocation($xpath, $relocation, $importer);
}
if ($importer["readonly"]) {
@ -3029,29 +3042,29 @@ class DFRN
}
$mails = $xpath->query("/atom:feed/dfrn:mail");
foreach ($mails AS $mail) {
self::process_mail($xpath, $mail, $importer);
foreach ($mails as $mail) {
self::processMail($xpath, $mail, $importer);
}
$suggestions = $xpath->query("/atom:feed/dfrn:suggest");
foreach ($suggestions AS $suggestion) {
self::process_suggestion($xpath, $suggestion, $importer);
foreach ($suggestions as $suggestion) {
self::processSuggestion($xpath, $suggestion, $importer);
}
$deletions = $xpath->query("/atom:feed/at:deleted-entry");
foreach ($deletions AS $deletion) {
self::process_deletion($xpath, $deletion, $importer);
foreach ($deletions as $deletion) {
self::processDeletion($xpath, $deletion, $importer);
}
if (!$sort_by_date) {
$entries = $xpath->query("/atom:feed/atom:entry");
foreach ($entries AS $entry) {
self::process_entry($header, $xpath, $entry, $importer, $xml);
foreach ($entries as $entry) {
self::processEntry($header, $xpath, $entry, $importer, $xml);
}
} else {
$newentries = array();
$entries = $xpath->query("/atom:feed/atom:entry");
foreach ($entries AS $entry) {
foreach ($entries as $entry) {
$created = $xpath->query("atom:published/text()", $entry)->item(0)->nodeValue;
$newentries[strtotime($created)] = $entry;
}
@ -3059,8 +3072,8 @@ class DFRN
// Now sort after the publishing date
ksort($newentries);
foreach ($newentries AS $entry) {
self::process_entry($header, $xpath, $entry, $importer, $xml);
foreach ($newentries as $entry) {
self::processEntry($header, $xpath, $entry, $importer, $xml);
}
}
logger("Import done for user " . $importer["uid"] . " from contact " . $importer["id"], LOGGER_DEBUG);

File diff suppressed because it is too large Load diff

View file

@ -298,6 +298,7 @@ class OStatus
* @param array $importer user record of the importing user
* @param array $contact contact
* @param string $hub Called by reference, returns the fetched hub data
* @return void
*/
public static function import($xml, $importer, &$contact, &$hub)
{
@ -309,7 +310,7 @@ class OStatus
*
* @param string $xml The XML
* @param array $importer user record of the importing user
* @param array $contact
* @param array $contact contact
* @param string $hub Called by reference, returns the fetched hub data
* @param boolean $stored Is the post fresh imported or from the database?
* @param boolean $initialize Is it the leading post so that data has to be initialized?
@ -537,6 +538,10 @@ class OStatus
return true;
}
/**
* @param object $item item
* @return void
*/
private static function deleteNotice($item)
{
$condition = array('uid' => $item['uid'], 'author-link' => $item['author-link'], 'uri' => $item['uri']);
@ -567,6 +572,7 @@ class OStatus
* @param object $entry The xml entry that is processed
* @param array $item The item array
* @param array $importer user record of the importing user
* @return void
*/
private static function processPost($xpath, $entry, &$item, $importer)
{
@ -708,6 +714,7 @@ class OStatus
*
* @param string $conversation The link to the conversation
* @param string $conversation_uri The conversation in "uri" format
* @return void
*/
private static function fetchConversation($conversation, $conversation_uri)
{
@ -768,6 +775,7 @@ class OStatus
* @param string $xml The feed
* @param string $conversation conversation
* @param string $conversation_uri conversation uri
* @return void
*/
private static function storeConversation($xml, $conversation = '', $conversation_uri = '')
{
@ -844,13 +852,14 @@ class OStatus
/**
* @brief Fetch the own post so that it can be stored later
* @param array $item The item array
*
* We want to store the original data for later processing.
* This function is meant for cases where we process a feed with multiple entries.
* In that case we need to fetch the single posts here.
*
* @param string $self The link to the self item
* @param array $item The item array
* @return void
*/
private static function fetchSelf($self, &$item)
{
@ -885,6 +894,7 @@ class OStatus
* @param string $related The link to the related item
* @param string $related_uri The related item in "uri" format
* @param array $importer user record of the importing user
* @return void
*/
private static function fetchRelated($related, $related_uri, $importer)
{
@ -1293,6 +1303,7 @@ class OStatus
* @param object $doc XML document
* @param object $root XML root element where the hub links are added
* @param object $nick nick
* @return void
*/
public static function hublinks($doc, $root, $nick)
{
@ -1306,6 +1317,7 @@ class OStatus
* @param object $doc XML document
* @param object $root XML root element where the hub links are added
* @param array $item Data of the item that is to be posted
* @return void
*/
private static function getAttachment($doc, $root, $item)
{
@ -1582,7 +1594,7 @@ class OStatus
* @param object $doc XML document
* @param array $item Data of the item that is to be posted
* @param array $owner Contact data of the poster
* @param $repeated_guid
* @param string $repeated_guid guid
* @param bool $toplevel Is it for en entry element (false) or a feed entry (true)?
*
* @return object Entry element
@ -1872,6 +1884,7 @@ class OStatus
* @param string $title Title for the post
* @param string $verb The activity verb
* @param bool $complete Add the "status_net" element?
* @return void
*/
private static function entryContent($doc, $entry, $item, $owner, $title, $verb = "", $complete = true)
{
@ -1914,6 +1927,7 @@ class OStatus
* @param array $item Data of the item that is to be posted
* @param array $owner Contact data of the poster
* @param bool $complete default true
* @return void
*/
private static function entryFooter($doc, $entry, $item, $owner, $complete = true)
{

View file

@ -485,7 +485,7 @@ class Delivery {
break;
if ($mail) {
Diaspora::send_mail($item,$owner,$contact);
Diaspora::sendMail($item,$owner,$contact);
break;
}
@ -498,7 +498,7 @@ class Delivery {
if (($target_item['deleted']) && (($target_item['uri'] === $target_item['parent-uri']) || $followup)) {
// top-level retraction
logger('diaspora retract: '.$loc);
Diaspora::send_retraction($target_item,$owner,$contact,$public_message);
Diaspora::sendRetraction($target_item,$owner,$contact,$public_message);
break;
} elseif ($relocate) {
Diaspora::sendAccountMigration($owner, $contact, $uid);
@ -506,17 +506,17 @@ class Delivery {
} elseif ($followup) {
// send comments and likes to owner to relay
logger('diaspora followup: '.$loc);
Diaspora::send_followup($target_item,$owner,$contact,$public_message);
Diaspora::sendFollowup($target_item,$owner,$contact,$public_message);
break;
} elseif ($target_item['uri'] !== $target_item['parent-uri']) {
// we are the relay - send comments, likes and relayable_retractions to our conversants
logger('diaspora relay: '.$loc);
Diaspora::send_relay($target_item,$owner,$contact,$public_message);
Diaspora::sendRelay($target_item,$owner,$contact,$public_message);
break;
} elseif ($top_level && !$walltowall) {
// currently no workable solution for sending walltowall
logger('diaspora status: '.$loc);
Diaspora::send_status($target_item,$owner,$contact,$public_message);
Diaspora::sendStatus($target_item,$owner,$contact,$public_message);
break;
}

View file

@ -525,7 +525,7 @@ class Notifier {
if ($diaspora_delivery) {
if (!$followup) {
$r0 = Diaspora::relay_list();
$r0 = Diaspora::relayList();
}
$r1 = q("SELECT `batch`, ANY_VALUE(`id`) AS `id`, ANY_VALUE(`name`) AS `name`, ANY_VALUE(`network`) AS `network`

View file

@ -14,6 +14,6 @@ class ProfileUpdate {
return;
}
Diaspora::send_profile($uid);
Diaspora::sendProfile($uid);
}
}