From 7f711e266f176be7c6a4fa864edb827d22f4150f Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 29 May 2022 16:13:49 -0400 Subject: [PATCH] Assume unsettable system.always_my_theme pconfig value is always true - This was a logged in user setting so it assumes false for anonymous users --- src/App.php | 4 ++-- src/Model/Profile.php | 18 ++++++------------ 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/src/App.php b/src/App.php index 5fc4c87ffe..e55938d39c 100644 --- a/src/App.php +++ b/src/App.php @@ -472,7 +472,7 @@ class App // Allow folks to override user themes and always use their own on their own site. // This works only if the user is on the same server $user = $this->database->selectFirst('user', ['theme'], ['uid' => $this->profile_owner]); - if ($this->database->isResult($user) && !$this->pConfig->get(local_user(), 'system', 'always_my_theme')) { + if ($this->database->isResult($user) && !local_user()) { $page_theme = $user['theme']; } } @@ -504,7 +504,7 @@ class App if (!empty($this->profile_owner) && ($this->profile_owner != local_user())) { // Allow folks to override user themes and always use their own on their own site. // This works only if the user is on the same server - if (!$this->pConfig->get(local_user(), 'system', 'always_my_theme')) { + if (!local_user()) { $page_mobile_theme = $this->pConfig->get($this->profile_owner, 'system', 'mobile-theme'); } } diff --git a/src/Model/Profile.php b/src/Model/Profile.php index 46c5b54242..aa027a860b 100644 --- a/src/Model/Profile.php +++ b/src/Model/Profile.php @@ -235,7 +235,7 @@ class Profile DI::page()['title'] = $profile['name'] . ' @ ' . DI::config()->get('config', 'sitename'); - if (!DI::pConfig()->get(local_user(), 'system', 'always_my_theme')) { + if (!local_user()) { $a->setCurrentTheme($profile['theme']); $a->setCurrentMobileTheme(DI::pConfig()->get($a->getProfileOwner(), 'system', 'mobile_theme')); } @@ -880,23 +880,17 @@ class Profile * * Used from within PCSS themes to set theme parameters. If there's a * profile_uid variable set in App, that is the "page owner" and normally their theme - * settings take precedence; unless a local user sets the "always_my_theme" - * system pconfig, which means they don't want to see anybody else's theme - * settings except their own while on this site. + * settings take precedence; unless a local user is logged in which means they don't + * want to see anybody else's theme settings except their own while on this site. * + * @param App $a * @return int user ID * - * @throws \Friendica\Network\HTTPException\InternalServerErrorException * @note Returns local_user instead of user ID if "always_my_theme" is set to true */ - public static function getThemeUid(App $a) + public static function getThemeUid(App $a): int { - $uid = !empty($a->getProfileOwner()) ? intval($a->getProfileOwner()) : 0; - if (local_user() && (DI::pConfig()->get(local_user(), 'system', 'always_my_theme') || !$uid)) { - return local_user(); - } - - return $uid; + return local_user() ?: $a->getProfileOwner(); } /** -- 2.39.5