]> git.mxchange.org Git - friendica.git/commitdiff
Fetching "location" and "about" from diaspora. Displaying them on the "display" page.
authorMichael Vogel <icarus@dabo.de>
Wed, 7 Jan 2015 00:46:13 +0000 (01:46 +0100)
committerMichael Vogel <icarus@dabo.de>
Wed, 7 Jan 2015 00:46:13 +0000 (01:46 +0100)
boot.php
include/diaspora.php
include/items.php
include/threads.php
mod/display.php
view/templates/profile_vcard.tpl
view/theme/vier/templates/profile_vcard.tpl

index ec2a4a1acf0f5e12331efafb38d6ff04587581da..9e5a32b66bcbe1fa9976da2841a7df49f1e9618a 100644 (file)
--- a/boot.php
+++ b/boot.php
@@ -1649,8 +1649,10 @@ if(! function_exists('profile_sidebar')) {
 
                $homepage = ((x($profile,'homepage') == 1) ?  t('Homepage:') : False);
 
+               $about = ((x($profile,'about') == 1) ?  t('About:') : False);
+
                if(($profile['hidewall'] || $block) && (! local_user()) && (! remote_user())) {
-                       $location = $pdesc = $gender = $marital = $homepage = False;
+                       $location = $pdesc = $gender = $marital = $homepage = $about = False;
                }
 
                $firstname = ((strpos($profile['name'],' '))
@@ -1695,6 +1697,7 @@ if(! function_exists('profile_sidebar')) {
                        '$pdesc'        => $pdesc,
                        '$marital'  => $marital,
                        '$homepage' => $homepage,
+                       '$about' => $about,
                        '$network' =>  t('Network:'),
                        '$diaspora' => $diaspora,
                        '$contact_block' => $contact_block,
index 99288b773cdaed1da8dfc7d8803101ec789b5e49..b5cb0f0e2364481de873e99eccf16aace9beda7c 100755 (executable)
@@ -2028,7 +2028,7 @@ function diaspora_retraction($importer,$xml) {
                                        dbesc(datetime_convert()),
                                        intval($r[0]['id'])
                                );
-                               delete_thread($r[0]['id']);
+                               delete_thread($r[0]['id'], $r[0]['parent-uri']);
                        }
                }
        }
@@ -2101,7 +2101,7 @@ function diaspora_signed_retraction($importer,$xml,$msg) {
                                        dbesc(datetime_convert()),
                                        intval($r[0]['id'])
                                );
-                               delete_thread($r[0]['id']);
+                               delete_thread($r[0]['id'], $r[0]['parent-uri']);
 
                                // Now check if the retraction needs to be relayed by us
                                //
@@ -2161,14 +2161,15 @@ function diaspora_profile($importer,$xml,$msg) {
        $name = unxmlify($xml->first_name) . ((strlen($xml->last_name)) ? ' ' . unxmlify($xml->last_name) : '');
        $image_url = unxmlify($xml->image_url);
        $birthday = unxmlify($xml->birthday);
+       $location = unxmlify($xml->location);
+       $about = diaspora2bb(unxmlify($xml->bio));
 
 
        $handle_parts = explode("@", $diaspora_handle);
        if($name === '') {
                $name = $handle_parts[0];
        }
-       
-        
+
        if( preg_match("|^https?://|", $image_url) === 0) {
                $image_url = "http://" . $handle_parts[1] . $image_url;
        }
@@ -2182,8 +2183,8 @@ function diaspora_profile($importer,$xml,$msg) {
        require_once('include/Photo.php');
 
        $images = import_profile_photo($image_url,$importer['uid'],$contact['id']);
-       
-       // Generic birthday. We don't know the timezone. The year is irrelevant. 
+
+       // Generic birthday. We don't know the timezone. The year is irrelevant.
 
        $birthday = str_replace('1000','1901',$birthday);
 
@@ -2196,9 +2197,9 @@ function diaspora_profile($importer,$xml,$msg) {
                $birthday = $contact['bd'];
 
        // TODO: update name on item['author-name'] if the name changed. See consume_feed()
-       // Not doing this currently because D* protocol is scheduled for revision soon. 
+       // Not doing this currently because D* protocol is scheduled for revision soon.
 
-       $r = q("UPDATE `contact` SET `name` = '%s', `name-date` = '%s', `photo` = '%s', `thumb` = '%s', `micro` = '%s', `avatar-date` = '%s' , `bd` = '%s' WHERE `id` = %d AND `uid` = %d",
+       $r = q("UPDATE `contact` SET `name` = '%s', `name-date` = '%s', `photo` = '%s', `thumb` = '%s', `micro` = '%s', `avatar-date` = '%s' , `bd` = '%s', `location` = '%s', `about` = '%s' WHERE `id` = %d AND `uid` = %d",
                dbesc($name),
                dbesc(datetime_convert()),
                dbesc($images[0]),
@@ -2206,9 +2207,11 @@ function diaspora_profile($importer,$xml,$msg) {
                dbesc($images[2]),
                dbesc(datetime_convert()),
                dbesc($birthday),
+               dbesc($location),
+               dbesc($about),
                intval($contact['id']),
                intval($importer['uid'])
-       ); 
+       );
 
 /*     if($r) {
                if($oldphotos) {
index c1352cebbea41260dfbac3897be4f453e3e2f12f..1637de15b3dd3d1492e3eb4aa36ad790ab543626 100644 (file)
@@ -4509,7 +4509,7 @@ function drop_item($id,$interactive = true) {
                );
                create_tags_from_item($item['id']);
                create_files_from_item($item['id']);
-               delete_thread($item['id']);
+               delete_thread($item['id'], $item['parent-uri']);
 
                // clean up categories and tags so they don't end up as orphans
 
index 8febe49e9bee6958463684c585a3c355f7bbe411..e9a0d7f1f271d7a4c5710d8e9b1a9f6e7005749c 100644 (file)
@@ -149,28 +149,26 @@ function delete_thread_uri($itemuri, $uid) {
 
        if(count($messages))
                foreach ($messages as $message)
-                       delete_thread($message["id"]);
+                       delete_thread($message["id"], $itemuri);
 }
 
-function delete_thread($itemid) {
-       // To-Do:
-       // There is no "uri" in the thread table ...
-       $item = q("SELECT `uri`, `uid` FROM `thread` WHERE `iid` = %d", intval($itemid));
+function delete_thread($itemid, $itemuri = "") {
+       $item = q("SELECT `uid` FROM `thread` WHERE `iid` = %d", intval($itemid));
 
        $result = q("DELETE FROM `thread` WHERE `iid` = %d", intval($itemid));
 
        logger("delete_thread: Deleted thread for item ".$itemid." - ".print_r($result, true), LOGGER_DEBUG);
 
-       if (count($item)) {
+       if ($itemuri != "") {
                $r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' AND NOT (`uid` IN (%d, 0))",
-                               dbesc($item["uri"]),
+                               dbesc($itemuri),
                                intval($item["uid"])
                        );
                if (!count($r)) {
                        $r = q("DELETE FROM `item` WHERE `uri` = '%s' AND `uid` = 0)",
-                               dbesc($item["uri"])
+                               dbesc($itemuri)
                        );
-                       logger("delete_thread: Deleted shadow for item ".$item["uri"]." - ".print_r($result, true), LOGGER_DEBUG);
+                       logger("delete_thread: Deleted shadow for item ".$itemuri." - ".print_r($result, true), LOGGER_DEBUG);
                }
        }
 }
index abb03b6d5bfaaf948e5ad7fff0ab48b1814a7233..d1da53cf168ab27585e275f0494a933215e6bcc8 100644 (file)
@@ -16,7 +16,7 @@ function display_init(&$a) {
 
                // Does the local user have this item?
                if (local_user()) {
-                       $r = q("SELECT `id`, `parent`, `author-name`, `author-link`, `author-avatar`, `network`, `body` FROM `item`
+                       $r = q("SELECT `id`, `parent`, `author-name`, `author-link`, `author-avatar`, `network`, `body`, `uid` FROM `item`
                                WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0
                                        AND `guid` = '%s' AND `uid` = %d", $a->argv[1], local_user());
                        if (count($r)) {
@@ -43,7 +43,7 @@ function display_init(&$a) {
                }
                if (count($r)) {
                        if ($r[0]["id"] != $r[0]["parent"])
-                               $r = q("SELECT `id`, `author-name`, `author-link`, `author-avatar`, `network`, `body` FROM `item`
+                               $r = q("SELECT `id`, `author-name`, `author-link`, `author-avatar`, `network`, `body`, `uid` FROM `item`
                                        WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0
                                                AND `id` = %d", $r[0]["parent"]);
 
@@ -88,21 +88,22 @@ function display_fetchauthor($a, $item) {
        $profiledata["photo"] = proxy_url($item["author-avatar"]);
        $profiledata["url"] = $item["author-link"];
        $profiledata["network"] = $item["network"];
+       $profiledata["address"] = "Ort".print_r($item, true);
 
-       // Fetching profile data from unique contacts
-       // To-do: Extend "unique contacts" table for further contact data like location, ...
-       $r = q("SELECT `avatar`, `nick` FROM `unique_contacts` WHERE `url` = '%s'", normalise_link($profiledata["url"]));
+       // Fetching further contact data from the contact table
+       $r = q("SELECT `photo`, `nick`, `location`, `about` FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d",
+               normalise_link($profiledata["url"]), $item["uid"]);
        if (count($r)) {
-               $profiledata["photo"] = proxy_url($r[0]["avatar"]);
+               $profiledata["photo"] = proxy_url($r[0]["photo"]);
+               $profiledata["address"] = $r[0]["location"];
+               $profiledata["about"] = $r[0]["about"];
                if ($r[0]["nick"] != "")
                        $profiledata["nickname"] = $r[0]["nick"];
        } else {
-               // Is this case possible?
-               // Fetching further contact data from the contact table, when it isn't available in the "unique contacts"
-               $r = q("SELECT `photo`, `nick` FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d",
-                       normalise_link($profiledata["url"]), $itemuid);
+               // Fetching profile data from unique contacts
+               $r = q("SELECT `avatar`, `nick` FROM `unique_contacts` WHERE `url` = '%s'", normalise_link($profiledata["url"]));
                if (count($r)) {
-                       $profiledata["photo"] = proxy_url($r[0]["photo"]);
+                       $profiledata["photo"] = proxy_url($r[0]["avatar"]);
                        if ($r[0]["nick"] != "")
                                $profiledata["nickname"] = $r[0]["nick"];
                }
index e72d25371d585f16cc8e58aae40ce46d9f888947..9bbb7f8a42d2f97b60ea4fdb4a4d68ae7c8b3a72 100644 (file)
@@ -35,6 +35,8 @@
 
        {{if $homepage}}<dl class="homepage"><dt class="homepage-label">{{$homepage}}</dt><dd class="homepage-url u-url"><a href="{{$profile.homepage}}" rel="me" target="_blank">{{$profile.homepage}}</a></dd></dl>{{/if}}
 
+       {{if $about}}<dl class="about"><dt class="about-label">{{$about}}</dt><dd class="x-network">{{$profile.about}}</dd></dl>{{/if}}
+
        {{include file="diaspora_vcard.tpl"}}
        
        <div id="profile-extra-links">
index 644c3d7e5d01b3ebcc4d3ab1671ffe1982dc37f7..61166ef9009ad83358a74ed1a5c62d697c5d5071 100644 (file)
@@ -55,6 +55,8 @@
 
        {{if $homepage}}<dl class="homepage"><dt class="homepage-label">{{$homepage}}</dt><dd class="homepage-url"><a href="{{$profile.homepage}}" class="u-url" rel="me" target="_blank">{{$profile.homepage}}</a></dd></dl>{{/if}}
 
+       {{if $about}}<dl class="about"><dt class="about-label">{{$about}}</dt><dd class="x-network">{{$profile.about}}</dd></dl>{{/if}}
+
        {{include file="diaspora_vcard.tpl"}}
        
        <div id="profile-extra-links">