1
1
Fork 0

Just some more code :-)

This commit is contained in:
Michael Vogel 2016-01-27 20:06:23 +01:00
parent 1d4de96960
commit 613f6b9b32

View file

@ -72,7 +72,9 @@ class dfrn2 {
$author["name"] = $xpath->evaluate($element.'/atom:name/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"])),
dbesc(normalise_link($author["link"])), dbesc(NETWORK_STATUSNET));
if ($r) {
@ -115,15 +117,11 @@ class dfrn2 {
if ($attributes->name == "updated")
$contact["name-date"] = $attributes->textContent;
$link_element = $xpath->query($element."/atom:link", $context)->item(0);
foreach($link_element->attributes AS $attributes)
if ($attributes->name == "updated")
$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
$value = $xpath->evaluate($element.'/dfrn:handle/text()', $context)->item(0)->nodeValue;
if ($value != "")
@ -188,37 +186,49 @@ class dfrn2 {
$contact["bd"] = $value;
}
if ($old_bdyear != $contact["bdyear"])
self::birthday_event($contact, $birthday;
//if ($old_bdyear != $contact["bdyear"])
// self::birthday_event($contact, $birthday);
print_r($contact);
die();
/*
if (($contact["name"] != $r[0]["name"]) OR ($contact["nick"] != $r[0]["nick"]) OR ($contact["about"] != $r[0]["about"]) OR ($contact["location"] != $r[0]["location"])) {
// Get all field names
$fields = array();
foreach ($r[0] AS $field => $data)
$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);
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(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);
$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'",
dbesc($author["author-avatar"]), dbesc($photos[1]), dbesc($photos[2]),
dbesc(datetime_convert()), intval($contact["id"]), dbesc(NETWORK_OSTATUS));
dbesc($author["avatar"]), dbesc($photos[1]), dbesc($photos[2]),
dbesc($contact["avatar-date"]), intval($contact["id"]), dbesc($contact["network"]));
}
*/
/// @todo Add the "addr" field
// $contact["generation"] = 2;
// $contact["photo"] = $author["avatar"];
//print_r($contact);
//update_gcontact($contact);
$contact["generation"] = 2;
$contact["photo"] = $author["avatar"];
print_r($contact);
update_gcontact($contact);
}
return($author);
@ -261,6 +271,9 @@ die();
// Only the "dfrn:owner" in the head section contains all data
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');
$item_id = 0;