use Friendica\App;
use Friendica\Content\Text\BBCode;
-use Friendica\Content\Text\HTML;
+use Friendica\Content\Widget;
use Friendica\Core\ACL;
use Friendica\Core\Logger;
use Friendica\Core\Protocol;
use Friendica\Model\Contact;
use Friendica\Model\Item;
use Friendica\Model\Post;
-use Friendica\Model\Profile;
-use Friendica\Module\Objects;
+use Friendica\Model\User;
+use Friendica\Module\ActivityPub\Objects;
use Friendica\Network\HTTPException;
use Friendica\Protocol\ActivityPub;
use Friendica\Protocol\DFRN;
$item = null;
$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 ($a->argc == 2) {
- $nick = "";
+ $nick = '';
// Does the local user have this item?
if (local_user()) {
$item = Post::selectFirstForUser(local_user(), $fields, ['guid' => $a->argv[1], 'uid' => local_user()]);
if (DBA::isResult($item)) {
- $nick = $a->user["nickname"];
+ $nick = $a->user['nickname'];
}
}
$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 = [];
- }
- }
-
- Profile::load($a, $nick, $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 = [];
- $profiledata['uid'] = -1;
- $profiledata['nickname'] = $author['nick'];
- $profiledata['name'] = $author['name'];
- $profiledata['picdate'] = '';
- $profiledata['photo'] = $author['photo'];
- $profiledata['url'] = $author['url'];
- $profiledata['network'] = $author['network'];
+ $profiledata = Contact::getByURLForUser($item['author-link'], local_user());
// Check for a repeated message
$shared = Item::getShareArray($item);
if (!empty($shared) && empty($shared['comment'])) {
+ $profiledata = [
+ 'uid' => -1,
+ 'id' => -1,
+ 'nickname' => '',
+ 'name' => '',
+ 'picdate' => '',
+ 'photo' => '',
+ 'url' => '',
+ 'network' => '',
+ ];
+
if (!empty($shared['author'])) {
$profiledata['name'] = $shared['author'];
}
$profiledata['photo'] = $shared['avatar'];
}
- $profiledata["nickname"] = $profiledata["name"];
- $profiledata["network"] = Protocol::matchByProfileUrl($profiledata["url"]);
+ $profiledata['nickname'] = $profiledata['name'];
+ $profiledata['network'] = Protocol::matchByProfileUrl($profiledata['url']);
- $profiledata["address"] = "";
- $profiledata["about"] = "";
- }
+ $profiledata['address'] = '';
+ $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;
$item = Post::selectFirst(['uid', 'parent-uri-id'], ['uri-id' => $uri_id, 'uid' => $update_uid]);
if (!empty($item)) {
if ($item['uid'] != 0) {
- $a->profile = ['uid' => intval($item['uid'])];
+ $a->setProfileOwner($item['uid']);
} else {
- $a->profile = ['uid' => intval($update_uid)];
+ $a->setProfileOwner($update_uid);
}
$parent_uri_id = $item['parent-uri-id'];
}
$is_remote_contact = false;
$item_uid = local_user();
+ $page_uid = 0;
$parent = null;
if (!empty($parent_uri_id)) {
}
if (DBA::isResult($parent)) {
- $a->profile['uid'] = ($a->profile['uid'] ?? 0) ?: $parent['uid'];
- $is_remote_contact = Session::getRemoteContactID($a->profile['uid']);
+ $page_uid = $page_uid ?? 0 ?: $parent['uid'];
+ $is_remote_contact = Session::getRemoteContactID($page_uid);
if ($is_remote_contact) {
$item_uid = $parent['uid'];
}
} else {
- $a->profile = ['uid' => intval($item['uid'])];
+ $page_uid = $item['uid'];
}
- $page_contact = DBA::selectFirst('contact', [], ['self' => true, 'uid' => $a->profile['uid']]);
- if (DBA::isResult($page_contact)) {
- $a->page_contact = $page_contact;
+ if (!empty($page_uid) && ($page_uid != local_user())) {
+ $page_user = User::getById($page_uid);
}
- $is_owner = (local_user() && (in_array($a->profile['uid'], [local_user(), 0])) ? true : false);
+ $is_owner = local_user() && (in_array($page_uid, [local_user(), 0]));
- if (!empty($a->profile['hidewall']) && !$is_owner && !$is_remote_contact) {
+ if (!empty($page_user['hidewall']) && !$is_owner && !$is_remote_contact) {
throw new HTTPException\ForbiddenException(DI::l10n()->t('Access to this profile has been restricted.'));
}
];
$o .= status_editor($a, $x, 0, true);
}
- $sql_extra = Item::getPermissionsSQLByUserId($a->profile['uid']);
+ $sql_extra = Item::getPermissionsSQLByUserId($page_uid);
- if (local_user() && (local_user() == $a->profile['uid'])) {
+ if (local_user() && (local_user() == $page_uid)) {
$condition = ['parent-uri-id' => $parent_uri_id, 'uid' => local_user(), 'unseen' => true];
$unseen = Post::exists($condition);
} else {
$condition = ["`uri-id` = ? AND `uid` IN (0, ?) " . $sql_extra, $uri_id, $item_uid];
$fields = ['parent-uri-id', 'body', 'title', 'author-name', 'author-avatar', 'plink', 'author-id', 'owner-id', 'contact-id'];
- $item = Post::selectFirstForUser($a->profile['uid'], $fields, $condition);
+ $item = Post::selectFirstForUser($page_uid, $fields, $condition);
if (!DBA::isResult($item)) {
throw new HTTPException\NotFoundException(DI::l10n()->t('The requested item doesn\'t exist or has been deleted.'));
$o .= conversation($a, [$item], 'display', $update_uid, false, 'commented', $item_uid);
// Preparing the meta header
- $description = trim(BBCode::toPlaintext($item["body"]));
- $title = trim(BBCode::toPlaintext($item["title"]));
- $author_name = $item["author-name"];
+ $description = trim(BBCode::toPlaintext($item['body']));
+ $title = trim(BBCode::toPlaintext($item['title']));
+ $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;
}