diff --git a/dev/Settings/Admin/Config.js b/dev/Settings/Admin/Config.js index 4c415adc1..9aa954e1f 100644 --- a/dev/Settings/Admin/Config.js +++ b/dev/Settings/Admin/Config.js @@ -2,6 +2,9 @@ import ko from 'ko'; import Remote from 'Remote/Admin/Fetch'; import { forEachObjectEntry } from 'Common/Utils'; +import { SettingsAdmin } from 'Common/Globals'; +import { LanguageStore } from 'Stores/Language'; +import { ThemeStore } from 'Stores/Theme'; export class AdminSettingsConfig /*extends AbstractViewSettings*/ { @@ -53,6 +56,11 @@ export class AdminSettingsConfig /*extends AbstractViewSettings*/ { items: [] }; forEachObjectEntry(items, (skey, item) => { + if ('language' === skey) { + item[2] = ('webmail' === key) ? LanguageStore.languages : SettingsAdmin('languages'); + } else if ('theme' === skey) { + item[2] = ThemeStore.themes; + } 'admin_password' === skey || section.items.push({ key: `config[${key}][${skey}]`, diff --git a/dev/Settings/Admin/General.js b/dev/Settings/Admin/General.js index 22983bfb2..143d30464 100644 --- a/dev/Settings/Admin/General.js +++ b/dev/Settings/Admin/General.js @@ -1,9 +1,5 @@ import ko from 'ko'; -import { - isArray -} from 'Common/Utils'; - import { addObservablesTo, addSubscribablesTo, addComputablesTo } from 'External/ko'; import { SaveSettingStatus } from 'Common/Enums'; @@ -111,10 +107,9 @@ export class AdminSettingsGeneral extends AbstractViewSettings { } selectLanguageAdmin() { - const aLanguagesAdmin = SettingsAdmin('languages'); showScreenPopup(LanguagesPopupView, [ this.languageAdmin, - isArray(aLanguagesAdmin) ? aLanguagesAdmin : [], + SettingsAdmin('languages'), SettingsAdmin('clientLanguage') ]); } diff --git a/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/Localization.php b/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/Localization.php index b1d2d1298..3af73d4f7 100644 --- a/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/Localization.php +++ b/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/Localization.php @@ -8,7 +8,7 @@ trait Localization { $oConfig = $this->Config(); if ($bAdmin) { - $sLanguage = $oConfig->Get('webmail', 'language_admin', 'en'); + $sLanguage = $oConfig->Get('admin_panel', 'language', 'en'); } else { $sLanguage = $oConfig->Get('webmail', 'language', 'en'); if ($oAccount = $this->getAccountFromToken(false)) { @@ -77,7 +77,7 @@ trait Localization return ''; } - $sResult = $this->Config()->Get('webmail', $bAdmin ? 'language_admin' : 'language', 'en'); + $sResult = $this->Config()->Get($bAdmin ? 'admin_panel' : 'webmail', 'language', 'en'); return \in_array($sResult, $aLang) ? $sResult : 'en'; } diff --git a/snappymail/v/0.0.0/app/libraries/RainLoop/ActionsAdmin.php b/snappymail/v/0.0.0/app/libraries/RainLoop/ActionsAdmin.php index d32e92221..90ea394b7 100644 --- a/snappymail/v/0.0.0/app/libraries/RainLoop/ActionsAdmin.php +++ b/snappymail/v/0.0.0/app/libraries/RainLoop/ActionsAdmin.php @@ -56,7 +56,7 @@ class ActionsAdmin extends Actions return $self->ValidateLanguage($sLanguage, '', false); }); - $this->setConfigFromParams($oConfig, 'languageAdmin', 'webmail', 'language_admin', 'string', function ($sLanguage) use ($self) { + $this->setConfigFromParams($oConfig, 'languageAdmin', 'admin_panel', 'language', 'string', function ($sLanguage) use ($self) { return $self->ValidateLanguage($sLanguage, '', true); }); @@ -419,8 +419,8 @@ class ActionsAdmin extends Actions { $oConfig = $oActions->Config(); $aResult['Admin'] = [ - 'host' => '' !== $oConfig->Get('security', 'admin_panel_host', ''), - 'path' => $oConfig->Get('security', 'admin_panel_key', '') ?: 'admin', + 'host' => '' !== $oConfig->Get('admin_panel', 'host', ''), + 'path' => $oConfig->Get('admin_panel', 'key', '') ?: 'admin', 'allowed' => (bool)$oConfig->Get('security', 'allow_admin_panel', true) ]; @@ -453,7 +453,7 @@ class ActionsAdmin extends Actions $aResult['weakPassword'] = \is_file(APP_PRIVATE_DATA.'admin_password.txt'); - $aResult['Admin']['language'] = $oActions->ValidateLanguage($oConfig->Get('webmail', 'language_admin', 'en'), '', true); + $aResult['Admin']['language'] = $oActions->ValidateLanguage($oConfig->Get('admin_panel', 'language', 'en'), '', true); $aResult['Admin']['languages'] = \SnappyMail\L10n::getLanguages(true); $aResult['Admin']['clientLanguage'] = $oActions->ValidateLanguage($oActions->detectClientLanguage(true), '', true, true); } else { diff --git a/snappymail/v/0.0.0/app/libraries/RainLoop/Config/Application.php b/snappymail/v/0.0.0/app/libraries/RainLoop/Config/Application.php index 5e4a34c9a..f1fb8bfab 100644 --- a/snappymail/v/0.0.0/app/libraries/RainLoop/Config/Application.php +++ b/snappymail/v/0.0.0/app/libraries/RainLoop/Config/Application.php @@ -95,6 +95,18 @@ class Application extends \RainLoop\Config\AbstractConfig public function Set(string $sSectionKey, string $sParamKey, $mParamValue) : void { // Workarounds for the changed application structure + if ('webmail' === $sSectionKey) { + if ('language_admin' === $sSectionKey) { + $sSectionKey = 'admin_panel'; + $sParamKey = 'language'; + } + } + if ('security' === $sSectionKey) { + if (\str_starts_with($sParamKey, 'admin_panel_')) { + $sSectionKey = 'admin_panel'; + $sParamKey = \str_replace('admin_panel_', '', $sParamKey); + } + } if ('labs' === $sSectionKey) { if (\str_starts_with($sParamKey, 'imap_')) { $sSectionKey = 'imap'; @@ -163,7 +175,6 @@ class Application extends \RainLoop\Config\AbstractConfig 'allow_user_background' => array(false), 'language' => array('en', 'Language used by default'), - 'language_admin' => array('en', 'Admin Panel interface language'), 'allow_languages_on_settings' => array(true, 'Allow language selection on settings screen'), 'allow_additional_accounts' => array(true), @@ -210,8 +221,6 @@ Warning: only enable when server does not do this, else double compression error 'admin_login' => array('admin', 'Login and password for web admin panel'), 'admin_password' => array(''), 'admin_totp' => array(''), - 'admin_panel_host' => array(''), - 'admin_panel_key' => array('admin'), 'force_https' => array(false), 'hide_x_mailer_header' => array(true), @@ -236,10 +245,11 @@ Default is "site=same-origin;site=none"') 'login' => array('admin', 'Login and password for web admin panel'), 'password' => array(''), 'totp' => array(''), +*/ 'host' => array(''), 'key' => array('admin'), -*/ - 'allow_update' => array(false) + 'allow_update' => array(false), + 'language' => array('en', 'Admin Panel interface language'), ), 'ssl' => array( diff --git a/snappymail/v/0.0.0/app/libraries/RainLoop/Service.php b/snappymail/v/0.0.0/app/libraries/RainLoop/Service.php index 131068985..e46e2541c 100644 --- a/snappymail/v/0.0.0/app/libraries/RainLoop/Service.php +++ b/snappymail/v/0.0.0/app/libraries/RainLoop/Service.php @@ -84,9 +84,9 @@ abstract class Service $aPaths = \explode('/', $sQuery); - $sAdminPanelHost = \trim($oConfig->Get('security', 'admin_panel_host', '')); + $sAdminPanelHost = \trim($oConfig->Get('admin_panel', 'host', '')); if (empty($sAdminPanelHost)) { - $bAdmin = !empty($aPaths[0]) && ($oConfig->Get('security', 'admin_panel_key', '') ?: 'admin') === $aPaths[0]; + $bAdmin = !empty($aPaths[0]) && ($oConfig->Get('admin_panel', 'key', '') ?: 'admin') === $aPaths[0]; $bAdmin && \array_shift($aPaths); } else { $bAdmin = \mb_strtolower($sAdminPanelHost) === \mb_strtolower($oHttp->GetHost());