From ae76fa1174f56e3d68473cf2a4b606838b514521 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Wed, 30 Nov 2022 14:38:23 -0500 Subject: [PATCH] Remove unused first parameter from BaseProfile::getTabsHTML - Add expected Profile::load call to Profile\Photos module --- mod/notes.php | 2 +- mod/photos.php | 2 +- src/Module/BaseProfile.php | 3 +-- src/Module/Profile/Common.php | 2 +- src/Module/Profile/Contacts.php | 2 +- src/Module/Profile/Media.php | 2 +- src/Module/Profile/Photos.php | 8 +++----- src/Module/Profile/Profile.php | 2 +- src/Module/Profile/Schedule.php | 2 +- src/Module/Profile/Status.php | 2 +- 10 files changed, 12 insertions(+), 15 deletions(-) diff --git a/mod/notes.php b/mod/notes.php index 39649d81f..475e0b7e5 100644 --- a/mod/notes.php +++ b/mod/notes.php @@ -45,7 +45,7 @@ function notes_content(App $a, bool $update = false) return; } - $o = BaseProfile::getTabsHTML($a, 'notes', true, $a->getLoggedInUserNickname(), false); + $o = BaseProfile::getTabsHTML('notes', true, $a->getLoggedInUserNickname(), false); if (!$update) { $o .= '

' . DI::l10n()->t('Personal Notes') . '

'; diff --git a/mod/photos.php b/mod/photos.php index 865e0fb31..8bcd9f460 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -875,7 +875,7 @@ function photos_content(App $a) // tabs $is_owner = (DI::userSession()->getLocalUserId() && (DI::userSession()->getLocalUserId() == $owner_uid)); - $o .= BaseProfile::getTabsHTML($a, 'photos', $is_owner, $user['nickname'], $profile['hide-friends']); + $o .= BaseProfile::getTabsHTML('photos', $is_owner, $user['nickname'], $profile['hide-friends']); // Display upload form if ($datatype === 'upload') { diff --git a/src/Module/BaseProfile.php b/src/Module/BaseProfile.php index 10384e157..1347ae0df 100644 --- a/src/Module/BaseProfile.php +++ b/src/Module/BaseProfile.php @@ -32,14 +32,13 @@ class BaseProfile extends BaseModule /** * Returns the HTML for the profile pages tabs * - * @param App $a * @param string $current * @param bool $is_owner * @param string $nickname * @return string * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public static function getTabsHTML(App $a, string $current, bool $is_owner, string $nickname, bool $hide_friends) + public static function getTabsHTML(string $current, bool $is_owner, string $nickname, bool $hide_friends) { $baseProfileUrl = DI::baseUrl() . '/profile/' . $nickname; diff --git a/src/Module/Profile/Common.php b/src/Module/Profile/Common.php index 6837e0f82..505675860 100644 --- a/src/Module/Profile/Common.php +++ b/src/Module/Profile/Common.php @@ -61,7 +61,7 @@ class Common extends BaseProfile $a->redirect('profile/' . $nickname . '/contacts'); }; - $o = self::getTabsHTML($a, 'contacts', false, $profile['nickname'], $profile['hide-friends']); + $o = self::getTabsHTML('contacts', false, $profile['nickname'], $profile['hide-friends']); $tabs = self::getContactFilterTabs('profile/' . $nickname, 'common', $displayCommonTab); diff --git a/src/Module/Profile/Contacts.php b/src/Module/Profile/Contacts.php index 6397ff459..5f8363a03 100644 --- a/src/Module/Profile/Contacts.php +++ b/src/Module/Profile/Contacts.php @@ -57,7 +57,7 @@ class Contacts extends Module\BaseProfile Nav::setSelected('home'); - $o = self::getTabsHTML($a, 'contacts', $is_owner, $profile['nickname'], $profile['hide-friends']); + $o = self::getTabsHTML('contacts', $is_owner, $profile['nickname'], $profile['hide-friends']); $tabs = self::getContactFilterTabs('profile/' . $nickname, $type, DI::userSession()->isAuthenticated() && $profile['uid'] != DI::userSession()->getLocalUserId()); diff --git a/src/Module/Profile/Media.php b/src/Module/Profile/Media.php index bae2f9ad8..6c140acce 100644 --- a/src/Module/Profile/Media.php +++ b/src/Module/Profile/Media.php @@ -44,7 +44,7 @@ class Media extends BaseProfile $is_owner = DI::userSession()->getLocalUserId() == $profile['uid']; - $o = self::getTabsHTML($a, 'media', $is_owner, $profile['nickname'], $profile['hide-friends']); + $o = self::getTabsHTML('media', $is_owner, $profile['nickname'], $profile['hide-friends']); $o .= Contact::getPostsFromUrl($profile['url'], false, 0, 0, true); diff --git a/src/Module/Profile/Photos.php b/src/Module/Profile/Photos.php index 940c1257b..12c0552b6 100644 --- a/src/Module/Profile/Photos.php +++ b/src/Module/Profile/Photos.php @@ -72,8 +72,8 @@ class Photos extends \Friendica\Module\BaseProfile throw new HttpException\ForbiddenException($this->t('Public access denied.')); } - $owner = User::getOwnerDataByNick($this->parameters['nickname']); - if (!isset($owner['account_removed']) || $owner['account_removed']) { + $owner = Profile::load($this->app, $this->parameters['nickname'] ?? ''); + if (!$owner || $owner['account_removed'] || $owner['account_expired']) { throw new HTTPException\NotFoundException($this->t('User not found.')); } @@ -174,13 +174,11 @@ class Photos extends \Friendica\Module\BaseProfile ]); } - $this->page['aside'] .= Widget\VCard::getHTML($owner); - if (!empty($photo_albums_widget)) { $this->page['aside'] .= $photo_albums_widget; } - $o = self::getTabsHTML($this->app, 'photos', $is_owner, $owner['nickname'], Profile::getByUID($owner['uid'])['hide-friends'] ?? false); + $o = self::getTabsHTML('photos', $is_owner, $owner['nickname'], Profile::getByUID($owner['uid'])['hide-friends'] ?? false); $tpl = Renderer::getMarkupTemplate('photos_recent.tpl'); $o .= Renderer::replaceMacros($tpl, [ diff --git a/src/Module/Profile/Profile.php b/src/Module/Profile/Profile.php index 553e9c523..2c680d446 100644 --- a/src/Module/Profile/Profile.php +++ b/src/Module/Profile/Profile.php @@ -100,7 +100,7 @@ class Profile extends BaseProfile Nav::setSelected('home'); $is_owner = DI::userSession()->getLocalUserId() == $profile['uid']; - $o = self::getTabsHTML($a, 'profile', $is_owner, $profile['nickname'], $profile['hide-friends']); + $o = self::getTabsHTML('profile', $is_owner, $profile['nickname'], $profile['hide-friends']); $view_as_contacts = []; $view_as_contact_id = 0; diff --git a/src/Module/Profile/Schedule.php b/src/Module/Profile/Schedule.php index 0e1f92018..10dd5339f 100644 --- a/src/Module/Profile/Schedule.php +++ b/src/Module/Profile/Schedule.php @@ -58,7 +58,7 @@ class Schedule extends BaseProfile $a = DI::app(); - $o = self::getTabsHTML($a, 'schedule', true, $a->getLoggedInUserNickname(), false); + $o = self::getTabsHTML('schedule', true, $a->getLoggedInUserNickname(), false); $schedule = []; $delayed = DBA::select('delayed-post', [], ['uid' => DI::userSession()->getLocalUserId()]); diff --git a/src/Module/Profile/Status.php b/src/Module/Profile/Status.php index 4b5e56755..0a4a17e46 100644 --- a/src/Module/Profile/Status.php +++ b/src/Module/Profile/Status.php @@ -109,7 +109,7 @@ class Status extends BaseProfile $this->baseUrl->redirect('profile/' . $profile['nickname'] . '/restricted'); } - $o .= self::getTabsHTML($a, 'status', $is_owner, $profile['nickname'], $profile['hide-friends']); + $o .= self::getTabsHTML('status', $is_owner, $profile['nickname'], $profile['hide-friends']); $o .= Widget::commonFriendsVisitor($profile['uid'], $profile['nickname']);