X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=inline;f=mod%2Fdisplay.php;h=c0e72837af11ff07c4f95ebb565899759835767c;hb=1793513f463973587caa517db77a3ab83f3b9cde;hp=2750102d7b4ea10f4af6b7cb4e9c4392ac7a47aa;hpb=acda145ceee17ea9bfc21b5733313547535fd10e;p=friendica.git diff --git a/mod/display.php b/mod/display.php index 2750102d7b..c0e72837af 100644 --- a/mod/display.php +++ b/mod/display.php @@ -21,7 +21,7 @@ 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; @@ -32,8 +32,8 @@ use Friendica\DI; 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; @@ -54,17 +54,17 @@ function display_init(App $a) $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']; } } @@ -110,41 +110,29 @@ function display_init(App $a) $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']; } @@ -157,17 +145,17 @@ function display_fetchauthor($a, $item) $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; @@ -190,9 +178,9 @@ function display_content(App $a, $update = false, $update_uid = 0) $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']; } @@ -236,6 +224,7 @@ function display_content(App $a, $update = false, $update_uid = 0) } if (!DI::pConfig()->get(local_user(), 'system', 'detailed_notif')) { + DBA::update('notification', ['seen' => true], ['parent-uri-id' => $item['parent-uri-id'], 'uid' => local_user()]); DBA::update('notify', ['seen' => true], ['parent-uri-id' => $item['parent-uri-id'], 'uid' => local_user()]); } @@ -256,6 +245,7 @@ function display_content(App $a, $update = false, $update_uid = 0) $is_remote_contact = false; $item_uid = local_user(); + $page_uid = 0; $parent = null; if (!empty($parent_uri_id)) { @@ -263,23 +253,22 @@ function display_content(App $a, $update = false, $update_uid = 0) } 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.')); } @@ -298,9 +287,9 @@ function display_content(App $a, $update = false, $update_uid = 0) ]; $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 { @@ -313,7 +302,7 @@ function display_content(App $a, $update = false, $update_uid = 0) $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.')); @@ -333,13 +322,13 @@ function display_content(App $a, $update = false, $update_uid = 0) $o .= conversation($a, [$item], 'display', $update_uid, false, 'commented', $item_uid); // Preparing the meta header - $description = trim(HTML::toPlaintext(BBCode::convert($item["body"], false), 0, true)); - $title = trim(HTML::toPlaintext(BBCode::convert($item["title"], false), 0, true)); - $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; }