]> git.mxchange.org Git - friendica.git/commitdiff
The table "unique_contacts" now has an "about" and "location" field as well.
authorMichael Vogel <icarus@dabo.de>
Thu, 8 Jan 2015 00:32:19 +0000 (01:32 +0100)
committerMichael Vogel <icarus@dabo.de>
Thu, 8 Jan 2015 00:32:19 +0000 (01:32 +0100)
include/dbstructure.php
include/diaspora.php
mod/display.php

index 008003e1b06b17a04b7e77e0d07239ae21369303..804f6f4c65582cb1294f8f9541a6d7cdce968f39 100644 (file)
@@ -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"),
index 45feee87b5ed475fc11768e632869d268d7e85fd..af92d67a94fb42ffe372232575b3c80df69d3d0f 100755 (executable)
@@ -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) {
index 9735ba921f6b57a8daf36fe974ab02fc9975a6bb..f2fde578781ae101b7c5215c345139c8ed3f7b8f 100644 (file)
@@ -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()) {