From 7aae852fe0285ac7dd88685f92715691a099190d Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Wed, 23 Mar 2016 22:12:08 +0100 Subject: [PATCH] Some more code cleaning --- include/diaspora.php | 35 ++++++++++++++++++++++++++--------- include/xml.php | 1 + 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/include/diaspora.php b/include/diaspora.php index 308a799118..a608516622 100644 --- a/include/diaspora.php +++ b/include/diaspora.php @@ -1694,11 +1694,8 @@ y * $BPhoto = "[url=".$contact["url"]."][img]".$contact["thumb"]."[/img][/url]"; $arr["body"] = sprintf(t("%1$s is now friends with %2$s"), $A, $B)."\n\n\n".$Bphoto; - $arr["object"] = "".ACTIVITY_OBJ_PERSON."".$contact["name"]."" - ."".$contact["url"]."/".$contact["name"].""; - $arr["object"] .= "".xmlify(''."\n"); - $arr["object"] .= xmlify(''."\n"); - $arr["object"] .= "\n"; + $arr["object"] = self::construct_new_friend_object($contact); + $arr["last-child"] = 1; $arr["allow_cid"] = $user[0]["allow_cid"]; @@ -1713,6 +1710,26 @@ y * } } + /** + * @brief Creates a XML object for a "new friend" message + * + * @param array $contact Array of the contact + * + * @return string The XML + */ + private function construct_new_friend_object($contact) { + $objtype = ACTIVITY_OBJ_PERSON; + $link = ''."\n". + ''."\n"; + + $xmldata = array("object" => array("type" => $objtype, + "title" => $contact["name"], + "id" => $contact["url"]."/".$contact["name"], + "link" => $link)); + + return xml::from_array($xmldata, $xml, true); + } + /** * @brief Processes incoming sharing notification * @@ -2184,9 +2201,9 @@ y * return $message_id; } - /****************************************************************************************** + /* ************************************************************************************** * * Here are all the functions that are needed to transmit data with the Diaspora protocol * - ******************************************************************************************/ + * ************************************************************************************** */ /** * @brief returnes the handle of a contact @@ -3071,7 +3088,7 @@ y * * * @return bool Success */ - function store_like_signature($contact, $post_id) { + public static function store_like_signature($contact, $post_id) { $enabled = intval(get_config('system','diaspora_enabled')); if (!$enabled) { @@ -3135,7 +3152,7 @@ y * * * @return bool Success */ - function store_comment_signature($item, $contact, $uprvkey, $message_id) { + public static function store_comment_signature($item, $contact, $uprvkey, $message_id) { if ($uprvkey == "") { logger('No private key, so not storing comment signature', LOGGER_DEBUG); diff --git a/include/xml.php b/include/xml.php index 2aed3fe8ed..47a2f6f7d5 100644 --- a/include/xml.php +++ b/include/xml.php @@ -1,5 +1,6 @@