$version = trim(str_replace("X-Diaspora-Version:", "", $line));
$version = trim(str_replace("x-diaspora-version:", "", $version));
$network = NETWORK_DIASPORA;
+ $versionparts = explode("-", $version);
+ $version = $versionparts[0];
}
}
}
if (!$gcontact_id)
return false;
- $r = q("SELECT `name`, `nick`, `photo`, `location`, `about`, `addr`, `generation`, `birthday`, `gender`, `keywords`, `hide`, `nsfw`
+ $r = q("SELECT `name`, `nick`, `photo`, `location`, `about`, `addr`, `generation`, `birthday`, `gender`, `keywords`, `hide`, `nsfw`, `network`
FROM `gcontact` WHERE `id` = %d LIMIT 1",
intval($gcontact_id));
if (!isset($contact["nsfw"]))
$contact["nsfw"] = $r[0]["nsfw"];
+ if ($contact["network"] =="")
+ $contact["network"] = $r[0]["network"];
+
if ($contact["network"] == NETWORK_STATUSNET)
$contact["network"] = NETWORK_OSTATUS;
if (($contact["photo"] != $r[0]["photo"]) OR ($contact["name"] != $r[0]["name"]) OR ($contact["nick"] != $r[0]["nick"]) OR ($contact["addr"] != $r[0]["addr"]) OR
($contact["birthday"] != $r[0]["birthday"]) OR ($contact["gender"] != $r[0]["gender"]) OR ($contact["keywords"] != $r[0]["keywords"]) OR
- ($contact["hide"] != $r[0]["hide"]) OR ($contact["nsfw"] != $r[0]["nsfw"]) OR
+ ($contact["hide"] != $r[0]["hide"]) OR ($contact["nsfw"] != $r[0]["nsfw"]) OR ($contact["network"] != $r[0]["network"]) OR
($contact["location"] != $r[0]["location"]) OR ($contact["about"] != $r[0]["about"]) OR ($contact["generation"] < $r[0]["generation"])) {
- q("UPDATE `gcontact` SET `photo` = '%s', `name` = '%s', `nick` = '%s', `addr` = '%s',
+ q("UPDATE `gcontact` SET `photo` = '%s', `name` = '%s', `nick` = '%s', `addr` = '%s', `network` = '%s',
`birthday` = '%s', `gender` = '%s', `keywords` = %d, `hide` = %d, `nsfw` = %d,
`location` = '%s', `about` = '%s', `generation` = %d, `updated` = '%s'
- WHERE `nurl` = '%s' AND `network` = '%s' AND (`generation` = 0 OR `generation` >= %d)",
- dbesc($contact["photo"]), dbesc($contact["name"]), dbesc($contact["nick"]), dbesc($contact["addr"]),
+ WHERE `nurl` = '%s' AND (`generation` = 0 OR `generation` >= %d)",
+ dbesc($contact["photo"]), dbesc($contact["name"]), dbesc($contact["nick"]),
+ dbesc($contact["addr"]), dbesc($contact["network"]),
dbesc($contact["birthday"]), dbesc($contact["gender"]), dbesc($contact["keywords"]),
intval($contact["hide"]), intval($contact["nsfw"]),
dbesc($contact["location"]), dbesc($contact["about"]), intval($contact["generation"]), dbesc(datetime_convert()),
- dbesc(normalise_link($contact["url"])), dbesc($contact["network"]), intval($contact["generation"]));
+ dbesc(normalise_link($contact["url"])), intval($contact["generation"]));
}
return $gcontact_id;
AND (normalise_link($parent_contact["url"]) != normalise_link($thrparent[0]["author-link"]))) {
$parent_contact = null;
+ // @todo: Use gcontact
require_once("include/Scrape.php");
$probed_contact = probe_url($thrparent[0]["author-link"]);
if ($probed_contact["network"] != NETWORK_FEED) {
//is it a link or a full dfrn address?
if((strpos($name,'@')) || (strpos($name,'http://'))) {
$newname = $name;
+
//get the profile links
$links = @lrdd($name);
if(count($links)) {
$inform .= 'cid:' . $r[0]['id'];
}
}
+
+ if(!isset($profile)) {
+ $r = q("SELECT `url` FROM `gcontact` WHERE `addr` = '%s' LIMIT 1",
+ dbesc($name));
+ if ($r)
+ $profile = $r[0]["url"];
+ }
+
//if there is an url for this persons profile
if(isset($profile)) {
+
+ $r = q("SELECT `nick`, `name`, `network` FROM `gcontact` WHERE `nurl` = '%s' LIMIT 1",
+ dbesc(normalise_link($profile)));
+ if ($r) {
+ $newname = $r[0]["name"];
+
+ //set newname to nick
+ if(($r[0]['network'] === NETWORK_OSTATUS) OR ($r[0]['network'] === NETWORK_TWITTER)
+ OR ($r[0]['network'] === NETWORK_STATUSNET) OR ($r[0]['network'] === NETWORK_APPNET)) {
+ $newname = $r[0]['nick'];
+ }
+ }
+
$replaced = true;
//create profile link
$profile = str_replace(',','%2c',$profile);