src Standards
This basically completes coding standards changes for the entire src directory, with the exception of App.php
This commit is contained in:
parent
057984c69e
commit
609a4de5d0
|
@ -4291,7 +4291,7 @@ function api_share_as_retweet(&$item)
|
||||||
{
|
{
|
||||||
$body = trim($item["body"]);
|
$body = trim($item["body"]);
|
||||||
|
|
||||||
if (Diaspora::is_reshare($body, false)===false) {
|
if (Diaspora::isReshare($body, false)===false) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4299,7 +4299,7 @@ function api_share_as_retweet(&$item)
|
||||||
$attributes = preg_replace("/\[share(.*?)\]\s?(.*?)\s?\[\/share\]\s?/ism", "$1", $body);
|
$attributes = preg_replace("/\[share(.*?)\]\s?(.*?)\s?\[\/share\]\s?/ism", "$1", $body);
|
||||||
/*
|
/*
|
||||||
* Skip if there is no shared message in there
|
* 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...
|
* but better one more than one less...
|
||||||
*/
|
*/
|
||||||
if ($body == $attributes) {
|
if ($body == $attributes) {
|
||||||
|
|
|
@ -272,7 +272,7 @@ function new_contact($uid, $url, $interactive = false, $network = '') {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($contact['network'] == NETWORK_DIASPORA) {
|
if ($contact['network'] == NETWORK_DIASPORA) {
|
||||||
$ret = Diaspora::send_share($a->user,$contact);
|
$ret = Diaspora::sendShare($a->user, $contact);
|
||||||
logger('share returns: '.$ret);
|
logger('share returns: '.$ret);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -247,7 +247,7 @@ EOT;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save the author information for the like in case we need to relay to Diaspora
|
// 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;
|
$new_item['id'] = $new_item_id;
|
||||||
|
|
||||||
|
|
|
@ -440,7 +440,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
|
||||||
if ((isset($new_relation) && $new_relation == CONTACT_IS_FRIEND)) {
|
if ((isset($new_relation) && $new_relation == CONTACT_IS_FRIEND)) {
|
||||||
|
|
||||||
if (($contact) && ($contact['network'] === NETWORK_DIASPORA)) {
|
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);
|
logger('share returns: ' . $ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -175,7 +175,7 @@ function dfrn_notify_post(App $a) {
|
||||||
*we got a key. old code send only the key, without RINO version.
|
*we got a key. old code send only the key, without RINO version.
|
||||||
* we assume RINO 1 if key and no 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;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -68,12 +68,12 @@ function fetch_init(App $a)
|
||||||
}
|
}
|
||||||
$user = $r[0];
|
$user = $r[0];
|
||||||
|
|
||||||
$status = Diaspora::build_status($item[0], $user);
|
$status = Diaspora::buildStatus($item[0], $user);
|
||||||
$xml = Diaspora::build_post_xml($status["type"], $status["message"]);
|
$xml = Diaspora::buildPostXml($status["type"], $status["message"]);
|
||||||
|
|
||||||
// Send the envelope
|
// Send the envelope
|
||||||
header("Content-Type: application/magic-envelope+xml; charset=utf-8");
|
header("Content-Type: application/magic-envelope+xml; charset=utf-8");
|
||||||
echo Diaspora::build_magic_envelope($xml, $user);
|
echo Diaspora::buildMagicEnvelope($xml, $user);
|
||||||
|
|
||||||
killme();
|
killme();
|
||||||
}
|
}
|
||||||
|
|
|
@ -985,7 +985,7 @@ function item_post(App $a) {
|
||||||
|
|
||||||
|
|
||||||
// Store the comment signature information in case we need to relay to Diaspora
|
// 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 {
|
} else {
|
||||||
$parent = $post_id;
|
$parent = $post_id;
|
||||||
|
|
|
@ -58,8 +58,8 @@ function p_init($a){
|
||||||
}
|
}
|
||||||
$user = $r[0];
|
$user = $r[0];
|
||||||
|
|
||||||
$status = Diaspora::build_status($item[0], $user);
|
$status = Diaspora::buildStatus($item[0], $user);
|
||||||
$xml = Diaspora::build_post_xml($status["type"], $status["message"]);
|
$xml = Diaspora::buildPostXml($status["type"], $status["message"]);
|
||||||
|
|
||||||
header("Content-Type: application/xml; charset=utf-8");
|
header("Content-Type: application/xml; charset=utf-8");
|
||||||
echo $xml;
|
echo $xml;
|
||||||
|
|
|
@ -49,14 +49,14 @@ function receive_post(App $a) {
|
||||||
}
|
}
|
||||||
|
|
||||||
logger('mod-diaspora: message is in the new format', LOGGER_DEBUG);
|
logger('mod-diaspora: message is in the new format', LOGGER_DEBUG);
|
||||||
$msg = Diaspora::decode_raw($importer, $postdata);
|
$msg = Diaspora::decodeRaw($importer, $postdata);
|
||||||
} else {
|
} else {
|
||||||
logger('mod-diaspora: decode message in the old format', LOGGER_DEBUG);
|
logger('mod-diaspora: decode message in the old format', LOGGER_DEBUG);
|
||||||
$msg = Diaspora::decode($importer, $xml);
|
$msg = Diaspora::decode($importer, $xml);
|
||||||
|
|
||||||
if ($public && !$msg) {
|
if ($public && !$msg) {
|
||||||
logger('mod-diaspora: decode message in the new format', LOGGER_DEBUG);
|
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;
|
$ret = true;
|
||||||
if ($public) {
|
if ($public) {
|
||||||
Diaspora::dispatch_public($msg);
|
Diaspora::dispatchPublic($msg);
|
||||||
} else {
|
} else {
|
||||||
$ret = Diaspora::dispatch($importer, $msg);
|
$ret = Diaspora::dispatch($importer, $msg);
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,7 @@ class DFRN
|
||||||
$doc = new DOMDocument('1.0', 'utf-8');
|
$doc = new DOMDocument('1.0', 'utf-8');
|
||||||
$doc->formatOutput = true;
|
$doc->formatOutput = true;
|
||||||
|
|
||||||
$root = self::add_header($doc, $owner, "dfrn:owner", "", false);
|
$root = self::addHeader($doc, $owner, "dfrn:owner", "", false);
|
||||||
|
|
||||||
if (! count($items)) {
|
if (! count($items)) {
|
||||||
return trim($doc->saveXML());
|
return trim($doc->saveXML());
|
||||||
|
@ -258,7 +258,7 @@ class DFRN
|
||||||
$author = "author";
|
$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
|
/// @TODO This hook can't work anymore
|
||||||
// call_hooks('atom_feed', $atom);
|
// call_hooks('atom_feed', $atom);
|
||||||
|
@ -370,7 +370,7 @@ class DFRN
|
||||||
$root->setAttribute("xmlns:ostatus", NAMESPACE_OSTATUS);
|
$root->setAttribute("xmlns:ostatus", NAMESPACE_OSTATUS);
|
||||||
$root->setAttribute("xmlns:statusnet", NAMESPACE_STATUSNET);
|
$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) {
|
foreach ($items as $item) {
|
||||||
$entry = self::entry($doc, $type, $item, $owner, true, 0);
|
$entry = self::entry($doc, $type, $item, $owner, true, 0);
|
||||||
|
@ -398,7 +398,7 @@ class DFRN
|
||||||
$doc = new DOMDocument('1.0', 'utf-8');
|
$doc = new DOMDocument('1.0', 'utf-8');
|
||||||
$doc->formatOutput = true;
|
$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");
|
$mail = $doc->createElement("dfrn:mail");
|
||||||
$sender = $doc->createElement("dfrn:sender");
|
$sender = $doc->createElement("dfrn:sender");
|
||||||
|
@ -411,7 +411,7 @@ class DFRN
|
||||||
|
|
||||||
XML::addElement($doc, $mail, "dfrn:id", $item['uri']);
|
XML::addElement($doc, $mail, "dfrn:id", $item['uri']);
|
||||||
XML::addElement($doc, $mail, "dfrn:in-reply-to", $item['parent-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:subject", $item['title']);
|
||||||
XML::addElement($doc, $mail, "dfrn:content", $item['body']);
|
XML::addElement($doc, $mail, "dfrn:content", $item['body']);
|
||||||
|
|
||||||
|
@ -434,7 +434,7 @@ class DFRN
|
||||||
$doc = new DOMDocument('1.0', 'utf-8');
|
$doc = new DOMDocument('1.0', 'utf-8');
|
||||||
$doc->formatOutput = true;
|
$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");
|
$suggest = $doc->createElement("dfrn:suggest");
|
||||||
|
|
||||||
|
@ -486,7 +486,7 @@ class DFRN
|
||||||
$doc = new DOMDocument('1.0', 'utf-8');
|
$doc = new DOMDocument('1.0', 'utf-8');
|
||||||
$doc->formatOutput = true;
|
$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");
|
$relocate = $doc->createElement("dfrn:relocate");
|
||||||
|
|
||||||
|
@ -501,7 +501,7 @@ class DFRN
|
||||||
XML::addElement($doc, $relocate, "dfrn:confirm", $owner['confirm']);
|
XML::addElement($doc, $relocate, "dfrn:confirm", $owner['confirm']);
|
||||||
XML::addElement($doc, $relocate, "dfrn:notify", $owner['notify']);
|
XML::addElement($doc, $relocate, "dfrn:notify", $owner['notify']);
|
||||||
XML::addElement($doc, $relocate, "dfrn:poll", $owner['poll']);
|
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);
|
$root->appendChild($relocate);
|
||||||
|
|
||||||
|
@ -520,7 +520,7 @@ class DFRN
|
||||||
* @return object XML root object
|
* @return object XML root object
|
||||||
* @todo Add type-hints
|
* @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 == "") {
|
if ($alternatelink == "") {
|
||||||
|
@ -579,7 +579,7 @@ class DFRN
|
||||||
|
|
||||||
XML::addElement($doc, $root, "updated", datetime_convert("UTC", "UTC", "now", ATOM_TIME));
|
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);
|
$root->appendChild($author);
|
||||||
|
|
||||||
return $root;
|
return $root;
|
||||||
|
@ -588,14 +588,15 @@ class DFRN
|
||||||
/**
|
/**
|
||||||
* @brief Adds the author element in the header for the DFRN protocol
|
* @brief Adds the author element in the header for the DFRN protocol
|
||||||
*
|
*
|
||||||
* @param object $doc XML document
|
* @param object $doc XML document
|
||||||
* @param array $owner Owner record
|
* @param array $owner Owner record
|
||||||
* @param string $authorelement Element name for the author
|
* @param string $authorelement Element name for the author
|
||||||
|
* @param boolean $public boolean
|
||||||
*
|
*
|
||||||
* @return object XML author object
|
* @return object XML author object
|
||||||
* @todo Add type-hints
|
* @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
|
// Is the profile hidden or shouldn't be published in the net? Then add the "hide" element
|
||||||
$r = q(
|
$r = q(
|
||||||
|
@ -739,7 +740,7 @@ class DFRN
|
||||||
* @return object XML author object
|
* @return object XML author object
|
||||||
* @todo Add type-hints
|
* @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"]);
|
$contact = Contact::getDetailsByURL($contact_url, $item["uid"]);
|
||||||
|
|
||||||
|
@ -780,7 +781,7 @@ class DFRN
|
||||||
* @return object XML activity object
|
* @return object XML activity object
|
||||||
* @todo Add type-hints
|
* @todo Add type-hints
|
||||||
*/
|
*/
|
||||||
private static function create_activity($doc, $element, $activity)
|
private static function createActivity($doc, $element, $activity)
|
||||||
{
|
{
|
||||||
if ($activity) {
|
if ($activity) {
|
||||||
$entry = $doc->createElement($element);
|
$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
|
// 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);
|
$data = parse_xml_string("<dummy>" . $r->link . "</dummy>", false);
|
||||||
if (is_object($data)) {
|
if (is_object($data)) {
|
||||||
foreach ($data->link AS $link) {
|
foreach ($data->link as $link) {
|
||||||
$attributes = array();
|
$attributes = array();
|
||||||
foreach ($link->attributes() as $parameter => $value) {
|
foreach ($link->attributes() as $parameter => $value) {
|
||||||
$attributes[$parameter] = $value;
|
$attributes[$parameter] = $value;
|
||||||
|
@ -843,7 +844,7 @@ class DFRN
|
||||||
* @return object XML attachment object
|
* @return object XML attachment object
|
||||||
* @todo Add type-hints
|
* @todo Add type-hints
|
||||||
*/
|
*/
|
||||||
private static function get_attachment($doc, $root, $item)
|
private static function getAttachment($doc, $root, $item)
|
||||||
{
|
{
|
||||||
$arr = explode('[/attach],', $item['attach']);
|
$arr = explode('[/attach],', $item['attach']);
|
||||||
if (count($arr)) {
|
if (count($arr)) {
|
||||||
|
@ -932,10 +933,10 @@ class DFRN
|
||||||
$htmlbody = bbcode($htmlbody, false, false, 7);
|
$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);
|
$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);
|
$entry->appendChild($dfrnowner);
|
||||||
|
|
||||||
if (($item['parent'] != $item['id']) || ($item['parent-uri'] !== $item['uri']) || (($item['thr-parent'] !== '') && ($item['thr-parent'] !== $item['uri']))) {
|
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);
|
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) {
|
if ($actobj) {
|
||||||
$entry->appendChild($actobj);
|
$entry->appendChild($actobj);
|
||||||
}
|
}
|
||||||
|
|
||||||
$actarg = self::create_activity($doc, "activity:target", $item['target']);
|
$actarg = self::createActivity($doc, "activity:target", $item['target']);
|
||||||
if ($actarg) {
|
if ($actarg) {
|
||||||
$entry->appendChild($actarg);
|
$entry->appendChild($actarg);
|
||||||
}
|
}
|
||||||
|
@ -1099,7 +1100,7 @@ class DFRN
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self::get_attachment($doc, $entry, $item);
|
self::getAttachment($doc, $entry, $item);
|
||||||
|
|
||||||
return $entry;
|
return $entry;
|
||||||
}
|
}
|
||||||
|
@ -1112,7 +1113,7 @@ class DFRN
|
||||||
*
|
*
|
||||||
* @return string encrypted data
|
* @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);
|
return openssl_encrypt($data, 'aes-128-ecb', $key, OPENSSL_RAW_DATA);
|
||||||
}
|
}
|
||||||
|
@ -1125,7 +1126,7 @@ class DFRN
|
||||||
*
|
*
|
||||||
* @return string decrypted data
|
* @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);
|
return openssl_decrypt($encrypted, 'aes-128-ecb', $key, OPENSSL_RAW_DATA);
|
||||||
}
|
}
|
||||||
|
@ -1291,7 +1292,7 @@ class DFRN
|
||||||
case 1:
|
case 1:
|
||||||
// Deprecated rino version!
|
// Deprecated rino version!
|
||||||
$key = openssl_random_pseudo_bytes(16);
|
$key = openssl_random_pseudo_bytes(16);
|
||||||
$data = self::aes_encrypt($postvars['data'], $key);
|
$data = self::aesEncrypt($postvars['data'], $key);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
// RINO 2 based on php-encryption
|
// RINO 2 based on php-encryption
|
||||||
|
@ -1392,9 +1393,10 @@ class DFRN
|
||||||
*
|
*
|
||||||
* @param array $contact Contact record
|
* @param array $contact Contact record
|
||||||
* @param string $birthday Birthday of the contact
|
* @param string $birthday Birthday of the contact
|
||||||
|
* @return void
|
||||||
* @todo Add array type-hint for $contact
|
* @todo Add array type-hint for $contact
|
||||||
*/
|
*/
|
||||||
private static function birthday_event($contact, $birthday)
|
private static function birthdayEvent($contact, $birthday)
|
||||||
{
|
{
|
||||||
// Check for duplicates
|
// Check for duplicates
|
||||||
$r = q(
|
$r = q(
|
||||||
|
@ -1412,7 +1414,7 @@ class DFRN
|
||||||
logger("updating birthday: ".$birthday." for contact ".$contact["id"]);
|
logger("updating birthday: ".$birthday." for contact ".$contact["id"]);
|
||||||
|
|
||||||
$bdtext = sprintf(t("%s\'s birthday"), $contact["name"]);
|
$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(
|
$r = q(
|
||||||
"INSERT INTO `event` (`uid`,`cid`,`created`,`edited`,`start`,`finish`,`summary`,`desc`,`type`)
|
"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 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 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 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
|
* @return Returns an array with relevant data of the author
|
||||||
* @todo Find good type-hints for all parameter
|
* @todo Find good type-hints for all parameter
|
||||||
|
@ -1474,10 +1477,10 @@ class DFRN
|
||||||
$avatarlist = array();
|
$avatarlist = array();
|
||||||
/// @todo check if "avatar" or "photo" would be the best field in the specification
|
/// @todo check if "avatar" or "photo" would be the best field in the specification
|
||||||
$avatars = $xpath->query($element."/atom:link[@rel='avatar']", $context);
|
$avatars = $xpath->query($element."/atom:link[@rel='avatar']", $context);
|
||||||
foreach ($avatars AS $avatar) {
|
foreach ($avatars as $avatar) {
|
||||||
$href = "";
|
$href = "";
|
||||||
$width = 0;
|
$width = 0;
|
||||||
foreach ($avatar->attributes AS $attributes) {
|
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") {
|
if ($attributes->name == "href") {
|
||||||
$href = $attributes->textContent;
|
$href = $attributes->textContent;
|
||||||
|
@ -1505,14 +1508,14 @@ class DFRN
|
||||||
|
|
||||||
// When was the last change to name or uri?
|
// When was the last change to name or uri?
|
||||||
$name_element = $xpath->query($element . "/atom:name", $context)->item(0);
|
$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") {
|
if ($attributes->name == "updated") {
|
||||||
$poco["name-date"] = $attributes->textContent;
|
$poco["name-date"] = $attributes->textContent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$link_element = $xpath->query($element . "/atom:link", $context)->item(0);
|
$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") {
|
if ($attributes->name == "updated") {
|
||||||
$poco["uri-date"] = $attributes->textContent;
|
$poco["uri-date"] = $attributes->textContent;
|
||||||
}
|
}
|
||||||
|
@ -1571,7 +1574,7 @@ class DFRN
|
||||||
// Save the keywords into the contact table
|
// Save the keywords into the contact table
|
||||||
$tags = array();
|
$tags = array();
|
||||||
$tagelements = $xpath->evaluate($element . "/poco:tags/text()", $context);
|
$tagelements = $xpath->evaluate($element . "/poco:tags/text()", $context);
|
||||||
foreach ($tagelements AS $tag) {
|
foreach ($tagelements as $tag) {
|
||||||
$tags[$tag->nodeValue] = $tag->nodeValue;
|
$tags[$tag->nodeValue] = $tag->nodeValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1608,12 +1611,12 @@ class DFRN
|
||||||
$contact = array_merge($contact, $poco);
|
$contact = array_merge($contact, $poco);
|
||||||
|
|
||||||
if ($old_bdyear != $contact["bdyear"]) {
|
if ($old_bdyear != $contact["bdyear"]) {
|
||||||
self::birthday_event($contact, $birthday);
|
self::birthdayEvent($contact, $birthday);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get all field names
|
// Get all field names
|
||||||
$fields = array();
|
$fields = array();
|
||||||
foreach ($r[0] AS $field => $data) {
|
foreach ($r[0] as $field => $data) {
|
||||||
$fields[$field] = $data;
|
$fields[$field] = $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1626,14 +1629,14 @@ class DFRN
|
||||||
|
|
||||||
// Update check for this field has to be done differently
|
// Update check for this field has to be done differently
|
||||||
$datefields = array("name-date", "uri-date");
|
$datefields = array("name-date", "uri-date");
|
||||||
foreach ($datefields AS $field) {
|
foreach ($datefields as $field) {
|
||||||
if (strtotime($contact[$field]) > strtotime($r[0][$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);
|
logger("Difference for contact " . $contact["id"] . " in field '" . $field . "'. New value: '" . $contact[$field] . "', old value '" . $r[0][$field] . "'", LOGGER_DEBUG);
|
||||||
$update = true;
|
$update = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($fields AS $field => $data) {
|
foreach ($fields as $field => $data) {
|
||||||
if ($contact[$field] != $r[0][$field]) {
|
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);
|
logger("Difference for contact " . $contact["id"] . " in field '" . $field . "'. New value: '" . $contact[$field] . "', old value '" . $r[0][$field] . "'", LOGGER_DEBUG);
|
||||||
$update = true;
|
$update = true;
|
||||||
|
@ -1692,7 +1695,7 @@ class DFRN
|
||||||
* @return string XML string
|
* @return string XML string
|
||||||
* @todo Find good type-hints for all parameter
|
* @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)) {
|
if (!is_object($activity)) {
|
||||||
return "";
|
return "";
|
||||||
|
@ -1743,9 +1746,10 @@ class DFRN
|
||||||
* @param object $xpath XPath object
|
* @param object $xpath XPath object
|
||||||
* @param object $mail mail elements
|
* @param object $mail mail elements
|
||||||
* @param array $importer Record of the importer user mixed with contact of the content
|
* @param array $importer Record of the importer user mixed with contact of the content
|
||||||
|
* @return void
|
||||||
* @todo Find good type-hints for all parameter
|
* @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");
|
logger("Processing mails");
|
||||||
|
|
||||||
|
@ -1794,9 +1798,10 @@ class DFRN
|
||||||
* @param object $xpath XPath object
|
* @param object $xpath XPath object
|
||||||
* @param object $suggestion suggestion elements
|
* @param object $suggestion suggestion elements
|
||||||
* @param array $importer Record of the importer user mixed with contact of the content
|
* @param array $importer Record of the importer user mixed with contact of the content
|
||||||
|
* @return boolean
|
||||||
* @todo Find good type-hints for all parameter
|
* @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();
|
$a = get_app();
|
||||||
|
|
||||||
|
@ -1903,20 +1908,21 @@ class DFRN
|
||||||
intval(0)
|
intval(0)
|
||||||
);
|
);
|
||||||
|
|
||||||
notification(array(
|
notification(
|
||||||
"type" => NOTIFY_SUGGEST,
|
array(
|
||||||
"notify_flags" => $importer["notify-flags"],
|
"type" => NOTIFY_SUGGEST,
|
||||||
"language" => $importer["language"],
|
"notify_flags" => $importer["notify-flags"],
|
||||||
"to_name" => $importer["username"],
|
"language" => $importer["language"],
|
||||||
"to_email" => $importer["email"],
|
"to_name" => $importer["username"],
|
||||||
"uid" => $importer["importer_uid"],
|
"to_email" => $importer["email"],
|
||||||
"item" => $suggest,
|
"uid" => $importer["importer_uid"],
|
||||||
"link" => System::baseUrl()."/notifications/intros",
|
"item" => $suggest,
|
||||||
"source_name" => $importer["name"],
|
"link" => System::baseUrl()."/notifications/intros",
|
||||||
"source_link" => $importer["url"],
|
"source_name" => $importer["name"],
|
||||||
"source_photo" => $importer["photo"],
|
"source_link" => $importer["url"],
|
||||||
"verb" => ACTIVITY_REQ_FRIEND,
|
"source_photo" => $importer["photo"],
|
||||||
"otype" => "intro")
|
"verb" => ACTIVITY_REQ_FRIEND,
|
||||||
|
"otype" => "intro")
|
||||||
);
|
);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -1928,9 +1934,10 @@ class DFRN
|
||||||
* @param object $xpath XPath object
|
* @param object $xpath XPath object
|
||||||
* @param object $relocation relocation elements
|
* @param object $relocation relocation elements
|
||||||
* @param array $importer Record of the importer user mixed with contact of the content
|
* @param array $importer Record of the importer user mixed with contact of the content
|
||||||
|
* @return boolean
|
||||||
* @todo Find good type-hints for all parameter
|
* @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");
|
logger("Processing relocations");
|
||||||
|
|
||||||
|
@ -2080,9 +2087,10 @@ class DFRN
|
||||||
* @param array $item the new item record
|
* @param array $item the new item record
|
||||||
* @param array $importer Record of the importer user mixed with contact of the content
|
* @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?
|
* @param int $entrytype Is it a toplevel entry, a comment or a relayed comment?
|
||||||
|
* @return mixed
|
||||||
* @todo set proper type-hints (array?)
|
* @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;
|
$changed = false;
|
||||||
|
|
||||||
|
@ -2137,7 +2145,7 @@ class DFRN
|
||||||
* @return int Is it a toplevel entry, a comment or a relayed comment?
|
* @return int Is it a toplevel entry, a comment or a relayed comment?
|
||||||
* @todo set proper type-hints (array?)
|
* @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"]) {
|
if ($item["parent-uri"] != $item["uri"]) {
|
||||||
$community = false;
|
$community = false;
|
||||||
|
@ -2208,9 +2216,10 @@ class DFRN
|
||||||
* @param array $item the new item record
|
* @param array $item the new item record
|
||||||
* @param array $importer Record of the importer user mixed with contact of the content
|
* @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
|
* @param int $posted_id The record number of item record that was just posted
|
||||||
|
* @return void
|
||||||
* @todo set proper type-hints (array?)
|
* @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));
|
$verb = urldecode(substr($item["verb"], strpos($item["verb"], "#")+1));
|
||||||
if (!$verb) {
|
if (!$verb) {
|
||||||
|
@ -2245,7 +2254,7 @@ class DFRN
|
||||||
"link" => System::baseUrl()."/display/".urlencode(get_item_guid($posted_id)),
|
"link" => System::baseUrl()."/display/".urlencode(get_item_guid($posted_id)),
|
||||||
"source_name" => stripslashes($item["author-name"]),
|
"source_name" => stripslashes($item["author-name"]),
|
||||||
"source_link" => $item["author-link"],
|
"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"]),
|
? $importer["thumb"] : $item["author-avatar"]),
|
||||||
"verb" => $item["verb"],
|
"verb" => $item["verb"],
|
||||||
"otype" => "person",
|
"otype" => "person",
|
||||||
|
@ -2267,7 +2276,7 @@ class DFRN
|
||||||
* @return bool Should the processing of the entries be continued?
|
* @return bool Should the processing of the entries be continued?
|
||||||
* @todo set proper type-hints (array?)
|
* @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);
|
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)) {
|
if (($item["verb"] == ACTIVITY_TAG) && ($item["object-type"] == ACTIVITY_OBJ_TAGTERM)) {
|
||||||
|
|
||||||
$xo = parse_xml_string($item["object"], false);
|
$xo = parse_xml_string($item["object"], false);
|
||||||
$xt = parse_xml_string($item["target"], false);
|
$xt = parse_xml_string($item["target"], false);
|
||||||
|
|
||||||
|
@ -2356,8 +2364,9 @@ class DFRN
|
||||||
|
|
||||||
// extract tag, if not duplicate, add to parent item
|
// extract tag, if not duplicate, add to parent item
|
||||||
if ($xo->content) {
|
if ($xo->content) {
|
||||||
if (!(stristr($r[0]["tag"],trim($xo->content)))) {
|
if (!(stristr($r[0]["tag"], trim($xo->content)))) {
|
||||||
q("UPDATE `item` SET `tag` = '%s' WHERE `id` = %d",
|
q(
|
||||||
|
"UPDATE `item` SET `tag` = '%s' WHERE `id` = %d",
|
||||||
dbesc($r[0]["tag"] . (strlen($r[0]["tag"]) ? ',' : '') . '#[url=' . $xo->id . ']'. $xo->content . '[/url]'),
|
dbesc($r[0]["tag"] . (strlen($r[0]["tag"]) ? ',' : '') . '#[url=' . $xo->id . ']'. $xo->content . '[/url]'),
|
||||||
intval($r[0]["id"])
|
intval($r[0]["id"])
|
||||||
);
|
);
|
||||||
|
@ -2375,17 +2384,18 @@ class DFRN
|
||||||
*
|
*
|
||||||
* @param object $links link elements
|
* @param object $links link elements
|
||||||
* @param array $item the item record
|
* @param array $item the item record
|
||||||
|
* @return void
|
||||||
* @todo set proper type-hints
|
* @todo set proper type-hints
|
||||||
*/
|
*/
|
||||||
private static function parse_links($links, &$item)
|
private static function parseLinks($links, &$item)
|
||||||
{
|
{
|
||||||
$rel = "";
|
$rel = "";
|
||||||
$href = "";
|
$href = "";
|
||||||
$type = "";
|
$type = "";
|
||||||
$length = "0";
|
$length = "0";
|
||||||
$title = "";
|
$title = "";
|
||||||
foreach ($links AS $link) {
|
foreach ($links as $link) {
|
||||||
foreach ($link->attributes AS $attributes) {
|
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") {
|
if ($attributes->name == "href") {
|
||||||
$href = $attributes->textContent;
|
$href = $attributes->textContent;
|
||||||
|
@ -2424,13 +2434,15 @@ class DFRN
|
||||||
/**
|
/**
|
||||||
* @brief Processes the entry elements which contain the items and comments
|
* @brief Processes the entry elements which contain the items and comments
|
||||||
*
|
*
|
||||||
* @param array $header Array of the header elements that always stay the same
|
* @param array $header Array of the header elements that always stay the same
|
||||||
* @param object $xpath XPath object
|
* @param object $xpath XPath object
|
||||||
* @param object $entry entry elements
|
* @param object $entry entry elements
|
||||||
* @param array $importer Record of the importer user mixed with contact of the content
|
* @param array $importer Record of the importer user mixed with contact of the content
|
||||||
|
* @param object $xml xml
|
||||||
|
* @return void
|
||||||
* @todo Add type-hints
|
* @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");
|
logger("Processing entries");
|
||||||
|
|
||||||
|
@ -2527,7 +2539,7 @@ class DFRN
|
||||||
|
|
||||||
$notice_info = $xpath->query("statusnet:notice_info", $entry);
|
$notice_info = $xpath->query("statusnet:notice_info", $entry);
|
||||||
if ($notice_info && ($notice_info->length > 0)) {
|
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") {
|
if ($attributes->name == "source") {
|
||||||
$item["app"] = strip_tags($attributes->textContent);
|
$item["app"] = strip_tags($attributes->textContent);
|
||||||
}
|
}
|
||||||
|
@ -2549,7 +2561,7 @@ class DFRN
|
||||||
}
|
}
|
||||||
|
|
||||||
$object = $xpath->query("activity:object", $entry)->item(0);
|
$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"]) != "") {
|
if (trim($item["object"]) != "") {
|
||||||
$r = parse_xml_string($item["object"], false);
|
$r = parse_xml_string($item["object"], false);
|
||||||
|
@ -2559,14 +2571,14 @@ class DFRN
|
||||||
}
|
}
|
||||||
|
|
||||||
$target = $xpath->query("activity:target", $entry)->item(0);
|
$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);
|
$categories = $xpath->query("atom:category", $entry);
|
||||||
if ($categories) {
|
if ($categories) {
|
||||||
foreach ($categories AS $category) {
|
foreach ($categories as $category) {
|
||||||
$term = "";
|
$term = "";
|
||||||
$scheme = "";
|
$scheme = "";
|
||||||
foreach ($category->attributes AS $attributes) {
|
foreach ($category->attributes as $attributes) {
|
||||||
if ($attributes->name == "term") {
|
if ($attributes->name == "term") {
|
||||||
$term = $attributes->textContent;
|
$term = $attributes->textContent;
|
||||||
}
|
}
|
||||||
|
@ -2596,14 +2608,14 @@ class DFRN
|
||||||
|
|
||||||
$links = $xpath->query("atom:link", $entry);
|
$links = $xpath->query("atom:link", $entry);
|
||||||
if ($links) {
|
if ($links) {
|
||||||
self::parse_links($links, $item);
|
self::parseLinks($links, $item);
|
||||||
}
|
}
|
||||||
|
|
||||||
$item['conversation-uri'] = $xpath->query('ostatus:conversation/text()', $entry)->item(0)->nodeValue;
|
$item['conversation-uri'] = $xpath->query('ostatus:conversation/text()', $entry)->item(0)->nodeValue;
|
||||||
|
|
||||||
$conv = $xpath->query('ostatus:conversation', $entry);
|
$conv = $xpath->query('ostatus:conversation', $entry);
|
||||||
if (is_object($conv->item(0))) {
|
if (is_object($conv->item(0))) {
|
||||||
foreach ($conv->item(0)->attributes AS $attributes) {
|
foreach ($conv->item(0)->attributes as $attributes) {
|
||||||
if ($attributes->name == "ref") {
|
if ($attributes->name == "ref") {
|
||||||
$item['conversation-uri'] = $attributes->textContent;
|
$item['conversation-uri'] = $attributes->textContent;
|
||||||
}
|
}
|
||||||
|
@ -2618,7 +2630,7 @@ class DFRN
|
||||||
|
|
||||||
$inreplyto = $xpath->query("thr:in-reply-to", $entry);
|
$inreplyto = $xpath->query("thr:in-reply-to", $entry);
|
||||||
if (is_object($inreplyto->item(0))) {
|
if (is_object($inreplyto->item(0))) {
|
||||||
foreach ($inreplyto->item(0)->attributes AS $attributes) {
|
foreach ($inreplyto->item(0)->attributes as $attributes) {
|
||||||
if ($attributes->name == "ref") {
|
if ($attributes->name == "ref") {
|
||||||
$item["parent-uri"] = $attributes->textContent;
|
$item["parent-uri"] = $attributes->textContent;
|
||||||
}
|
}
|
||||||
|
@ -2626,7 +2638,7 @@ class DFRN
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the type of the item (Top level post, reply or remote reply)
|
// 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
|
// 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))) {
|
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)) {
|
if (!self::processVerbs($entrytype, $importer, $item, $is_like)) {
|
||||||
logger("Exiting because 'process_verbs' told us so", LOGGER_DEBUG);
|
logger("Exiting because 'processVerbs' told us so", LOGGER_DEBUG);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update content if 'updated' changes
|
// Update content if 'updated' changes
|
||||||
if (DBM::is_result($current)) {
|
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);
|
logger("Item ".$item["uri"]." was updated.", LOGGER_DEBUG);
|
||||||
} else {
|
} else {
|
||||||
logger("Item ".$item["uri"]." already existed.", LOGGER_DEBUG);
|
logger("Item ".$item["uri"]." already existed.", LOGGER_DEBUG);
|
||||||
|
@ -2783,8 +2795,9 @@ class DFRN
|
||||||
|
|
||||||
logger("Item was stored with id ".$posted_id, LOGGER_DEBUG);
|
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);
|
self::doPoke($item, $importer, $posted_id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2794,13 +2807,14 @@ class DFRN
|
||||||
* @param object $xpath XPath object
|
* @param object $xpath XPath object
|
||||||
* @param object $deletion deletion elements
|
* @param object $deletion deletion elements
|
||||||
* @param array $importer Record of the importer user mixed with contact of the content
|
* @param array $importer Record of the importer user mixed with contact of the content
|
||||||
|
* @return void
|
||||||
* @todo set proper type-hints
|
* @todo set proper type-hints
|
||||||
*/
|
*/
|
||||||
private static function process_deletion($xpath, $deletion, $importer)
|
private static function processDeletion($xpath, $deletion, $importer)
|
||||||
{
|
{
|
||||||
logger("Processing deletions");
|
logger("Processing deletions");
|
||||||
|
|
||||||
foreach ($deletion->attributes AS $attributes) {
|
foreach ($deletion->attributes as $attributes) {
|
||||||
if ($attributes->name == "ref") {
|
if ($attributes->name == "ref") {
|
||||||
$uri = $attributes->textContent;
|
$uri = $attributes->textContent;
|
||||||
}
|
}
|
||||||
|
@ -2832,7 +2846,7 @@ class DFRN
|
||||||
} else {
|
} else {
|
||||||
$item = $r[0];
|
$item = $r[0];
|
||||||
|
|
||||||
$entrytype = self::get_entry_type($importer, $item);
|
$entrytype = self::getEntryType($importer, $item);
|
||||||
|
|
||||||
if (!$item["deleted"]) {
|
if (!$item["deleted"]) {
|
||||||
logger('deleting item '.$item["id"].' uri='.$uri, LOGGER_DEBUG);
|
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)) {
|
if (($item["verb"] == ACTIVITY_TAG) && ($item["object-type"] == ACTIVITY_OBJ_TAGTERM)) {
|
||||||
|
|
||||||
$xo = parse_xml_string($item["object"], false);
|
$xo = parse_xml_string($item["object"], false);
|
||||||
$xt = parse_xml_string($item["target"], 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
|
// We are processing relocations even if we are ignoring a contact
|
||||||
$relocations = $xpath->query("/atom:feed/dfrn:relocate");
|
$relocations = $xpath->query("/atom:feed/dfrn:relocate");
|
||||||
foreach ($relocations AS $relocation) {
|
foreach ($relocations as $relocation) {
|
||||||
self::process_relocation($xpath, $relocation, $importer);
|
self::processRelocation($xpath, $relocation, $importer);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($importer["readonly"]) {
|
if ($importer["readonly"]) {
|
||||||
|
@ -3029,29 +3042,29 @@ class DFRN
|
||||||
}
|
}
|
||||||
|
|
||||||
$mails = $xpath->query("/atom:feed/dfrn:mail");
|
$mails = $xpath->query("/atom:feed/dfrn:mail");
|
||||||
foreach ($mails AS $mail) {
|
foreach ($mails as $mail) {
|
||||||
self::process_mail($xpath, $mail, $importer);
|
self::processMail($xpath, $mail, $importer);
|
||||||
}
|
}
|
||||||
|
|
||||||
$suggestions = $xpath->query("/atom:feed/dfrn:suggest");
|
$suggestions = $xpath->query("/atom:feed/dfrn:suggest");
|
||||||
foreach ($suggestions AS $suggestion) {
|
foreach ($suggestions as $suggestion) {
|
||||||
self::process_suggestion($xpath, $suggestion, $importer);
|
self::processSuggestion($xpath, $suggestion, $importer);
|
||||||
}
|
}
|
||||||
|
|
||||||
$deletions = $xpath->query("/atom:feed/at:deleted-entry");
|
$deletions = $xpath->query("/atom:feed/at:deleted-entry");
|
||||||
foreach ($deletions AS $deletion) {
|
foreach ($deletions as $deletion) {
|
||||||
self::process_deletion($xpath, $deletion, $importer);
|
self::processDeletion($xpath, $deletion, $importer);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$sort_by_date) {
|
if (!$sort_by_date) {
|
||||||
$entries = $xpath->query("/atom:feed/atom:entry");
|
$entries = $xpath->query("/atom:feed/atom:entry");
|
||||||
foreach ($entries AS $entry) {
|
foreach ($entries as $entry) {
|
||||||
self::process_entry($header, $xpath, $entry, $importer, $xml);
|
self::processEntry($header, $xpath, $entry, $importer, $xml);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$newentries = array();
|
$newentries = array();
|
||||||
$entries = $xpath->query("/atom:feed/atom:entry");
|
$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;
|
$created = $xpath->query("atom:published/text()", $entry)->item(0)->nodeValue;
|
||||||
$newentries[strtotime($created)] = $entry;
|
$newentries[strtotime($created)] = $entry;
|
||||||
}
|
}
|
||||||
|
@ -3059,8 +3072,8 @@ class DFRN
|
||||||
// Now sort after the publishing date
|
// Now sort after the publishing date
|
||||||
ksort($newentries);
|
ksort($newentries);
|
||||||
|
|
||||||
foreach ($newentries AS $entry) {
|
foreach ($newentries as $entry) {
|
||||||
self::process_entry($header, $xpath, $entry, $importer, $xml);
|
self::processEntry($header, $xpath, $entry, $importer, $xml);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
logger("Import done for user " . $importer["uid"] . " from contact " . $importer["id"], LOGGER_DEBUG);
|
logger("Import done for user " . $importer["uid"] . " from contact " . $importer["id"], LOGGER_DEBUG);
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -298,6 +298,7 @@ class OStatus
|
||||||
* @param array $importer user record of the importing user
|
* @param array $importer user record of the importing user
|
||||||
* @param array $contact contact
|
* @param array $contact contact
|
||||||
* @param string $hub Called by reference, returns the fetched hub data
|
* @param string $hub Called by reference, returns the fetched hub data
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function import($xml, $importer, &$contact, &$hub)
|
public static function import($xml, $importer, &$contact, &$hub)
|
||||||
{
|
{
|
||||||
|
@ -309,7 +310,7 @@ class OStatus
|
||||||
*
|
*
|
||||||
* @param string $xml The XML
|
* @param string $xml The XML
|
||||||
* @param array $importer user record of the importing user
|
* @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 string $hub Called by reference, returns the fetched hub data
|
||||||
* @param boolean $stored Is the post fresh imported or from the database?
|
* @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?
|
* @param boolean $initialize Is it the leading post so that data has to be initialized?
|
||||||
|
@ -537,6 +538,10 @@ class OStatus
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param object $item item
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
private static function deleteNotice($item)
|
private static function deleteNotice($item)
|
||||||
{
|
{
|
||||||
$condition = array('uid' => $item['uid'], 'author-link' => $item['author-link'], 'uri' => $item['uri']);
|
$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 object $entry The xml entry that is processed
|
||||||
* @param array $item The item array
|
* @param array $item The item array
|
||||||
* @param array $importer user record of the importing user
|
* @param array $importer user record of the importing user
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
private static function processPost($xpath, $entry, &$item, $importer)
|
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 The link to the conversation
|
||||||
* @param string $conversation_uri The conversation in "uri" format
|
* @param string $conversation_uri The conversation in "uri" format
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
private static function fetchConversation($conversation, $conversation_uri)
|
private static function fetchConversation($conversation, $conversation_uri)
|
||||||
{
|
{
|
||||||
|
@ -768,6 +775,7 @@ class OStatus
|
||||||
* @param string $xml The feed
|
* @param string $xml The feed
|
||||||
* @param string $conversation conversation
|
* @param string $conversation conversation
|
||||||
* @param string $conversation_uri conversation uri
|
* @param string $conversation_uri conversation uri
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
private static function storeConversation($xml, $conversation = '', $conversation_uri = '')
|
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
|
* @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.
|
* We want to store the original data for later processing.
|
||||||
* This function is meant for cases where we process a feed with multiple entries.
|
* 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.
|
* In that case we need to fetch the single posts here.
|
||||||
*
|
*
|
||||||
* @param string $self The link to the self item
|
* @param string $self The link to the self item
|
||||||
|
* @param array $item The item array
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
private static function fetchSelf($self, &$item)
|
private static function fetchSelf($self, &$item)
|
||||||
{
|
{
|
||||||
|
@ -885,6 +894,7 @@ class OStatus
|
||||||
* @param string $related The link to the related item
|
* @param string $related The link to the related item
|
||||||
* @param string $related_uri The related item in "uri" format
|
* @param string $related_uri The related item in "uri" format
|
||||||
* @param array $importer user record of the importing user
|
* @param array $importer user record of the importing user
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
private static function fetchRelated($related, $related_uri, $importer)
|
private static function fetchRelated($related, $related_uri, $importer)
|
||||||
{
|
{
|
||||||
|
@ -1293,6 +1303,7 @@ class OStatus
|
||||||
* @param object $doc XML document
|
* @param object $doc XML document
|
||||||
* @param object $root XML root element where the hub links are added
|
* @param object $root XML root element where the hub links are added
|
||||||
* @param object $nick nick
|
* @param object $nick nick
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function hublinks($doc, $root, $nick)
|
public static function hublinks($doc, $root, $nick)
|
||||||
{
|
{
|
||||||
|
@ -1306,6 +1317,7 @@ class OStatus
|
||||||
* @param object $doc XML document
|
* @param object $doc XML document
|
||||||
* @param object $root XML root element where the hub links are added
|
* @param object $root XML root element where the hub links are added
|
||||||
* @param array $item Data of the item that is to be posted
|
* @param array $item Data of the item that is to be posted
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
private static function getAttachment($doc, $root, $item)
|
private static function getAttachment($doc, $root, $item)
|
||||||
{
|
{
|
||||||
|
@ -1582,7 +1594,7 @@ class OStatus
|
||||||
* @param object $doc XML document
|
* @param object $doc XML document
|
||||||
* @param array $item Data of the item that is to be posted
|
* @param array $item Data of the item that is to be posted
|
||||||
* @param array $owner Contact data of the poster
|
* @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)?
|
* @param bool $toplevel Is it for en entry element (false) or a feed entry (true)?
|
||||||
*
|
*
|
||||||
* @return object Entry element
|
* @return object Entry element
|
||||||
|
@ -1872,6 +1884,7 @@ class OStatus
|
||||||
* @param string $title Title for the post
|
* @param string $title Title for the post
|
||||||
* @param string $verb The activity verb
|
* @param string $verb The activity verb
|
||||||
* @param bool $complete Add the "status_net" element?
|
* @param bool $complete Add the "status_net" element?
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
private static function entryContent($doc, $entry, $item, $owner, $title, $verb = "", $complete = true)
|
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 $item Data of the item that is to be posted
|
||||||
* @param array $owner Contact data of the poster
|
* @param array $owner Contact data of the poster
|
||||||
* @param bool $complete default true
|
* @param bool $complete default true
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
private static function entryFooter($doc, $entry, $item, $owner, $complete = true)
|
private static function entryFooter($doc, $entry, $item, $owner, $complete = true)
|
||||||
{
|
{
|
||||||
|
|
|
@ -485,7 +485,7 @@ class Delivery {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if ($mail) {
|
if ($mail) {
|
||||||
Diaspora::send_mail($item,$owner,$contact);
|
Diaspora::sendMail($item,$owner,$contact);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -498,7 +498,7 @@ class Delivery {
|
||||||
if (($target_item['deleted']) && (($target_item['uri'] === $target_item['parent-uri']) || $followup)) {
|
if (($target_item['deleted']) && (($target_item['uri'] === $target_item['parent-uri']) || $followup)) {
|
||||||
// top-level retraction
|
// top-level retraction
|
||||||
logger('diaspora retract: '.$loc);
|
logger('diaspora retract: '.$loc);
|
||||||
Diaspora::send_retraction($target_item,$owner,$contact,$public_message);
|
Diaspora::sendRetraction($target_item,$owner,$contact,$public_message);
|
||||||
break;
|
break;
|
||||||
} elseif ($relocate) {
|
} elseif ($relocate) {
|
||||||
Diaspora::sendAccountMigration($owner, $contact, $uid);
|
Diaspora::sendAccountMigration($owner, $contact, $uid);
|
||||||
|
@ -506,17 +506,17 @@ class Delivery {
|
||||||
} elseif ($followup) {
|
} elseif ($followup) {
|
||||||
// send comments and likes to owner to relay
|
// send comments and likes to owner to relay
|
||||||
logger('diaspora followup: '.$loc);
|
logger('diaspora followup: '.$loc);
|
||||||
Diaspora::send_followup($target_item,$owner,$contact,$public_message);
|
Diaspora::sendFollowup($target_item,$owner,$contact,$public_message);
|
||||||
break;
|
break;
|
||||||
} elseif ($target_item['uri'] !== $target_item['parent-uri']) {
|
} elseif ($target_item['uri'] !== $target_item['parent-uri']) {
|
||||||
// we are the relay - send comments, likes and relayable_retractions to our conversants
|
// we are the relay - send comments, likes and relayable_retractions to our conversants
|
||||||
logger('diaspora relay: '.$loc);
|
logger('diaspora relay: '.$loc);
|
||||||
Diaspora::send_relay($target_item,$owner,$contact,$public_message);
|
Diaspora::sendRelay($target_item,$owner,$contact,$public_message);
|
||||||
break;
|
break;
|
||||||
} elseif ($top_level && !$walltowall) {
|
} elseif ($top_level && !$walltowall) {
|
||||||
// currently no workable solution for sending walltowall
|
// currently no workable solution for sending walltowall
|
||||||
logger('diaspora status: '.$loc);
|
logger('diaspora status: '.$loc);
|
||||||
Diaspora::send_status($target_item,$owner,$contact,$public_message);
|
Diaspora::sendStatus($target_item,$owner,$contact,$public_message);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -525,7 +525,7 @@ class Notifier {
|
||||||
|
|
||||||
if ($diaspora_delivery) {
|
if ($diaspora_delivery) {
|
||||||
if (!$followup) {
|
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`
|
$r1 = q("SELECT `batch`, ANY_VALUE(`id`) AS `id`, ANY_VALUE(`name`) AS `name`, ANY_VALUE(`network`) AS `network`
|
||||||
|
|
|
@ -14,6 +14,6 @@ class ProfileUpdate {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Diaspora::send_profile($uid);
|
Diaspora::sendProfile($uid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue