]> git.mxchange.org Git - friendica.git/blobdiff - mod/display.php
Apply suggestions from code review
[friendica.git] / mod / display.php
index 3a93e504aed36d20d30179b0dc2855922b7c5e12..c0e72837af11ff07c4f95ebb565899759835767c 100644 (file)
@@ -122,15 +122,16 @@ function display_fetchauthor($item)
        // Check for a repeated message
        $shared = Item::getShareArray($item);
        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'] = '';
+               $profiledata = [
+                       'uid' => -1,
+                       'id' => -1,
+                       'nickname' => '',
+                       'name' => '',
+                       'picdate' => '',
+                       'photo' => '',
+                       'url' => '',
+                       'network' => '',
+               ];
 
                if (!empty($shared['author'])) {
                        $profiledata['name'] = $shared['author'];
@@ -177,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_owner = intval($item['uid']);
+                               $a->setProfileOwner($item['uid']);
                        } else {
-                               $a->profile_owner = intval($update_uid);
+                               $a->setProfileOwner($update_uid);
                        }
                        $parent_uri_id = $item['parent-uri-id'];
                }
@@ -261,16 +262,11 @@ function display_content(App $a, $update = false, $update_uid = 0)
                $page_uid = $item['uid'];
        }
 
-       $page_contact = DBA::selectFirst('contact', ['id', 'url', 'network', 'name'], ['self' => true, 'uid' => $page_uid]);
-       if (DBA::isResult($page_contact)) {
-               // "$a->page_contact" is only used in "checkWallToWall" in Post.php.
-               // It is used for the wall post feature that has its issues.
-               // It can't work with AP or Diaspora since the creator can't sign the post with their private key.
-               $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($page_uid, [local_user(), 0])) ? true : false);
+       $is_owner = local_user() && (in_array($page_uid, [local_user(), 0]));
 
        if (!empty($page_user['hidewall']) && !$is_owner && !$is_remote_contact) {
                throw new HTTPException\ForbiddenException(DI::l10n()->t('Access to this profile has been restricted.'));