Some more code cleaning

This commit is contained in:
Michael Vogel 2016-03-23 22:12:08 +01:00
parent ac35f8c756
commit 7aae852fe0
2 changed files with 27 additions and 9 deletions

View File

@ -1694,11 +1694,8 @@ y *
$BPhoto = "[url=".$contact["url"]."][img]".$contact["thumb"]."[/img][/url]"; $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["body"] = sprintf(t("%1$s is now friends with %2$s"), $A, $B)."\n\n\n".$Bphoto;
$arr["object"] = "<object><type>".ACTIVITY_OBJ_PERSON."</type><title>".$contact["name"]."</title>" $arr["object"] = self::construct_new_friend_object($contact);
."<id>".$contact["url"]."/".$contact["name"]."</id>";
$arr["object"] .= "<link>".xmlify('<link rel="alternate" type="text/html" href="'.$contact["url"].'" />'."\n");
$arr["object"] .= xmlify('<link rel="photo" type="image/jpeg" href="'.$contact["thumb"].'" />'."\n");
$arr["object"] .= "</link></object>\n";
$arr["last-child"] = 1; $arr["last-child"] = 1;
$arr["allow_cid"] = $user[0]["allow_cid"]; $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 = '<link rel="alternate" type="text/html" href="'.$contact["url"].'" />'."\n".
'<link rel="photo" type="image/jpeg" href="'.$contact["thumb"].'" />'."\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 * @brief Processes incoming sharing notification
* *
@ -2184,9 +2201,9 @@ y *
return $message_id; return $message_id;
} }
/****************************************************************************************** /* ************************************************************************************** *
* Here are all the functions that are needed to transmit data with the Diaspora protocol * * Here are all the functions that are needed to transmit data with the Diaspora protocol *
******************************************************************************************/ * ************************************************************************************** */
/** /**
* @brief returnes the handle of a contact * @brief returnes the handle of a contact
@ -3071,7 +3088,7 @@ y *
* *
* @return bool Success * @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')); $enabled = intval(get_config('system','diaspora_enabled'));
if (!$enabled) { if (!$enabled) {
@ -3135,7 +3152,7 @@ y *
* *
* @return bool Success * @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 == "") { if ($uprvkey == "") {
logger('No private key, so not storing comment signature', LOGGER_DEBUG); logger('No private key, so not storing comment signature', LOGGER_DEBUG);

View File

@ -1,5 +1,6 @@
<?php <?php
/** /**
* @file include/xml.php
* @brief This class contain functions to work with XML data * @brief This class contain functions to work with XML data
* *
*/ */