Profile fetching simplyfied
This commit is contained in:
parent
0fe5759d8a
commit
f60d60e997
1 changed files with 29 additions and 43 deletions
|
@ -54,17 +54,17 @@ function display_init(App $a)
|
||||||
$item = null;
|
$item = null;
|
||||||
$item_user = local_user();
|
$item_user = local_user();
|
||||||
|
|
||||||
$fields = ['uri-id', 'parent-uri-id', 'author-id', 'body', 'uid', 'guid', 'gravity'];
|
$fields = ['uri-id', 'parent-uri-id', 'author-id', 'author-link', 'body', 'uid', 'guid', 'gravity'];
|
||||||
|
|
||||||
// If there is only one parameter, then check if this parameter could be a guid
|
// If there is only one parameter, then check if this parameter could be a guid
|
||||||
if ($a->argc == 2) {
|
if ($a->argc == 2) {
|
||||||
$nick = "";
|
$nick = '';
|
||||||
|
|
||||||
// Does the local user have this item?
|
// Does the local user have this item?
|
||||||
if (local_user()) {
|
if (local_user()) {
|
||||||
$item = Post::selectFirstForUser(local_user(), $fields, ['guid' => $a->argv[1], 'uid' => local_user()]);
|
$item = Post::selectFirstForUser(local_user(), $fields, ['guid' => $a->argv[1], 'uid' => local_user()]);
|
||||||
if (DBA::isResult($item)) {
|
if (DBA::isResult($item)) {
|
||||||
$nick = $a->user["nickname"];
|
$nick = $a->user['nickname'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,42 +110,28 @@ function display_init(App $a)
|
||||||
$item = $parent ?: $item;
|
$item = $parent ?: $item;
|
||||||
}
|
}
|
||||||
|
|
||||||
$profiledata = display_fetchauthor($a, $item);
|
$profiledata = display_fetchauthor($item);
|
||||||
|
|
||||||
if (strstr(Strings::normaliseLink($profiledata['url']), Strings::normaliseLink(DI::baseUrl()))) {
|
|
||||||
$nickname = str_replace(Strings::normaliseLink(DI::baseUrl()) . '/profile/', '', Strings::normaliseLink($profiledata['url']));
|
|
||||||
|
|
||||||
if (!empty($a->user['nickname']) && $nickname != $a->user['nickname']) {
|
|
||||||
$profile = DBA::selectFirst('owner-view', [], ['nickname' => $nickname]);
|
|
||||||
if (DBA::isResult($profile)) {
|
|
||||||
$profiledata = $profile;
|
|
||||||
}
|
|
||||||
$profiledata["network"] = Protocol::DFRN;
|
|
||||||
} else {
|
|
||||||
$profiledata = [];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
DI::page()['aside'] = Widget\VCard::getHTML($profiledata);
|
DI::page()['aside'] = Widget\VCard::getHTML($profiledata);
|
||||||
}
|
}
|
||||||
|
|
||||||
function display_fetchauthor($a, $item)
|
function display_fetchauthor($item)
|
||||||
{
|
{
|
||||||
$author = DBA::selectFirst('contact', ['name', 'nick', 'photo', 'network', 'url'], ['id' => $item['author-id']]);
|
$profiledata = Contact::getByURLForUser($item['author-link'], local_user());
|
||||||
|
|
||||||
$profiledata = [];
|
|
||||||
$profiledata['uid'] = -1;
|
|
||||||
$profiledata['id'] = -1;
|
|
||||||
$profiledata['nickname'] = $author['nick'];
|
|
||||||
$profiledata['name'] = $author['name'];
|
|
||||||
$profiledata['picdate'] = '';
|
|
||||||
$profiledata['photo'] = $author['photo'];
|
|
||||||
$profiledata['url'] = $author['url'];
|
|
||||||
$profiledata['network'] = $author['network'];
|
|
||||||
|
|
||||||
// Check for a repeated message
|
// Check for a repeated message
|
||||||
$shared = Item::getShareArray($item);
|
$shared = Item::getShareArray($item);
|
||||||
if (!empty($shared) && empty($shared['comment'])) {
|
if (!empty($shared) && empty($shared['comment'])) {
|
||||||
|
$profiledata = [];
|
||||||
|
$profiledata['uid'] = -1;
|
||||||
|
$profiledata['id'] = -1;
|
||||||
|
$profiledata['nickname'] = '';
|
||||||
|
$profiledata['name'] = '';
|
||||||
|
$profiledata['picdate'] = '';
|
||||||
|
$profiledata['photo'] = '';
|
||||||
|
$profiledata['url'] = '';
|
||||||
|
$profiledata['network'] = '';
|
||||||
|
|
||||||
if (!empty($shared['author'])) {
|
if (!empty($shared['author'])) {
|
||||||
$profiledata['name'] = $shared['author'];
|
$profiledata['name'] = $shared['author'];
|
||||||
}
|
}
|
||||||
|
@ -158,17 +144,17 @@ function display_fetchauthor($a, $item)
|
||||||
$profiledata['photo'] = $shared['avatar'];
|
$profiledata['photo'] = $shared['avatar'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$profiledata["nickname"] = $profiledata["name"];
|
$profiledata['nickname'] = $profiledata['name'];
|
||||||
$profiledata["network"] = Protocol::matchByProfileUrl($profiledata["url"]);
|
$profiledata['network'] = Protocol::matchByProfileUrl($profiledata['url']);
|
||||||
|
|
||||||
$profiledata["address"] = "";
|
$profiledata['address'] = '';
|
||||||
$profiledata["about"] = "";
|
$profiledata['about'] = '';
|
||||||
|
|
||||||
|
$profiledata = Contact::getByURLForUser($profiledata['url'], local_user()) ?: $profiledata;
|
||||||
}
|
}
|
||||||
|
|
||||||
$profiledata = Contact::getByURLForUser($profiledata["url"], local_user()) ?: $profiledata;
|
if (!empty($profiledata['photo'])) {
|
||||||
|
$profiledata['photo'] = DI::baseUrl()->remove($profiledata['photo']);
|
||||||
if (!empty($profiledata["photo"])) {
|
|
||||||
$profiledata["photo"] = DI::baseUrl()->remove($profiledata["photo"]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $profiledata;
|
return $profiledata;
|
||||||
|
@ -340,13 +326,13 @@ function display_content(App $a, $update = false, $update_uid = 0)
|
||||||
$o .= conversation($a, [$item], 'display', $update_uid, false, 'commented', $item_uid);
|
$o .= conversation($a, [$item], 'display', $update_uid, false, 'commented', $item_uid);
|
||||||
|
|
||||||
// Preparing the meta header
|
// Preparing the meta header
|
||||||
$description = trim(BBCode::toPlaintext($item["body"]));
|
$description = trim(BBCode::toPlaintext($item['body']));
|
||||||
$title = trim(BBCode::toPlaintext($item["title"]));
|
$title = trim(BBCode::toPlaintext($item['title']));
|
||||||
$author_name = $item["author-name"];
|
$author_name = $item['author-name'];
|
||||||
|
|
||||||
$image = DI::baseUrl()->remove($item["author-avatar"]);
|
$image = DI::baseUrl()->remove($item['author-avatar']);
|
||||||
|
|
||||||
if ($title == "") {
|
if ($title == '') {
|
||||||
$title = $author_name;
|
$title = $author_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue