Updated function call for updating the global contacts.

This commit is contained in:
Michael Vogel 2016-01-06 15:10:22 +01:00
parent 3b54203d80
commit bed435d76a
4 changed files with 109 additions and 114 deletions

View file

@ -909,35 +909,35 @@ function statusnet_fetch_contact($uid, $contact, $create_user) {
return(-1);
if (function_exists("update_gcontact"))
update_gcontact($contact->statusnet_profile_url,
NETWORK_STATUSNET, $contact->profile_image_url,
$contact->name, $contact->screen_name,
$contact->location, $contact->description,
statusnet_address($contact));
update_gcontact(array("url" => $contact->statusnet_profile_url,
"network" => NETWORK_STATUSNET, "photo" => $contact->profile_image_url,
"name" => $contact->name, "nick" => $contact->screen_name,
"location" => $contact->location, "about" => $contact->description,
"addr" => statusnet_address($contact), "generation" => 3));
else {
// Old Code
$r = q("SELECT id FROM unique_contacts WHERE url='%s' LIMIT 1",
dbesc(normalise_link($contact->statusnet_profile_url)));
// Check if the unique contact is existing
// To-Do: only update once a while
$r = q("SELECT id FROM unique_contacts WHERE url='%s' LIMIT 1",
dbesc(normalise_link($contact->statusnet_profile_url)));
if (count($r) == 0)
q("INSERT INTO unique_contacts (url, name, nick, avatar) VALUES ('%s', '%s', '%s', '%s')",
dbesc(normalise_link($contact->statusnet_profile_url)),
dbesc($contact->name),
dbesc($contact->screen_name),
dbesc($contact->profile_image_url));
else
q("UPDATE unique_contacts SET name = '%s', nick = '%s', avatar = '%s' WHERE url = '%s'",
dbesc($contact->name),
dbesc($contact->screen_name),
dbesc($contact->profile_image_url),
dbesc(normalise_link($contact->statusnet_profile_url)));
if (count($r) == 0)
q("INSERT INTO unique_contacts (url, name, nick, avatar) VALUES ('%s', '%s', '%s', '%s')",
dbesc(normalise_link($contact->statusnet_profile_url)),
dbesc($contact->name),
dbesc($contact->screen_name),
dbesc($contact->profile_image_url));
else
q("UPDATE unique_contacts SET name = '%s', nick = '%s', avatar = '%s' WHERE url = '%s'",
dbesc($contact->name),
dbesc($contact->screen_name),
dbesc($contact->profile_image_url),
dbesc(normalise_link($contact->statusnet_profile_url)));
if (DB_UPDATE_VERSION >= "1177")
q("UPDATE `unique_contacts` SET `location` = '%s', `about` = '%s' WHERE url = '%s'",
dbesc($contact->location),
dbesc($contact->description),
dbesc(normalise_link($contact->statusnet_profile_url)));
if (DB_UPDATE_VERSION >= "1177")
q("UPDATE `unique_contacts` SET `location` = '%s', `about` = '%s' WHERE url = '%s'",
dbesc($contact->location),
dbesc($contact->description),
dbesc(normalise_link($contact->statusnet_profile_url)));
}
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `alias` = '%s' AND `network` = '%s'LIMIT 1",
intval($uid), dbesc(normalise_link($contact->statusnet_profile_url)), dbesc(NETWORK_STATUSNET));