mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-31 21:19:21 +03:00
Moved some config admin settings
This commit is contained in:
parent
8e6f35bfad
commit
27f5ba9337
6 changed files with 32 additions and 19 deletions
|
|
@ -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}]`,
|
||||
|
|
|
|||
|
|
@ -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')
|
||||
]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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';
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue