]> git.mxchange.org Git - friendica.git/commitdiff
Fetching of profile data improved
authorMichael Vogel <icarus@dabo.de>
Sun, 5 Jun 2016 19:17:55 +0000 (21:17 +0200)
committerMichael Vogel <icarus@dabo.de>
Sun, 5 Jun 2016 19:17:55 +0000 (21:17 +0200)
include/identity.php
mod/display.php
object/Item.php
view/templates/diaspora_vcard.tpl

index 580539c07155cbd4e106b08394b2ada65350401b..48a6c5bbf7d8ddb072b8e0c16ee80e98cb0fafbb 100644 (file)
@@ -345,18 +345,21 @@ function profile_sidebar($profile, $block = 0) {
                        ? trim(substr($profile['name'],0,strpos($profile['name'],' '))) : $profile['name']);
        $lastname = (($firstname === $profile['name']) ? '' : trim(substr($profile['name'],strlen($firstname))));
 
-       $diaspora = array(
-               'guid' => $profile['guid'],
-               'podloc' => $a->get_baseurl(),
-               'searchable' => (($profile['publish'] && $profile['net-publish']) ? 'true' : 'false' ),
-               'nickname' => $profile['nickname'],
-               'fullname' => $profile['name'],
-               'firstname' => $firstname,
-               'lastname' => $lastname,
-               'photo300' => $a->get_baseurl() . '/photo/custom/300/' . $profile['uid'] . '.jpg',
-               'photo100' => $a->get_baseurl() . '/photo/custom/100/' . $profile['uid'] . '.jpg',
-               'photo50' => $a->get_baseurl() . '/photo/custom/50/'  . $profile['uid'] . '.jpg',
-       );
+       if ($profile['guid'] != "")
+               $diaspora = array(
+                       'guid' => $profile['guid'],
+                       'podloc' => $a->get_baseurl(),
+                       'searchable' => (($profile['publish'] && $profile['net-publish']) ? 'true' : 'false' ),
+                       'nickname' => $profile['nickname'],
+                       'fullname' => $profile['name'],
+                       'firstname' => $firstname,
+                       'lastname' => $lastname,
+                       'photo300' => $a->get_baseurl() . '/photo/custom/300/' . $profile['uid'] . '.jpg',
+                       'photo100' => $a->get_baseurl() . '/photo/custom/100/' . $profile['uid'] . '.jpg',
+                       'photo50' => $a->get_baseurl() . '/photo/custom/50/'  . $profile['uid'] . '.jpg',
+               );
+       else
+               $diaspora = false;
 
        if (!$block){
                $contact_block = contact_block();
index 21fff7866c289f397fd18741f976edc3ed0aadda..949ba5ab46d8d3f8b3bacf19d07513ede5e193bf 100644 (file)
@@ -112,6 +112,8 @@ function display_init(&$a) {
 
 function display_fetchauthor($a, $item) {
 
+       require_once("include/Contact.php");
+
        $profiledata = array();
        $profiledata["uid"] = -1;
        $profiledata["nickname"] = $item["author-name"];
@@ -176,61 +178,9 @@ function display_fetchauthor($a, $item) {
                $profiledata["about"] = "";
        }
 
-       // Don't show details from Diaspora contacts if you don't follow the contact
-       $showdetails = ($profiledata["network"] != NETWORK_DIASPORA);
-
-       // Fetching further contact data from the contact table
-       $r = q("SELECT `uid`, `network`, `name`, `photo`, `nick`, `addr`, `location`, `about`, `gender`, `keywords`
-               FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d AND `network` = '%s' AND `rel` IN (%d, %d)",
-               dbesc(normalise_link($profiledata["url"])), intval(local_user()), dbesc($item["network"]),
-               intval(CONTACT_IS_SHARING), intval(CONTACT_IS_FRIEND));
-       if (!count($r))
-               $r = q("SELECT `uid`, `network`, `name`, `photo`, `nick`, `addr`, `location`, `about`, `gender`, `keywords`
-                       FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d AND `rel` IN (%d, %d)",
-                       dbesc(normalise_link($profiledata["url"])), intval(local_user()),
-                       intval(CONTACT_IS_SHARING), intval(CONTACT_IS_FRIEND));
-
-       if (count($r)) {
-               $profiledata["name"] = $r[0]["name"];
-               $profiledata["photo"] = $r[0]["photo"];
-               $profiledata["nickname"] = $r[0]["nick"];
-               $profiledata["addr"] = $r[0]["addr"];
-               $profiledata["keywords"] = $r[0]["keywords"];
-               $profiledata["network"] = $r[0]["network"];
-
-               if (local_user() OR $showdetails) {
-                       $showdetails = true;
-                       $profiledata["address"] = $r[0]["location"];
-                       $profiledata["about"] = $r[0]["about"];
-                       $profiledata["gender"] = $r[0]["gender"];
-               }
-       }
-
-       // Fetching profile data from global contacts
-       if ($profiledata["network"] != NETWORK_FEED) {
-               $r = q("SELECT `name`, `photo`, `nick`, `addr`, `location`, `about`, `gender`, `keywords`, `network` FROM `gcontact` WHERE `nurl` = '%s'", dbesc(normalise_link($profiledata["url"])));
-               if (count($r)) {
-                       $profiledata["name"] = $r[0]["name"];
-                       $profiledata["photo"] = $r[0]["photo"];
-                       $profiledata["nickname"] = $r[0]["nick"];
-                       $profiledata["addr"] = $r[0]["addr"];
-                       $profiledata["network"] = $r[0]["network"];
-
-                       if ($r[0]["keywords"])
-                               $profiledata["keywords"] = $r[0]["keywords"];
+       $profiledata = get_contact_details_by_url($profiledata["url"], local_user(), $profiledata);
 
-                       if ($showdetails) {
-                               if ($r[0]["location"])
-                                       $profiledata["address"] = $r[0]["location"];
-
-                               if ($r[0]["about"])
-                                       $profiledata["about"] = $r[0]["about"];
-
-                               if ($r[0]["gender"])
-                                       $profiledata["gender"] = $r[0]["gender"];
-                       }
-               }
-       }
+       $profiledata["photo"] = App::remove_baseurl($profiledata["photo"]);
 
        if (local_user()) {
                if (in_array($profiledata["network"], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS)))
@@ -482,9 +432,7 @@ function display_content(&$a, $update = 0) {
                $title = trim(html2plain(bbcode($r[0]["title"], false, false), 0, true));
                $author_name = $r[0]["author-name"];
 
-               $image = "";
-               if ($image == "")
-                       $image = $r[0]["thumb"];
+               $image = $a->remove_baseurl($r[0]["thumb"]);
 
                if ($title == "")
                        $title = $author_name;
index 9dc35e82f1ca8686e7dc894aa0852e2a26aac3db..a907ff228a141574f1bfc6b2dfe5e6f47c8342a1 100644 (file)
@@ -364,7 +364,7 @@ class Item extends BaseObject {
                        'profile_url' => $profile_link,
                        'item_photo_menu' => item_photo_menu($item),
                        'name' => $name_e,
-                       'thumb' => proxy_url($profile_avatar, false, PROXY_SIZE_THUMB),
+                       'thumb' => $a->remove_baseurl(proxy_url($profile_avatar, false, PROXY_SIZE_THUMB)),
                        'osparkle' => $osparkle,
                        'sparkle' => $sparkle,
                        'title' => $title_e,
index 58419bd13d0f181a8de17fbba08220d8e45b01b2..45b9fa4ff7a83e10891f8d43ace0b05764abc5af 100644 (file)
@@ -1,4 +1,4 @@
-
+{{if $diaspora}}
 <div style="display:none;">
        <dl class="entity_uid">
                <dt>Uid</dt>
@@ -61,3 +61,4 @@
                </dd>
        </dl>
 </div>
+{{/if}}