[Scrutinizer] Fix undeclared variables in src/Protocol/
- Use dba::selectFirst to remove intermediate variables `$r` - Remove unused variable `$sender` in Protocol\Email - Simplify Protocol\OStatus:fetchAuthor cascading queries
This commit is contained in:
parent
2234bb92ae
commit
d8e9ed5ff8
|
@ -930,6 +930,7 @@ class DFRN
|
||||||
// Remove the abstract element. It is only locally important.
|
// Remove the abstract element. It is only locally important.
|
||||||
$body = BBCode::stripAbstract($body);
|
$body = BBCode::stripAbstract($body);
|
||||||
|
|
||||||
|
$htmlbody = '';
|
||||||
if ($type == 'html') {
|
if ($type == 'html') {
|
||||||
$htmlbody = $body;
|
$htmlbody = $body;
|
||||||
|
|
||||||
|
@ -1432,19 +1433,17 @@ class DFRN
|
||||||
$author["name"] = $xpath->evaluate($element."/atom:name/text()", $context)->item(0)->nodeValue;
|
$author["name"] = $xpath->evaluate($element."/atom:name/text()", $context)->item(0)->nodeValue;
|
||||||
$author["link"] = $xpath->evaluate($element."/atom:uri/text()", $context)->item(0)->nodeValue;
|
$author["link"] = $xpath->evaluate($element."/atom:uri/text()", $context)->item(0)->nodeValue;
|
||||||
|
|
||||||
$r = q(
|
$contact_old = dba::fetch_first("SELECT `id`, `uid`, `url`, `network`, `avatar-date`, `name-date`, `uri-date`, `addr`,
|
||||||
"SELECT `id`, `uid`, `url`, `network`, `avatar-date`, `name-date`, `uri-date`, `addr`,
|
|
||||||
`name`, `nick`, `about`, `location`, `keywords`, `xmpp`, `bdyear`, `bd`, `hidden`, `contact-type`
|
`name`, `nick`, `about`, `location`, `keywords`, `xmpp`, `bdyear`, `bd`, `hidden`, `contact-type`
|
||||||
FROM `contact` WHERE `uid` = %d AND `nurl` = '%s' AND `network` != '%s'",
|
FROM `contact` WHERE `uid` = ? AND `nurl` = ? AND `network` != ?",
|
||||||
intval($importer["uid"]),
|
$importer["uid"],
|
||||||
dbesc(normalise_link($author["link"])),
|
normalise_link($author["link"]),
|
||||||
dbesc(NETWORK_STATUSNET)
|
NETWORK_STATUSNET
|
||||||
);
|
);
|
||||||
|
|
||||||
if (DBM::is_result($r)) {
|
if (DBM::is_result($contact_old)) {
|
||||||
$contact = $r[0];
|
$author["contact-id"] = $contact_old["id"];
|
||||||
$author["contact-id"] = $r[0]["id"];
|
$author["network"] = $contact_old["network"];
|
||||||
$author["network"] = $r[0]["network"];
|
|
||||||
} else {
|
} else {
|
||||||
if (!$onlyfetch) {
|
if (!$onlyfetch) {
|
||||||
logger("Contact ".$author["link"]." wasn't found for user ".$importer["uid"]." XML: ".$xml, LOGGER_DEBUG);
|
logger("Contact ".$author["link"]." wasn't found for user ".$importer["uid"]." XML: ".$xml, LOGGER_DEBUG);
|
||||||
|
@ -1471,7 +1470,7 @@ class DFRN
|
||||||
$width = $attributes->textContent;
|
$width = $attributes->textContent;
|
||||||
}
|
}
|
||||||
if ($attributes->name == "updated") {
|
if ($attributes->name == "updated") {
|
||||||
$contact["avatar-date"] = $attributes->textContent;
|
$contact_old["avatar-date"] = $attributes->textContent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (($width > 0) && ($href != "")) {
|
if (($width > 0) && ($href != "")) {
|
||||||
|
@ -1483,10 +1482,10 @@ class DFRN
|
||||||
$author["avatar"] = current($avatarlist);
|
$author["avatar"] = current($avatarlist);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DBM::is_result($r) && !$onlyfetch) {
|
if (DBM::is_result($contact_old) && !$onlyfetch) {
|
||||||
logger("Check if contact details for contact " . $r[0]["id"] . " (" . $r[0]["nick"] . ") have to be updated.", LOGGER_DEBUG);
|
logger("Check if contact details for contact " . $contact_old["id"] . " (" . $contact_old["nick"] . ") have to be updated.", LOGGER_DEBUG);
|
||||||
|
|
||||||
$poco = ["url" => $contact["url"]];
|
$poco = ["url" => $contact_old["url"]];
|
||||||
|
|
||||||
// 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);
|
||||||
|
@ -1545,12 +1544,12 @@ class DFRN
|
||||||
// If the "hide" element is present then the profile isn't searchable.
|
// If the "hide" element is present then the profile isn't searchable.
|
||||||
$hide = intval($xpath->evaluate($element . "/dfrn:hide/text()", $context)->item(0)->nodeValue == "true");
|
$hide = intval($xpath->evaluate($element . "/dfrn:hide/text()", $context)->item(0)->nodeValue == "true");
|
||||||
|
|
||||||
logger("Hidden status for contact " . $contact["url"] . ": " . $hide, LOGGER_DEBUG);
|
logger("Hidden status for contact " . $contact_old["url"] . ": " . $hide, LOGGER_DEBUG);
|
||||||
|
|
||||||
// If the contact isn't searchable then set the contact to "hidden".
|
// If the contact isn't searchable then set the contact to "hidden".
|
||||||
// Problem: This can be manually overridden by the user.
|
// Problem: This can be manually overridden by the user.
|
||||||
if ($hide) {
|
if ($hide) {
|
||||||
$contact["hidden"] = true;
|
$contact_old["hidden"] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save the keywords into the contact table
|
// Save the keywords into the contact table
|
||||||
|
@ -1565,8 +1564,6 @@ class DFRN
|
||||||
}
|
}
|
||||||
|
|
||||||
// "dfrn:birthday" contains the birthday converted to UTC
|
// "dfrn:birthday" contains the birthday converted to UTC
|
||||||
$old_bdyear = $contact["bdyear"];
|
|
||||||
|
|
||||||
$birthday = $xpath->evaluate($element . "/dfrn:birthday/text()", $context)->item(0)->nodeValue;
|
$birthday = $xpath->evaluate($element . "/dfrn:birthday/text()", $context)->item(0)->nodeValue;
|
||||||
|
|
||||||
if (strtotime($birthday) > time()) {
|
if (strtotime($birthday) > time()) {
|
||||||
|
@ -1590,15 +1587,15 @@ class DFRN
|
||||||
$poco["bd"] = $value;
|
$poco["bd"] = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
$contact = array_merge($contact, $poco);
|
$contact = array_merge($contact_old, $poco);
|
||||||
|
|
||||||
if ($old_bdyear != $contact["bdyear"]) {
|
if ($contact_old["bdyear"] != $contact["bdyear"]) {
|
||||||
self::birthdayEvent($contact, $birthday);
|
self::birthdayEvent($contact, $birthday);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get all field names
|
// Get all field names
|
||||||
$fields = [];
|
$fields = [];
|
||||||
foreach ($r[0] as $field => $data) {
|
foreach ($contact_old as $field => $data) {
|
||||||
$fields[$field] = $data;
|
$fields[$field] = $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1609,18 +1606,19 @@ class DFRN
|
||||||
unset($fields["name-date"]);
|
unset($fields["name-date"]);
|
||||||
unset($fields["uri-date"]);
|
unset($fields["uri-date"]);
|
||||||
|
|
||||||
|
$update = false;
|
||||||
// Update check for this field has to be done differently
|
// Update check for this field has to be done differently
|
||||||
$datefields = ["name-date", "uri-date"];
|
$datefields = ["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($contact_old[$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 '" . $contact_old[$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] != $contact_old[$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 '" . $contact_old[$field] . "'", LOGGER_DEBUG);
|
||||||
$update = true;
|
$update = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1645,7 +1643,7 @@ class DFRN
|
||||||
$author["avatar"],
|
$author["avatar"],
|
||||||
$importer["uid"],
|
$importer["uid"],
|
||||||
$contact["id"],
|
$contact["id"],
|
||||||
(strtotime($contact["avatar-date"]) > strtotime($r[0]["avatar-date"]))
|
(strtotime($contact["avatar-date"]) > strtotime($contact_old["avatar-date"]))
|
||||||
);
|
);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -2404,14 +2402,12 @@ class DFRN
|
||||||
|
|
||||||
$item["edited"] = $xpath->query("atom:updated/text()", $entry)->item(0)->nodeValue;
|
$item["edited"] = $xpath->query("atom:updated/text()", $entry)->item(0)->nodeValue;
|
||||||
|
|
||||||
$current = q(
|
$current = dba::selectFirst('item',
|
||||||
"SELECT `id`, `uid`, `edited`, `body` FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
|
['id', 'uid', 'edited', 'body'],
|
||||||
dbesc($item["uri"]),
|
['uri' => $item["uri"], 'uid' => $importer["importer_uid"]]
|
||||||
intval($importer["importer_uid"])
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// Is there an existing item?
|
// Is there an existing item?
|
||||||
if (DBM::is_result($current) && !self::isEditedTimestampNewer($current[0], $item)) {
|
if (DBM::is_result($current) && !self::isEditedTimestampNewer($current, $item)) {
|
||||||
logger("Item ".$item["uri"]." (".$item['edited'].") already existed.", LOGGER_DEBUG);
|
logger("Item ".$item["uri"]." (".$item['edited'].") already existed.", LOGGER_DEBUG);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -2652,7 +2648,7 @@ class DFRN
|
||||||
|
|
||||||
// Update content if 'updated' changes
|
// Update content if 'updated' changes
|
||||||
if (DBM::is_result($current)) {
|
if (DBM::is_result($current)) {
|
||||||
if (self::updateContent($r[0], $item, $importer, $entrytype)) {
|
if (self::updateContent($current, $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);
|
||||||
|
@ -2731,7 +2727,7 @@ class DFRN
|
||||||
private static function processDeletion($xpath, $deletion, $importer)
|
private static function processDeletion($xpath, $deletion, $importer)
|
||||||
{
|
{
|
||||||
logger("Processing deletions");
|
logger("Processing deletions");
|
||||||
|
$uri = null;
|
||||||
foreach ($deletion->attributes as $attributes) {
|
foreach ($deletion->attributes as $attributes) {
|
||||||
if ($attributes->name == "ref") {
|
if ($attributes->name == "ref") {
|
||||||
$uri = $attributes->textContent;
|
$uri = $attributes->textContent;
|
||||||
|
|
|
@ -355,6 +355,9 @@ class Diaspora
|
||||||
}
|
}
|
||||||
$children = $basedom->children('https://joindiaspora.com/protocol');
|
$children = $basedom->children('https://joindiaspora.com/protocol');
|
||||||
|
|
||||||
|
$inner_aes_key = null;
|
||||||
|
$inner_iv = null;
|
||||||
|
|
||||||
if ($children->header) {
|
if ($children->header) {
|
||||||
$public = true;
|
$public = true;
|
||||||
$author_link = str_replace('acct:', '', $children->header->author_id);
|
$author_link = str_replace('acct:', '', $children->header->author_id);
|
||||||
|
@ -393,6 +396,7 @@ class Diaspora
|
||||||
|
|
||||||
// figure out where in the DOM tree our data is hiding
|
// figure out where in the DOM tree our data is hiding
|
||||||
|
|
||||||
|
$base = null;
|
||||||
if ($dom->provenance->data) {
|
if ($dom->provenance->data) {
|
||||||
$base = $dom->provenance;
|
$base = $dom->provenance;
|
||||||
} elseif ($dom->env->data) {
|
} elseif ($dom->env->data) {
|
||||||
|
@ -638,8 +642,6 @@ class Diaspora
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$first_child = $data->getName();
|
|
||||||
|
|
||||||
// Is this the new or the old version?
|
// Is this the new or the old version?
|
||||||
if ($data->getName() == "XML") {
|
if ($data->getName() == "XML") {
|
||||||
$oldXML = true;
|
$oldXML = true;
|
||||||
|
@ -668,6 +670,8 @@ class Diaspora
|
||||||
$fields = new SimpleXMLElement("<".$type."/>");
|
$fields = new SimpleXMLElement("<".$type."/>");
|
||||||
|
|
||||||
$signed_data = "";
|
$signed_data = "";
|
||||||
|
$author_signature = null;
|
||||||
|
$parent_author_signature = null;
|
||||||
|
|
||||||
foreach ($element->children() as $fieldname => $entry) {
|
foreach ($element->children() as $fieldname => $entry) {
|
||||||
if ($oldXML) {
|
if ($oldXML) {
|
||||||
|
@ -796,14 +800,11 @@ class Diaspora
|
||||||
*/
|
*/
|
||||||
public static function personByHandle($handle)
|
public static function personByHandle($handle)
|
||||||
{
|
{
|
||||||
$r = q(
|
$update = false;
|
||||||
"SELECT * FROM `fcontact` WHERE `network` = '%s' AND `addr` = '%s' LIMIT 1",
|
|
||||||
dbesc(NETWORK_DIASPORA),
|
$person = dba::selectFirst('fcontact', [], ['network' => NETWORK_DIASPORA, 'addr' => $handle]);
|
||||||
dbesc($handle)
|
if (DBM::is_result($person)) {
|
||||||
);
|
logger("In cache " . print_r($person, true), LOGGER_DEBUG);
|
||||||
if ($r) {
|
|
||||||
$person = $r[0];
|
|
||||||
logger("In cache " . print_r($r, true), LOGGER_DEBUG);
|
|
||||||
|
|
||||||
// update record occasionally so it doesn't get stale
|
// update record occasionally so it doesn't get stale
|
||||||
$d = strtotime($person["updated"]." +00:00");
|
$d = strtotime($person["updated"]." +00:00");
|
||||||
|
@ -816,7 +817,7 @@ class Diaspora
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$person || $update) {
|
if (!DBM::is_result($person) || $update) {
|
||||||
logger("create or refresh", LOGGER_DEBUG);
|
logger("create or refresh", LOGGER_DEBUG);
|
||||||
$r = Probe::uri($handle, NETWORK_DIASPORA);
|
$r = Probe::uri($handle, NETWORK_DIASPORA);
|
||||||
|
|
||||||
|
@ -827,6 +828,7 @@ class Diaspora
|
||||||
$person = $r;
|
$person = $r;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $person;
|
return $person;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3741,6 +3743,7 @@ class Diaspora
|
||||||
$parent = $p[0];
|
$parent = $p[0];
|
||||||
|
|
||||||
$target_type = ($parent["uri"] === $parent["parent-uri"] ? "Post" : "Comment");
|
$target_type = ($parent["uri"] === $parent["parent-uri"] ? "Post" : "Comment");
|
||||||
|
$positive = null;
|
||||||
if ($item['verb'] === ACTIVITY_LIKE) {
|
if ($item['verb'] === ACTIVITY_LIKE) {
|
||||||
$positive = "true";
|
$positive = "true";
|
||||||
} elseif ($item['verb'] === ACTIVITY_DISLIKE) {
|
} elseif ($item['verb'] === ACTIVITY_DISLIKE) {
|
||||||
|
@ -4181,6 +4184,10 @@ class Diaspora
|
||||||
$small = System::baseUrl().'/photo/custom/50/' .$profile['uid'].'.jpg';
|
$small = System::baseUrl().'/photo/custom/50/' .$profile['uid'].'.jpg';
|
||||||
$searchable = (($profile['publish'] && $profile['net-publish']) ? 'true' : 'false');
|
$searchable = (($profile['publish'] && $profile['net-publish']) ? 'true' : 'false');
|
||||||
|
|
||||||
|
$dob = null;
|
||||||
|
$about = null;
|
||||||
|
$location = null;
|
||||||
|
$tags = null;
|
||||||
if ($searchable === 'true') {
|
if ($searchable === 'true') {
|
||||||
$dob = '';
|
$dob = '';
|
||||||
|
|
||||||
|
|
|
@ -617,12 +617,7 @@ class Email
|
||||||
$currline = $arrbody[$i];
|
$currline = $arrbody[$i];
|
||||||
|
|
||||||
while ($previousquote < $quotelevel) {
|
while ($previousquote < $quotelevel) {
|
||||||
if ($sender != '') {
|
|
||||||
$quote = "[quote title=$sender]";
|
|
||||||
$sender = '';
|
|
||||||
} else
|
|
||||||
$quote = "[quote]";
|
$quote = "[quote]";
|
||||||
|
|
||||||
$arrbody[$i] = $quote.$arrbody[$i];
|
$arrbody[$i] = $quote.$arrbody[$i];
|
||||||
$previousquote++;
|
$previousquote++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,6 +68,7 @@ class Feed {
|
||||||
$xpath->registerNamespace('poco', NAMESPACE_POCO);
|
$xpath->registerNamespace('poco', NAMESPACE_POCO);
|
||||||
|
|
||||||
$author = [];
|
$author = [];
|
||||||
|
$entries = null;
|
||||||
|
|
||||||
// Is it RDF?
|
// Is it RDF?
|
||||||
if ($xpath->query('/rdf:RDF/rss:channel')->length > 0) {
|
if ($xpath->query('/rdf:RDF/rss:channel')->length > 0) {
|
||||||
|
@ -369,9 +370,8 @@ class Feed {
|
||||||
$item["title"] = '';
|
$item["title"] = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$preview = '';
|
||||||
if (!empty($contact["fetch_further_information"]) && ($contact["fetch_further_information"] < 3)) {
|
if (!empty($contact["fetch_further_information"]) && ($contact["fetch_further_information"] < 3)) {
|
||||||
$preview = "";
|
|
||||||
|
|
||||||
// Handle enclosures and treat them as preview picture
|
// Handle enclosures and treat them as preview picture
|
||||||
foreach ($attachments AS $attachment) {
|
foreach ($attachments AS $attachment) {
|
||||||
if ($attachment["type"] == "image/jpeg") {
|
if ($attachment["type"] == "image/jpeg") {
|
||||||
|
@ -410,6 +410,7 @@ class Feed {
|
||||||
if (!empty($tags)) {
|
if (!empty($tags)) {
|
||||||
$item["tag"] = $tags;
|
$item["tag"] = $tags;
|
||||||
} else {
|
} else {
|
||||||
|
// @todo $preview is never set in this case, is it intended? - @MrPetovan 2018-02-13
|
||||||
$item["tag"] = add_page_keywords($item["plink"], $preview, true, $contact["ffi_keyword_blacklist"]);
|
$item["tag"] = add_page_keywords($item["plink"], $preview, true, $contact["ffi_keyword_blacklist"]);
|
||||||
}
|
}
|
||||||
$item["body"] .= "\n".$item['tag'];
|
$item["body"] .= "\n".$item['tag'];
|
||||||
|
|
|
@ -71,55 +71,34 @@ class OStatus
|
||||||
}
|
}
|
||||||
$author["contact-id"] = $contact["id"];
|
$author["contact-id"] = $contact["id"];
|
||||||
|
|
||||||
$found = false;
|
$contact = null;
|
||||||
|
|
||||||
if ($aliaslink != '') {
|
if ($aliaslink != '') {
|
||||||
$condition = ["`uid` = ? AND `alias` = ? AND `network` != ?",
|
$condition = ["`uid` = ? AND `alias` = ? AND `network` != ?",
|
||||||
$importer["uid"], $aliaslink, NETWORK_STATUSNET];
|
$importer["uid"], $aliaslink, NETWORK_STATUSNET];
|
||||||
$r = dba::selectFirst('contact', [], $condition);
|
$contact = dba::selectFirst('contact', [], $condition);
|
||||||
|
|
||||||
if (DBM::is_result($r)) {
|
|
||||||
$found = true;
|
|
||||||
if ($r['blocked']) {
|
|
||||||
$r['id'] = -1;
|
|
||||||
}
|
|
||||||
$contact = $r;
|
|
||||||
$author["contact-id"] = $r["id"];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$found && ($author["author-link"] != "")) {
|
if (!DBM::is_result($contact) && $author["author-link"] != '') {
|
||||||
if ($aliaslink == "") {
|
if ($aliaslink == "") {
|
||||||
$aliaslink = $author["author-link"];
|
$aliaslink = $author["author-link"];
|
||||||
}
|
}
|
||||||
|
|
||||||
$condition = ["`uid` = ? AND `nurl` IN (?, ?) AND `network` != ?", $importer["uid"],
|
$condition = ["`uid` = ? AND `nurl` IN (?, ?) AND `network` != ?", $importer["uid"],
|
||||||
normalise_link($author["author-link"]), normalise_link($aliaslink), NETWORK_STATUSNET];
|
normalise_link($author["author-link"]), normalise_link($aliaslink), NETWORK_STATUSNET];
|
||||||
$r = dba::selectFirst('contact', [], $condition);
|
$contact = dba::selectFirst('contact', [], $condition);
|
||||||
|
|
||||||
if (DBM::is_result($r)) {
|
|
||||||
$found = true;
|
|
||||||
if ($r['blocked']) {
|
|
||||||
$r['id'] = -1;
|
|
||||||
}
|
|
||||||
$contact = $r;
|
|
||||||
$author["contact-id"] = $r["id"];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$found && ($addr != "")) {
|
if (!DBM::is_result($contact) && ($addr != '')) {
|
||||||
$condition = ["`uid` = ? AND `addr` = ? AND `network` != ?",
|
$condition = ["`uid` = ? AND `addr` = ? AND `network` != ?",
|
||||||
$importer["uid"], $addr, NETWORK_STATUSNET];
|
$importer["uid"], $addr, NETWORK_STATUSNET];
|
||||||
$r = dba::selectFirst('contact', [], $condition);
|
$contact = dba::selectFirst('contact', [], $condition);
|
||||||
|
}
|
||||||
|
|
||||||
if (DBM::is_result($r)) {
|
if (DBM::is_result($contact)) {
|
||||||
$found = true;
|
if ($contact['blocked']) {
|
||||||
if ($r['blocked']) {
|
$contact['id'] = -1;
|
||||||
$r['id'] = -1;
|
|
||||||
}
|
|
||||||
$contact = $r;
|
|
||||||
$author["contact-id"] = $r["id"];
|
|
||||||
}
|
}
|
||||||
|
$author["contact-id"] = $contact["id"];
|
||||||
}
|
}
|
||||||
|
|
||||||
$avatarlist = [];
|
$avatarlist = [];
|
||||||
|
@ -154,7 +133,7 @@ class OStatus
|
||||||
$author["owner-avatar"] = $author["author-avatar"];
|
$author["owner-avatar"] = $author["author-avatar"];
|
||||||
|
|
||||||
// Only update the contacts if it is an OStatus contact
|
// Only update the contacts if it is an OStatus contact
|
||||||
if ($r && ($r['id'] > 0) && !$onlyfetch && ($contact["network"] == NETWORK_OSTATUS)) {
|
if (DBM::is_result($contact) && ($contact['id'] > 0) && !$onlyfetch && ($contact["network"] == NETWORK_OSTATUS)) {
|
||||||
|
|
||||||
// Update contact data
|
// Update contact data
|
||||||
$current = $contact;
|
$current = $contact;
|
||||||
|
@ -738,6 +717,7 @@ class OStatus
|
||||||
|
|
||||||
$links = $xpath->query('//link');
|
$links = $xpath->query('//link');
|
||||||
if ($links) {
|
if ($links) {
|
||||||
|
$file = '';
|
||||||
foreach ($links as $link) {
|
foreach ($links as $link) {
|
||||||
$attribute = self::readAttributes($link);
|
$attribute = self::readAttributes($link);
|
||||||
if (($attribute['rel'] == 'alternate') && ($attribute['type'] == 'application/atom+xml')) {
|
if (($attribute['rel'] == 'alternate') && ($attribute['type'] == 'application/atom+xml')) {
|
||||||
|
@ -1251,6 +1231,7 @@ class OStatus
|
||||||
$root->setAttribute("xmlns:statusnet", NAMESPACE_STATUSNET);
|
$root->setAttribute("xmlns:statusnet", NAMESPACE_STATUSNET);
|
||||||
$root->setAttribute("xmlns:mastodon", NAMESPACE_MASTODON);
|
$root->setAttribute("xmlns:mastodon", NAMESPACE_MASTODON);
|
||||||
|
|
||||||
|
$title = '';
|
||||||
switch ($filter) {
|
switch ($filter) {
|
||||||
case 'activity': $title = L10n::t('%s\'s timeline', $owner['name']); break;
|
case 'activity': $title = L10n::t('%s\'s timeline', $owner['name']); break;
|
||||||
case 'posts' : $title = L10n::t('%s\'s posts' , $owner['name']); break;
|
case 'posts' : $title = L10n::t('%s\'s posts' , $owner['name']); break;
|
||||||
|
@ -1385,10 +1366,7 @@ class OStatus
|
||||||
*/
|
*/
|
||||||
private static function addAuthor($doc, $owner)
|
private static function addAuthor($doc, $owner)
|
||||||
{
|
{
|
||||||
$r = q("SELECT `homepage`, `publish` FROM `profile` WHERE `uid` = %d AND `is-default` LIMIT 1", intval($owner["uid"]));
|
$profile = dba::selectFirst('profile', ['homepage', 'publish'], ['uid' => $owner['uid'], 'is-default' => true]);
|
||||||
if (DBM::is_result($r)) {
|
|
||||||
$profile = $r[0];
|
|
||||||
}
|
|
||||||
$author = $doc->createElement("author");
|
$author = $doc->createElement("author");
|
||||||
XML::addElement($doc, $author, "id", $owner["url"]);
|
XML::addElement($doc, $author, "id", $owner["url"]);
|
||||||
XML::addElement($doc, $author, "activity:object-type", ACTIVITY_OBJ_PERSON);
|
XML::addElement($doc, $author, "activity:object-type", ACTIVITY_OBJ_PERSON);
|
||||||
|
@ -1428,6 +1406,7 @@ class OStatus
|
||||||
$author->appendChild($element);
|
$author->appendChild($element);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (DBM::is_result($profile)) {
|
||||||
if (trim($profile["homepage"]) != "") {
|
if (trim($profile["homepage"]) != "") {
|
||||||
$urls = $doc->createElement("poco:urls");
|
$urls = $doc->createElement("poco:urls");
|
||||||
XML::addElement($doc, $urls, "poco:type", "homepage");
|
XML::addElement($doc, $urls, "poco:type", "homepage");
|
||||||
|
@ -1436,7 +1415,6 @@ class OStatus
|
||||||
$author->appendChild($urls);
|
$author->appendChild($urls);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($profile)) {
|
|
||||||
XML::addElement($doc, $author, "followers", "", ["url" => System::baseUrl()."/viewcontacts/".$owner["nick"]]);
|
XML::addElement($doc, $author, "followers", "", ["url" => System::baseUrl()."/viewcontacts/".$owner["nick"]]);
|
||||||
XML::addElement($doc, $author, "statusnet:profile_info", "", ["local_id" => $owner["uid"]]);
|
XML::addElement($doc, $author, "statusnet:profile_info", "", ["local_id" => $owner["uid"]]);
|
||||||
}
|
}
|
||||||
|
@ -1495,6 +1473,8 @@ class OStatus
|
||||||
*/
|
*/
|
||||||
private static function entry($doc, $item, $owner, $toplevel = false)
|
private static function entry($doc, $item, $owner, $toplevel = false)
|
||||||
{
|
{
|
||||||
|
$xml = null;
|
||||||
|
|
||||||
$repeated_guid = self::getResharedGuid($item);
|
$repeated_guid = self::getResharedGuid($item);
|
||||||
if ($repeated_guid != "") {
|
if ($repeated_guid != "") {
|
||||||
$xml = self::reshareEntry($doc, $item, $owner, $repeated_guid, $toplevel);
|
$xml = self::reshareEntry($doc, $item, $owner, $repeated_guid, $toplevel);
|
||||||
|
|
|
@ -317,6 +317,7 @@ class PortableContact
|
||||||
$contact['created'] = DateTimeFormat::utcNow();
|
$contact['created'] = DateTimeFormat::utcNow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$server_url = '';
|
||||||
if ($force) {
|
if ($force) {
|
||||||
$server_url = normalise_link(self::detectServer($profile));
|
$server_url = normalise_link(self::detectServer($profile));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue