Fetching of profile data improved

This commit is contained in:
Michael Vogel 2016-06-05 21:17:55 +02:00
parent ea3a6ec6eb
commit 4b640dbd97
4 changed files with 23 additions and 71 deletions

View File

@ -345,18 +345,21 @@ function profile_sidebar($profile, $block = 0) {
? trim(substr($profile['name'],0,strpos($profile['name'],' '))) : $profile['name']); ? trim(substr($profile['name'],0,strpos($profile['name'],' '))) : $profile['name']);
$lastname = (($firstname === $profile['name']) ? '' : trim(substr($profile['name'],strlen($firstname)))); $lastname = (($firstname === $profile['name']) ? '' : trim(substr($profile['name'],strlen($firstname))));
$diaspora = array( if ($profile['guid'] != "")
'guid' => $profile['guid'], $diaspora = array(
'podloc' => $a->get_baseurl(), 'guid' => $profile['guid'],
'searchable' => (($profile['publish'] && $profile['net-publish']) ? 'true' : 'false' ), 'podloc' => $a->get_baseurl(),
'nickname' => $profile['nickname'], 'searchable' => (($profile['publish'] && $profile['net-publish']) ? 'true' : 'false' ),
'fullname' => $profile['name'], 'nickname' => $profile['nickname'],
'firstname' => $firstname, 'fullname' => $profile['name'],
'lastname' => $lastname, 'firstname' => $firstname,
'photo300' => $a->get_baseurl() . '/photo/custom/300/' . $profile['uid'] . '.jpg', 'lastname' => $lastname,
'photo100' => $a->get_baseurl() . '/photo/custom/100/' . $profile['uid'] . '.jpg', 'photo300' => $a->get_baseurl() . '/photo/custom/300/' . $profile['uid'] . '.jpg',
'photo50' => $a->get_baseurl() . '/photo/custom/50/' . $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){ if (!$block){
$contact_block = contact_block(); $contact_block = contact_block();

View File

@ -112,6 +112,8 @@ function display_init(&$a) {
function display_fetchauthor($a, $item) { function display_fetchauthor($a, $item) {
require_once("include/Contact.php");
$profiledata = array(); $profiledata = array();
$profiledata["uid"] = -1; $profiledata["uid"] = -1;
$profiledata["nickname"] = $item["author-name"]; $profiledata["nickname"] = $item["author-name"];
@ -176,61 +178,9 @@ function display_fetchauthor($a, $item) {
$profiledata["about"] = ""; $profiledata["about"] = "";
} }
// Don't show details from Diaspora contacts if you don't follow the contact $profiledata = get_contact_details_by_url($profiledata["url"], local_user(), $profiledata);
$showdetails = ($profiledata["network"] != NETWORK_DIASPORA);
// Fetching further contact data from the contact table $profiledata["photo"] = App::remove_baseurl($profiledata["photo"]);
$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"];
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"];
}
}
}
if (local_user()) { if (local_user()) {
if (in_array($profiledata["network"], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS))) 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)); $title = trim(html2plain(bbcode($r[0]["title"], false, false), 0, true));
$author_name = $r[0]["author-name"]; $author_name = $r[0]["author-name"];
$image = ""; $image = $a->remove_baseurl($r[0]["thumb"]);
if ($image == "")
$image = $r[0]["thumb"];
if ($title == "") if ($title == "")
$title = $author_name; $title = $author_name;

View File

@ -364,7 +364,7 @@ class Item extends BaseObject {
'profile_url' => $profile_link, 'profile_url' => $profile_link,
'item_photo_menu' => item_photo_menu($item), 'item_photo_menu' => item_photo_menu($item),
'name' => $name_e, '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, 'osparkle' => $osparkle,
'sparkle' => $sparkle, 'sparkle' => $sparkle,
'title' => $title_e, 'title' => $title_e,

View File

@ -1,4 +1,4 @@
{{if $diaspora}}
<div style="display:none;"> <div style="display:none;">
<dl class="entity_uid"> <dl class="entity_uid">
<dt>Uid</dt> <dt>Uid</dt>
@ -61,3 +61,4 @@
</dd> </dd>
</dl> </dl>
</div> </div>
{{/if}}