From d6695d3ad8a8f2dd82312e53b2be5118858df284 Mon Sep 17 00:00:00 2001 From: Molkobain Date: Fri, 9 Apr 2021 09:01:33 +0200 Subject: [PATCH] =?UTF-8?q?N=C2=B03936=20-=20Add=20config=20parameter=20to?= =?UTF-8?q?=20disable=20theme=20selection=20in=20the=20user=20preferences?= =?UTF-8?q?=20("user=5Fpreferences.allow=5Fbackoffice=5Ftheme=5Foverride")?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/themehandler.class.inc.php | 8 ++++++-- core/config.class.inc.php | 8 ++++++++ pages/preferences.php | 4 +++- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/application/themehandler.class.inc.php b/application/themehandler.class.inc.php index ebbe06ade..603bc3a2e 100644 --- a/application/themehandler.class.inc.php +++ b/application/themehandler.class.inc.php @@ -93,11 +93,15 @@ class ThemeHandler */ public static function GetCurrentUserThemeId(): string { + $sThemeId = null; + try { - $sThemeId = appUserPreferences::GetPref('backoffice_theme', null); + if (true === MetaModel::GetConfig()->Get('user_preferences.allow_backoffice_theme_override')) { + $sThemeId = appUserPreferences::GetPref('backoffice_theme', null); + } } catch (Exception $oException) { - $sThemeId = null; + // Do nothing, already handled by $sThemeId null by default } // Fallback on the app. theme diff --git a/core/config.class.inc.php b/core/config.class.inc.php index 3b2902042..d2e3e6545 100644 --- a/core/config.class.inc.php +++ b/core/config.class.inc.php @@ -1287,6 +1287,14 @@ class Config 'source_of_value' => '', 'show_in_conf_sample' => false, ], + 'user_preferences.allow_backoffice_theme_override' => [ + 'type' => 'bool', + 'description' => 'Whether the user can choose which theme to use in the backoffice. If set to false, all users will have the theme defined in "backoffice_default_theme"', + 'default' => true, + 'value' => '', + 'source_of_value' => '', + 'show_in_conf_sample' => false, + ], 'secure_rest_services' => [ 'type' => 'bool', 'description' => 'When set to true, only the users with the profile "REST Services User" are allowed to use the REST web services.', diff --git a/pages/preferences.php b/pages/preferences.php index f2762bae9..c147ddd6e 100644 --- a/pages/preferences.php +++ b/pages/preferences.php @@ -79,7 +79,9 @@ function DisplayPreferences($oP) // General $oGeneralFieldset = FieldSetUIBlockFactory::MakeStandard(Dict::S('UI:Preferences:General:Title'), 'ibo-fieldset-for-language-preferences'); $oGeneralFieldset->AddSubBlock(GetLanguageFieldBlock()); - $oGeneralFieldset->AddSubBlock(GetThemeFieldBlock()); + if (true === MetaModel::GetConfig()->Get('user_preferences.allow_backoffice_theme_override')) { + $oGeneralFieldset->AddSubBlock(GetThemeFieldBlock()); + } $oFirstColumn->AddSubBlock($oGeneralFieldset); // Lists