mirror of
https://github.com/friendica/friendica
synced 2024-12-24 02:00:15 +00:00
Just some more code :-)
This commit is contained in:
parent
1d4de96960
commit
613f6b9b32
1 changed files with 55 additions and 42 deletions
|
@ -72,7 +72,9 @@ class dfrn2 {
|
||||||
$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("SELECT * FROM `contact` WHERE `uid` = %d AND `nurl` IN ('%s', '%s') AND `network` != '%s'",
|
$r = q("SELECT `id`, `uid`, `network`, `avatar-date`, `name-date`, `uri-date`, `addr`,
|
||||||
|
`name`, `nick`, `about`, `location`, `keywords`, `bdyear`, `bd`
|
||||||
|
FROM `contact` WHERE `uid` = %d AND `nurl` IN ('%s', '%s') AND `network` != '%s'",
|
||||||
intval($importer["uid"]), dbesc(normalise_link($author["author-link"])),
|
intval($importer["uid"]), dbesc(normalise_link($author["author-link"])),
|
||||||
dbesc(normalise_link($author["link"])), dbesc(NETWORK_STATUSNET));
|
dbesc(normalise_link($author["link"])), dbesc(NETWORK_STATUSNET));
|
||||||
if ($r) {
|
if ($r) {
|
||||||
|
@ -115,15 +117,11 @@ class dfrn2 {
|
||||||
if ($attributes->name == "updated")
|
if ($attributes->name == "updated")
|
||||||
$contact["name-date"] = $attributes->textContent;
|
$contact["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")
|
||||||
$contact["uri-date"] = $attributes->textContent;
|
$contact["uri-date"] = $attributes->textContent;
|
||||||
|
|
||||||
// is it a public forum? Private forums aren't supported by now with this method
|
|
||||||
$contact["forum"] = intval($xpath->evaluate($element.'/dfrn:community/text()', $context)->item(0)->nodeValue);
|
|
||||||
|
|
||||||
// Update contact data
|
// Update contact data
|
||||||
$value = $xpath->evaluate($element.'/dfrn:handle/text()', $context)->item(0)->nodeValue;
|
$value = $xpath->evaluate($element.'/dfrn:handle/text()', $context)->item(0)->nodeValue;
|
||||||
if ($value != "")
|
if ($value != "")
|
||||||
|
@ -188,37 +186,49 @@ class dfrn2 {
|
||||||
$contact["bd"] = $value;
|
$contact["bd"] = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($old_bdyear != $contact["bdyear"])
|
//if ($old_bdyear != $contact["bdyear"])
|
||||||
self::birthday_event($contact, $birthday;
|
// self::birthday_event($contact, $birthday);
|
||||||
|
|
||||||
print_r($contact);
|
// Get all field names
|
||||||
die();
|
$fields = array();
|
||||||
/*
|
foreach ($r[0] AS $field => $data)
|
||||||
if (($contact["name"] != $r[0]["name"]) OR ($contact["nick"] != $r[0]["nick"]) OR ($contact["about"] != $r[0]["about"]) OR ($contact["location"] != $r[0]["location"])) {
|
$fields[$field] = $data;
|
||||||
|
|
||||||
|
unset($fields["id"]);
|
||||||
|
unset($fields["uid"]);
|
||||||
|
|
||||||
|
foreach ($fields AS $field => $data)
|
||||||
|
if ($contact[$field] != $r[0][$field])
|
||||||
|
$update = true;
|
||||||
|
|
||||||
|
if ($update) {
|
||||||
logger("Update contact data for contact ".$contact["id"], LOGGER_DEBUG);
|
logger("Update contact data for contact ".$contact["id"], LOGGER_DEBUG);
|
||||||
|
|
||||||
q("UPDATE `contact` SET `name` = '%s', `nick` = '%s', `about` = '%s', `location` = '%s', `name-date` = '%s' WHERE `id` = %d AND `network` = '%s'",
|
q("UPDATE `contact` SET `name` = '%s', `nick` = '%s', `about` = '%s', `location` = '%s',
|
||||||
|
`addr` = '%s', `keywords` = '%s', `bdyear` = '%s', `bd` = '%s'
|
||||||
|
`avatar-date` = '%s', `name-date` = '%s', `uri-date` = '%s'
|
||||||
|
WHERE `id` = %d AND `network` = '%s'",
|
||||||
dbesc($contact["name"]), dbesc($contact["nick"]), dbesc($contact["about"]), dbesc($contact["location"]),
|
dbesc($contact["name"]), dbesc($contact["nick"]), dbesc($contact["about"]), dbesc($contact["location"]),
|
||||||
dbesc(datetime_convert()), intval($contact["id"]), dbesc(NETWORK_OSTATUS));
|
dbesc($contact["addr"]), dbesc($contact["keywords"]), dbesc($contact["bdyear"]),
|
||||||
|
dbesc($contact["bd"]), dbesc($contact["avatar-date"]), dbesc($contact["name-date"]), dbesc($contact["uri-date"]),
|
||||||
|
intval($contact["id"]), dbesc($contact["network"]));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($author["author-avatar"]) AND ($author["author-avatar"] != $r[0]['photo'])) {
|
if ((isset($author["avatar"]) AND ($author["avatar"] != $r[0]["photo"])) OR
|
||||||
|
($contact["avatar-date"] != $r[0]["avatar-date"])) {
|
||||||
logger("Update profile picture for contact ".$contact["id"], LOGGER_DEBUG);
|
logger("Update profile picture for contact ".$contact["id"], LOGGER_DEBUG);
|
||||||
|
|
||||||
$photos = import_profile_photo($author["author-avatar"], $importer["uid"], $contact["id"]);
|
$photos = import_profile_photo($author["avatar"], $importer["uid"], $contact["id"]);
|
||||||
|
|
||||||
q("UPDATE `contact` SET `photo` = '%s', `thumb` = '%s', `micro` = '%s', `avatar-date` = '%s' WHERE `id` = %d AND `network` = '%s'",
|
q("UPDATE `contact` SET `photo` = '%s', `thumb` = '%s', `micro` = '%s', `avatar-date` = '%s' WHERE `id` = %d AND `network` = '%s'",
|
||||||
dbesc($author["author-avatar"]), dbesc($photos[1]), dbesc($photos[2]),
|
dbesc($author["avatar"]), dbesc($photos[1]), dbesc($photos[2]),
|
||||||
dbesc(datetime_convert()), intval($contact["id"]), dbesc(NETWORK_OSTATUS));
|
dbesc($contact["avatar-date"]), intval($contact["id"]), dbesc($contact["network"]));
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
/// @todo Add the "addr" field
|
$contact["generation"] = 2;
|
||||||
// $contact["generation"] = 2;
|
$contact["photo"] = $author["avatar"];
|
||||||
// $contact["photo"] = $author["avatar"];
|
print_r($contact);
|
||||||
//print_r($contact);
|
update_gcontact($contact);
|
||||||
//update_gcontact($contact);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return($author);
|
return($author);
|
||||||
|
@ -261,6 +271,9 @@ die();
|
||||||
// Only the "dfrn:owner" in the head section contains all data
|
// Only the "dfrn:owner" in the head section contains all data
|
||||||
self::fetchauthor($xpath, $doc->firstChild, $importer, "dfrn:owner", $contact, false);
|
self::fetchauthor($xpath, $doc->firstChild, $importer, "dfrn:owner", $contact, false);
|
||||||
|
|
||||||
|
// is it a public forum? Private forums aren't supported by now with this method
|
||||||
|
//$contact["forum"] = intval($xpath->evaluate($element.'/dfrn:community/text()', $context)->item(0)->nodeValue);
|
||||||
|
|
||||||
$entries = $xpath->query('/atom:feed/atom:entry');
|
$entries = $xpath->query('/atom:feed/atom:entry');
|
||||||
|
|
||||||
$item_id = 0;
|
$item_id = 0;
|
||||||
|
|
Loading…
Reference in a new issue