Merge pull request #11579 from MrPetovan/bug/11291-user-theme-display

Assume unsettable system.always_my_theme pconfig value is always true
This commit is contained in:
Michael Vogel 2022-05-29 23:27:21 +02:00 committed by GitHub
commit ee40d8ea04
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 14 deletions

View File

@ -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');
}
}

View File

@ -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();
}
/**