1
0
Fork 0

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
This commit is contained in:
Hypolite Petovan 2022-05-29 16:13:49 -04:00
parent 9160fde8ca
commit 7f711e266f
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();
}
/**