if(link_compare($post->actor->url, $own_id)) {
$contactid = $self[0]['id'];
} else {
- $r = q("SELECT * FROM `contact` WHERE `url` = '%s' AND `uid` = %d AND `blocked` = 0 AND `readonly` = 0 LIMIT 1",
- dbesc($post->actor->url),
+ $r = q("SELECT * FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d AND `blocked` = 0 AND `readonly` = 0 LIMIT 1",
+ dbesc(normalise_link($post->actor->url)),
intval($uid)
);
function pumpio_get_contact($uid, $contact, $no_insert = false) {
- if (function_exists("update_gcontact")) {
- update_gcontact(array("url" => $contact->url, "network" => NETWORK_PUMPIO, "generation" => 2,
- "photo" => $contact->image->url, "name" => $contact->displayName, "hide" => true,
- "nick" => $contact->preferredUsername, "location" => $contact->location->displayName,
- "about" => $contact->summary, "addr" => str_replace("acct:", "", $contact->id)));
-
- $cid = get_contact($contact->url, $uid);
- } else {
- // Old Code
- $r = q("SELECT id FROM unique_contacts WHERE url='%s' LIMIT 1",
- dbesc(normalise_link($contact->url)));
-
- if (count($r) == 0)
- q("INSERT INTO unique_contacts (url, name, nick, avatar) VALUES ('%s', '%s', '%s', '%s')",
- dbesc(normalise_link($contact->url)),
- dbesc($contact->displayName),
- dbesc($contact->preferredUsername),
- dbesc($contact->image->url));
- else
- q("UPDATE unique_contacts SET name = '%s', nick = '%s', avatar = '%s' WHERE url = '%s'",
- dbesc($contact->displayName),
- dbesc($contact->preferredUsername),
- dbesc($contact->image->url),
- dbesc(normalise_link($contact->url)));
-
- if (DB_UPDATE_VERSION >= "1177")
- q("UPDATE `unique_contacts` SET `location` = '%s', `about` = '%s' WHERE url = '%s'",
- dbesc($contact->location->displayName),
- dbesc($contact->summary),
- dbesc(normalise_link($contact->url)));
-
- $cid = 0;
- }
+ update_gcontact(array("url" => $contact->url, "network" => NETWORK_PUMPIO, "generation" => 2,
+ "photo" => $contact->image->url, "name" => $contact->displayName, "hide" => true,
+ "nick" => $contact->preferredUsername, "location" => $contact->location->displayName,
+ "about" => $contact->summary, "addr" => str_replace("acct:", "", $contact->id)));
+ $cid = get_contact($contact->url, $uid);
if ($no_insert)
return($cid);
- $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `url` = '%s' LIMIT 1",
- intval($uid), dbesc($contact->url));
+ $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `nurl` = '%s' LIMIT 1",
+ intval($uid), dbesc(normalise_link($contact->url)));
- if(!count($r)) {
+ if (!count($r)) {
// create contact record
- q("INSERT INTO `contact` ( `uid`, `created`, `url`, `nurl`, `addr`, `alias`, `notify`, `poll`,
+ q("INSERT INTO `contact` (`uid`, `created`, `url`, `nurl`, `addr`, `alias`, `notify`, `poll`,
`name`, `nick`, `photo`, `network`, `rel`, `priority`,
`writable`, `blocked`, `readonly`, `pending` )
- VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, 0, 0, 0 ) ",
+ VALUES (%d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, 0, 0, 0)",
intval($uid),
dbesc(datetime_convert()),
dbesc($contact->url),
intval(1)
);
- $r = q("SELECT * FROM `contact` WHERE `url` = '%s' AND `uid` = %d LIMIT 1",
- dbesc($contact->url),
+ $r = q("SELECT * FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d LIMIT 1",
+ dbesc(normalise_link($contact->url)),
intval($uid)
);
- if(! count($r))
+ if (!count($r)) {
return(false);
+ }
- $contact_id = $r[0]['id'];
+ $contact_id = $r[0]['id'];
$g = q("select def_gid from user where uid = %d limit 1",
intval($uid)
$post->actor->image->url = $self[0]['photo'];
} elseif ($contact_id == 0) {
// Take an existing contact, the contact of the note or - as a fallback - the id of the user
- $r = q("SELECT * FROM `contact` WHERE `url` = '%s' AND `uid` = %d AND `blocked` = 0 AND `readonly` = 0 LIMIT 1",
- dbesc($post->actor->url),
+ $r = q("SELECT * FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d AND `blocked` = 0 AND `readonly` = 0 LIMIT 1",
+ dbesc(normalise_link($post->actor->url)),
intval($uid)
);
if(count($r))
$contact_id = $r[0]['id'];
else {
- $r = q("SELECT * FROM `contact` WHERE `url` = '%s' AND `uid` = %d AND `blocked` = 0 AND `readonly` = 0 LIMIT 1",
- dbesc($post->actor->url),
+ $r = q("SELECT * FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d AND `blocked` = 0 AND `readonly` = 0 LIMIT 1",
+ dbesc(normalise_link($post->actor->url)),
intval($uid)
);