X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fsocgraph.php;h=186326f42d961a11ca39c9e002f7b8b16ec07692;hb=9619829b4ab693bdbe2e24071e3d39d840d855b0;hp=8ad7a4cd31104ace048e793de8d055d206d8995a;hpb=2ca6cdf6b6e0fa4a04fb1d1fb6bf5d83f9ba74e8;p=friendica.git diff --git a/include/socgraph.php b/include/socgraph.php index 8ad7a4cd31..186326f42d 100644 --- a/include/socgraph.php +++ b/include/socgraph.php @@ -11,7 +11,7 @@ require_once('include/datetime.php'); require_once("include/Scrape.php"); require_once("include/html2bbcode.php"); require_once("include/Contact.php"); - +require_once("include/Photo.php"); /* * poco_load @@ -438,44 +438,47 @@ function poco_last_updated($profile, $force = false) { $noscrape = json_decode($noscraperet["body"], true); - $contact = array("url" => $profile, - "network" => $server[0]["network"], - "generation" => $gcontacts[0]["generation"]); + if (is_array($noscrape)) { + $contact = array("url" => $profile, + "network" => $server[0]["network"], + "generation" => $gcontacts[0]["generation"]); - $contact["name"] = $noscrape["fn"]; - $contact["community"] = $noscrape["comm"]; + $contact["name"] = $noscrape["fn"]; + $contact["community"] = $noscrape["comm"]; - if (isset($noscrape["tags"])) { - $keywords = implode(" ", $noscrape["tags"]); - if ($keywords != "") - $contact["keywords"] = $keywords; - } + if (isset($noscrape["tags"])) { + $keywords = implode(" ", $noscrape["tags"]); + if ($keywords != "") + $contact["keywords"] = $keywords; + } + + $location = formatted_location($noscrape); + if ($location) + $contact["location"] = $location; + + $contact["notify"] = $noscrape["dfrn-notify"]; + + // Remove all fields that are not present in the gcontact table + unset($noscrape["fn"]); + unset($noscrape["key"]); + unset($noscrape["homepage"]); + unset($noscrape["comm"]); + unset($noscrape["tags"]); + unset($noscrape["locality"]); + unset($noscrape["region"]); + unset($noscrape["country-name"]); + unset($noscrape["contacts"]); + unset($noscrape["dfrn-request"]); + unset($noscrape["dfrn-confirm"]); + unset($noscrape["dfrn-notify"]); + unset($noscrape["dfrn-poll"]); - $location = formatted_location($noscrape); - if ($location) - $contact["location"] = $location; - - $contact["notify"] = $noscrape["dfrn-notify"]; - - // Remove all fields that are not present in the gcontact table - unset($noscrape["fn"]); - unset($noscrape["key"]); - unset($noscrape["homepage"]); - unset($noscrape["comm"]); - unset($noscrape["tags"]); - unset($noscrape["locality"]); - unset($noscrape["region"]); - unset($noscrape["country-name"]); - unset($noscrape["contacts"]); - unset($noscrape["dfrn-request"]); - unset($noscrape["dfrn-confirm"]); - unset($noscrape["dfrn-notify"]); - unset($noscrape["dfrn-poll"]); - - $contact = array_merge($contact, $noscrape); - update_gcontact($contact); - - return $noscrape["updated"]; + $contact = array_merge($contact, $noscrape); + + update_gcontact($contact); + + return $noscrape["updated"]; + } } } } @@ -1422,6 +1425,14 @@ function update_gcontact($contact) { unset($fields["url"]); unset($fields["updated"]); + // Bugfix: We had an error in the storing of keywords which lead to the "0" + // This value is still transmitted via poco. + if ($contact["keywords"] == "0") + unset($contact["keywords"]); + + if ($r[0]["keywords"] == "0") + $r[0]["keywords"] = ""; + // assign all unassigned fields from the database entry foreach ($fields AS $field => $data) if (!isset($contact[$field]) OR ($contact[$field] == "")) @@ -1433,6 +1444,28 @@ function update_gcontact($contact) { if (!isset($contact["updated"])) $contact["updated"] = datetime_convert(); + if ($contact["server_url"] == "") { + $server_url = $contact["url"]; + + $server_url = matching_url($server_url, $contact["alias"]); + if ($server_url != "") + $contact["server_url"] = $server_url; + + $server_url = matching_url($server_url, $contact["photo"]); + if ($server_url != "") + $contact["server_url"] = $server_url; + + $server_url = matching_url($server_url, $contact["notify"]); + if ($server_url != "") + $contact["server_url"] = $server_url; + } else + $contact["server_url"] = normalise_link($contact["server_url"]); + + if (($contact["addr"] == "") AND ($contact["server_url"] != "") AND ($contact["nick"] != "")) { + $hostname = str_replace("http://", "", $contact["server_url"]); + $contact["addr"] = $contact["nick"]."@".$hostname; + } + // Check if any field changed $update = false; unset($fields["generation"]); @@ -1467,6 +1500,28 @@ function update_gcontact($contact) { intval($contact["generation"]), dbesc($contact["updated"]), dbesc($contact["server_url"]), dbesc($contact["connect"]), dbesc(normalise_link($contact["url"])), intval($contact["generation"])); + + + // Now update the contact entry with the user id "0" as well. + // This is used for the shadow copies of public items. + $r = q("SELECT `id` FROM `contact` WHERE `nurl` = '%s' AND `uid` = 0 ORDER BY `id` LIMIT 1", + dbesc(normalise_link($contact["url"]))); + + if ($r) { + logger("Update shadow contact ".$r[0]["id"], LOGGER_DEBUG); + + update_contact_avatar($contact["photo"], 0, $r[0]["id"]); + + q("UPDATE `contact` SET `name` = '%s', `nick` = '%s', `addr` = '%s', + `network` = '%s', `bd` = '%s', `gender` = '%s', + `keywords` = '%s', `alias` = '%s', `url` = '%s', + `location` = '%s', `about` = '%s' + WHERE `id` = %d", + dbesc($contact["name"]), dbesc($contact["nick"]), dbesc($contact["addr"]), + dbesc($contact["network"]), dbesc($contact["birthday"]), dbesc($contact["gender"]), + dbesc($contact["keywords"]), dbesc($contact["alias"]), dbesc($contact["url"]), + dbesc($contact["location"]), dbesc($contact["about"]), intval($r[0]["id"])); + } } return $gcontact_id;