From: Michael Vogel Date: Thu, 8 Jan 2015 00:32:19 +0000 (+0100) Subject: The table "unique_contacts" now has an "about" and "location" field as well. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=46db8575a01d0d9a7ffd4ea647349e880950da0f;p=friendica.git The table "unique_contacts" now has an "about" and "location" field as well. --- diff --git a/include/dbstructure.php b/include/dbstructure.php index 008003e1b0..804f6f4c65 100644 --- a/include/dbstructure.php +++ b/include/dbstructure.php @@ -1251,6 +1251,8 @@ function db_definition() { "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), "avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "about" => array("type" => "text", "not null" => "1"), ), "indexes" => array( "PRIMARY" => array("id"), diff --git a/include/diaspora.php b/include/diaspora.php index 45feee87b5..af92d67a94 100755 --- a/include/diaspora.php +++ b/include/diaspora.php @@ -2213,6 +2213,21 @@ function diaspora_profile($importer,$xml,$msg) { intval($importer['uid']) ); + $profileurl = ""; + $author = q("SELECT * FROM `unique_contacts` WHERE `url`='%s' LIMIT 1", + dbesc(normalise_link($contact['url']))); + + if (count($author) == 0) { + q("INSERT INTO `unique_contacts` (`url`, `name`, `avatar`, `location`, `about`) VALUES ('%s', '%s', '%s', '%s', '%s')", + dbesc(normalise_link($contact['url'])), dbesc($name), dbesc($location), dbesc($about), dbesc($images[0])); + + $author = q("SELECT id FROM unique_contacts WHERE url='%s' LIMIT 1", + dbesc(normalise_link($contact['url']))); + } else if (normalise_link($contact['url']).$name.$location.$about != normalise_link($author[0]["url"]).$author[0]["name"].$author[0]["location"].$author[0]["about"]) { + q("UPDATE unique_contacts SET name = '%s', avatar = '%s', `location` = '%s', `about` = '%s' WHERE url = '%s'", + dbesc($name), dbesc($images[0]), dbesc($location), dbesc($about), dbesc(normalise_link($contact['url']))); + } + /* if($r) { if($oldphotos) { foreach($oldphotos as $ph) { diff --git a/mod/display.php b/mod/display.php index 9735ba921f..f2fde57878 100644 --- a/mod/display.php +++ b/mod/display.php @@ -98,14 +98,19 @@ function display_fetchauthor($a, $item) { $profiledata["about"] = bbcode($r[0]["about"]); if ($r[0]["nick"] != "") $profiledata["nickname"] = $r[0]["nick"]; - } else { - // Fetching profile data from unique contacts - $r = q("SELECT `avatar`, `nick` FROM `unique_contacts` WHERE `url` = '%s'", normalise_link($profiledata["url"])); - if (count($r)) { + } + + // Fetching profile data from unique contacts + $r = q("SELECT `avatar`, `nick`, `location`, `about` FROM `unique_contacts` WHERE `url` = '%s'", normalise_link($profiledata["url"])); + if (count($r)) { + if ($profiledata["photo"] == "") $profiledata["photo"] = proxy_url($r[0]["avatar"]); - if ($r[0]["nick"] != "") - $profiledata["nickname"] = $r[0]["nick"]; - } + if ($profiledata["address"] == "") + $profiledata["address"] = bbcode($r[0]["location"]); + if ($profiledata["about"] == "") + $profiledata["about"] = bbcode($r[0]["about"]); + if (($profiledata["nickname"] == "") AND ($r[0]["nick"] != "")) + $profiledata["nickname"] = $r[0]["nick"]; } // Check for a repeated message @@ -158,6 +163,21 @@ function display_fetchauthor($a, $item) { $profiledata["nickname"] = $profiledata["name"]; $profiledata["network"] = GetProfileUsername($profiledata["url"], "", false, true); + + $profiledata["address"] = ""; + $profiledata["about"] = ""; + + // Fetching profile data from unique contacts + if ($profiledata["url"] != "") { + $r = q("SELECT `avatar`, `nick`, `location`, `about` FROM `unique_contacts` WHERE `url` = '%s'", normalise_link($profiledata["url"])); + if (count($r)) { + $profiledata["photo"] = proxy_url($r[0]["avatar"]); + $profiledata["address"] = bbcode($r[0]["location"]); + $profiledata["about"] = bbcode($r[0]["about"]); + if ($r[0]["nick"] != "") + $profiledata["nickname"] = $r[0]["nick"]; + } + } } if (local_user()) {