Many AppData properties to JavaScript camelCase

This commit is contained in:
the-djmaze 2023-02-21 10:22:59 +01:00
parent c53d9adaba
commit ce2fb9d7f2
21 changed files with 82 additions and 66 deletions

View file

@ -268,13 +268,13 @@ export class AppUser extends AbstractApp {
navigator.registerProtocolHandler?.(
'mailto',
location.protocol + '//' + location.host + location.pathname + '?mailto&to=%s',
(SettingsGet('Title') || 'SnappyMail')
(SettingsGet('title') || 'SnappyMail')
);
} catch (e) {
console.error(e);
}
setTimeout(() => mailToHelper(SettingsGet('MailToEmail')), 500);
setTimeout(() => mailToHelper(SettingsGet('mailToEmail')), 500);
} else {
this.logout();
}

View file

@ -427,7 +427,7 @@ export class MessageModel extends AbstractModel {
hasImages = true;
},
attr = 'data-x-src',
src, useProxy = !!SettingsGet('UseLocalProxyForExternalImages');
src, useProxy = !!SettingsGet('useLocalProxyForExternalImages');
body.querySelectorAll('img[' + attr + ']').forEach(node => {
src = node.getAttribute(attr);
if (isValid(src)) {

View file

@ -3,8 +3,8 @@ import { AbstractViewSettings } from 'Knoin/AbstractViews';
export class AdminSettingsBranding extends AbstractViewSettings {
constructor() {
super();
this.addSetting('Title');
this.addSetting('LoadingDescription');
this.addSetting('FaviconUrl');
this.addSetting('title');
this.addSetting('loadingDescription');
this.addSetting('faviconUrl');
}
}

View file

@ -22,7 +22,7 @@ export class AdminSettingsContacts extends AbstractViewSettings {
this.testContactsErrorMessage('');
});
this.addSettings(['ContactsEnable','ContactsSync']);
this.addSettings(['contactsEnable','contactsSync']);
addObservablesTo(this, {
testing: false,

View file

@ -33,7 +33,7 @@ export class AdminSettingsGeneral extends AbstractViewSettings {
this.theme = ThemeStore.theme;
this.themes = ThemeStore.themes;
this.addSettings(['AllowLanguagesOnSettings']);
this.addSettings(['allowLanguagesOnSettings']);
addObservablesTo(this, {
capaThemes: SettingsCapa('Themes'),
@ -60,7 +60,7 @@ export class AdminSettingsGeneral extends AbstractViewSettings {
this.addSetting('AttachmentLimit');
this.addSetting('Theme', value => changeTheme(value, this.themeTrigger));
this.uploadData = SettingsGet('PhpUploadSizes');
this.uploadData = SettingsGet('phpUploadSizes');
this.uploadDataDesc =
(this.uploadData?.upload_max_filesize || this.uploadData?.post_max_size)
? [

View file

@ -3,7 +3,7 @@ import { AbstractViewSettings } from 'Knoin/AbstractViews';
export class AdminSettingsLogin extends AbstractViewSettings {
constructor() {
super();
this.addSetting('LoginDefaultDomain');
this.addSettings(['DetermineUserLanguage','DetermineUserDomain','AllowLanguagesOnLogin']);
this.addSetting('loginDefaultDomain');
this.addSettings(['determineUserLanguage','determineUserDomain','allowLanguagesOnLogin']);
}
}

View file

@ -15,7 +15,7 @@ export class AdminSettingsPackages extends AbstractViewSettings {
constructor() {
super();
this.addSettings(['EnabledPlugins']);
this.addSettings(['pluginsEnable']);
addObservablesTo(this, {
packagesError: ''

View file

@ -10,7 +10,7 @@ export class AdminSettingsSecurity extends AbstractViewSettings {
constructor() {
super();
this.addSettings(['UseLocalProxyForExternalImages']);
this.addSettings(['useLocalProxyForExternalImages']);
this.weakPassword = rl.app.weakPassword;

View file

@ -34,7 +34,7 @@ export class UserSettingsGeneral extends AbstractViewSettings {
this.soundNotification = SMAudio.notifications;
this.notificationSound = ko.observable(SettingsGet('NotificationSound'));
this.notificationSounds = ko.observableArray(SettingsGet('NewMailSounds'));
this.notificationSounds = ko.observableArray(SettingsGet('newMailSounds'));
this.desktopNotification = NotificationUserStore.enabled;
this.isDesktopNotificationAllowed = NotificationUserStore.allowed;
@ -48,7 +48,7 @@ export class UserSettingsGeneral extends AbstractViewSettings {
'useCheckboxesInList', 'listGrouped', 'useThreads', 'replySameFolder', 'msgDefaultAction', 'allowSpellcheck'
].forEach(name => this[name] = SettingsUserStore[name]);
this.allowLanguagesOnSettings = !!SettingsGet('AllowLanguagesOnSettings');
this.allowLanguagesOnSettings = !!SettingsGet('allowLanguagesOnSettings');
this.languageTrigger = ko.observable(SaveSettingStatus.Idle);

View file

@ -84,7 +84,7 @@ export class FilterPopupView extends rl.pluginPopupView {
this.defaultOptionsAfterRender = defaultOptionsAfterRender;
this.folderSelectList = koComputable(() =>
folderListOptionsBuilder(
[rl.settings.get('SieveAllowFileintoInbox') ? '' : 'INBOX'],
[rl.settings.get('sieveAllowFileintoInbox') ? '' : 'INBOX'],
[['', '']],
item => item?.localName() || ''
)

View file

@ -23,8 +23,8 @@ export const
ThemeStore.themes(isArray(themes) ? themes : []);
ThemeStore.theme(SettingsGet('Theme'));
if (!ThemeStore.isMobile()) {
ThemeStore.userBackgroundName(SettingsGet('UserBackgroundName'));
ThemeStore.userBackgroundHash(SettingsGet('UserBackgroundHash'));
ThemeStore.userBackgroundName(SettingsGet('userBackgroundName'));
ThemeStore.userBackgroundHash(SettingsGet('userBackgroundHash'));
}
ThemeStore.fontSansSerif(SettingsGet('fontSansSerif'));
ThemeStore.fontSerif(SettingsGet('fontSerif'));

View file

@ -1292,7 +1292,7 @@ export class ComposePopupView extends AbstractViewPopup {
*/
let text = this.oEditor.getData(),
encrypted = PgpUserStore.isEncrypted(text),
size = SettingsGet('PhpUploadSizes')['post_max_size'],
size = SettingsGet('phpUploadSizes')['post_max_size'],
quota = pInt(size);
switch (size.slice(-1)) {
case 'G': quota *= 1024; // fallthrough

View file

@ -26,7 +26,7 @@ export class LoginUserView extends AbstractViewLogin {
super();
addObservablesTo(this, {
loadingDesc: SettingsGet('LoadingDescription'),
loadingDesc: SettingsGet('loadingDescription'),
email: SettingsGet('DevEmail'),
password: SettingsGet('DevPassword'),
@ -44,7 +44,7 @@ export class LoginUserView extends AbstractViewLogin {
signMeType: SignMeUnused
});
this.allowLanguagesOnLogin = !!SettingsGet('AllowLanguagesOnLogin');
this.allowLanguagesOnLogin = !!SettingsGet('allowLanguagesOnLogin');
this.language = LanguageStore.language;
this.languages = LanguageStore.languages;
@ -111,7 +111,7 @@ export class LoginUserView extends AbstractViewLogin {
if (valid) {
this.submitRequest(true);
data.set('Language', this.bSendLanguage ? this.language() : '');
data.set('SignMe', this.signMe() ? 1 : 0);
data.set('signMe', this.signMe() ? 1 : 0);
Remote.request('Login',
(iError, oData) => {
fireEvent('sm-user-login-response', {
@ -142,7 +142,7 @@ export class LoginUserView extends AbstractViewLogin {
onBuild(dom) {
super.onBuild(dom);
const signMe = (SettingsGet('SignMe') || '').toLowerCase();
const signMe = (SettingsGet('signMe') || '').toLowerCase();
switch (signMe) {
case 'defaultoff':

View file

@ -58,7 +58,7 @@ window.rl = {
},
setTitle: title =>
doc.title = (title || '') + (RL_APP_DATA.Title ? (title ? ' - ' : '') + RL_APP_DATA.Title : ''),
doc.title = (title || '') + (RL_APP_DATA.title ? (title ? ' - ' : '') + RL_APP_DATA.title : ''),
initData: appData => {
RL_APP_DATA = appData;

View file

@ -610,8 +610,8 @@ class Actions
$aResult = array(
'Auth' => false,
'Title' => $oConfig->Get('webmail', 'title', 'SnappyMail Webmail'),
'LoadingDescription' => $oConfig->Get('webmail', 'loading_description', 'SnappyMail'),
'title' => $oConfig->Get('webmail', 'title', 'SnappyMail Webmail'),
'loadingDescription' => $oConfig->Get('webmail', 'loading_description', 'SnappyMail'),
'Plugins' => array(),
'System' => \array_merge(
array(
@ -626,7 +626,7 @@ class Actions
'adminAllowed' => (bool)$oConfig->Get('security', 'allow_admin_panel', true)
) : array()
),
'AllowLanguagesOnLogin' => (bool) $oConfig->Get('login', 'allow_languages_on_login', true)
'allowLanguagesOnLogin' => (bool) $oConfig->Get('login', 'allow_languages_on_login', true)
);
$sLanguage = $oConfig->Get('webmail', 'language', 'en');
@ -637,16 +637,16 @@ class Actions
if ($aResult['Auth']) {
$aResult['AdminLogin'] = (string)$oConfig->Get('security', 'admin_login', '');
$aResult['AdminTOTP'] = (string)$oConfig->Get('security', 'admin_totp', '');
$aResult['EnabledPlugins'] = (bool)$oConfig->Get('plugins', 'enable', false);
$aResult['pluginsEnable'] = (bool)$oConfig->Get('plugins', 'enable', false);
$aResult['LoginDefaultDomain'] = $oConfig->Get('login', 'default_domain', '');
$aResult['DetermineUserLanguage'] = (bool)$oConfig->Get('login', 'determine_user_language', true);
$aResult['DetermineUserDomain'] = (bool)$oConfig->Get('login', 'determine_user_domain', false);
$aResult['loginDefaultDomain'] = $oConfig->Get('login', 'default_domain', '');
$aResult['determineUserLanguage'] = (bool)$oConfig->Get('login', 'determine_user_language', true);
$aResult['determineUserDomain'] = (bool)$oConfig->Get('login', 'determine_user_domain', false);
$aResult['supportedPdoDrivers'] = \RainLoop\Common\PdoAbstract::getAvailableDrivers();
$aResult['ContactsEnable'] = (bool)$oConfig->Get('contacts', 'enable', false);
$aResult['ContactsSync'] = (bool)$oConfig->Get('contacts', 'allow_sync', false);
$aResult['contactsEnable'] = (bool)$oConfig->Get('contacts', 'enable', false);
$aResult['contactsSync'] = (bool)$oConfig->Get('contacts', 'allow_sync', false);
$aResult['ContactsPdoType'] = Providers\AddressBook\PdoAddressBook::validPdoType($this->oConfig->Get('contacts', 'type', 'sqlite'));
$aResult['ContactsPdoDsn'] = (string)$oConfig->Get('contacts', 'pdo_dsn', '');
$aResult['ContactsPdoType'] = (string)$oConfig->Get('contacts', 'type', '');
@ -654,7 +654,7 @@ class Actions
$aResult['ContactsPdoPassword'] = static::APP_DUMMY;
$aResult['ContactsSuggestionsLimit'] = (int)$oConfig->Get('contacts', 'suggestions_limit', 20);
$aResult['FaviconUrl'] = $oConfig->Get('webmail', 'favicon_url', '');
$aResult['faviconUrl'] = $oConfig->Get('webmail', 'favicon_url', '');
$aResult['WeakPassword'] = \is_file(APP_PRIVATE_DATA.'admin_password.txt');
@ -681,7 +681,6 @@ class Actions
'AccountHash' => $oAccount->Hash(),
'AccountSignMe' => isset($_COOKIE[self::AUTH_SIGN_ME_TOKEN_KEY]),
'MainEmail' => \MailSo\Base\Utils::IdnToUtf8($this->getMainAccountFromToken()->Email()),
'MailToEmail' => '',
'ContactsIsAllowed' => $this->AddressBookProvider($oAccount)->IsActive(),
@ -714,9 +713,7 @@ class Actions
'ShowUnreadCount' => false,
'UnhideKolabFolders' => false,
'CheckMailInterval' => 15,
'UserBackgroundName' => '',
'UserBackgroundHash' => '',
'SieveAllowFileintoInbox' => (bool)$oConfig->Get('labs', 'sieve_allow_fileinto_inbox', false)
'sieveAllowFileintoInbox' => (bool)$oConfig->Get('labs', 'sieve_allow_fileinto_inbox', false)
]);
$aAttachmentsActions = array();
@ -753,7 +750,7 @@ class Actions
$mMailToData = Utils::DecodeKeyValuesQ($sToken);
if (!empty($mMailToData['MailTo']) && 'MailTo' === $mMailToData['MailTo'] && !empty($mMailToData['To'])) {
$aResult['MailToEmail'] = \MailSo\Base\Utils::IdnToUtf8($mMailToData['To']);
$aResult['mailToEmail'] = \MailSo\Base\Utils::IdnToUtf8($mMailToData['To']);
}
}
@ -764,6 +761,14 @@ class Actions
// MainAccount or AdditionalAccount
$oSettingsLocal = $this->SettingsProvider(true)->Load($oAccount);
if ($oSettingsLocal instanceof Settings) {
/*
foreach ($oSettingsLocal->toArray() as $key => $value) {
$aResult[\lcfirst($key)] = $value;
}
$aResult['junkFolder'] = $aResult['spamFolder'];
unset($aResult['checkableFolder']);
unset($aResult['theme']);
*/
$aResult['SentFolder'] = (string)$oSettingsLocal->GetConf('SentFolder', '');
$aResult['DraftsFolder'] = (string)$oSettingsLocal->GetConf('DraftFolder', '');
$aResult['JunkFolder'] = (string)$oSettingsLocal->GetConf('SpamFolder', '');
@ -781,6 +786,11 @@ class Actions
// MainAccount
$oSettings = $this->SettingsProvider()->Load($oAccount);
if ($oSettings instanceof Settings) {
/*
foreach ($oSettings->toArray() as $key => $value) {
$aResult[\lcfirst($key)] = $value;
}
*/
if ($oConfig->Get('webmail', 'allow_languages_on_settings', true)) {
$sLanguage = (string) $oSettings->GetConf('Language', $sLanguage);
}
@ -830,14 +840,14 @@ class Actions
$aResult['fontMono'] = $oSettings->GetConf('fontMono', '');
if ($this->GetCapa(Enumerations\Capa::USER_BACKGROUND)) {
$aResult['UserBackgroundName'] = (string)$oSettings->GetConf('UserBackgroundName', $aResult['UserBackgroundName']);
$aResult['UserBackgroundHash'] = (string)$oSettings->GetConf('UserBackgroundHash', $aResult['UserBackgroundHash']);
$aResult['userBackgroundName'] = (string)$oSettings->GetConf('UserBackgroundName', $aResult['UserBackgroundName']);
$aResult['userBackgroundHash'] = (string)$oSettings->GetConf('UserBackgroundHash', $aResult['UserBackgroundHash']);
}
}
$aResult['NewMailSounds'] = [];
$aResult['newMailSounds'] = [];
foreach (\glob(APP_VERSION_ROOT_PATH.'static/sounds/*.mp3') as $file) {
$aResult['NewMailSounds'][] = \basename($file, '.mp3');
$aResult['newMailSounds'][] = \basename($file, '.mp3');
}
}
else {
@ -853,13 +863,13 @@ class Actions
$aResult['DevPassword'] = '';
}
$aResult['SignMe'] = (string) $oConfig->Get('login', 'sign_me_auto', Enumerations\SignMeType::DEFAULT_OFF);
$aResult['signMe'] = (string) $oConfig->Get('login', 'sign_me_auto', Enumerations\SignMeType::DEFAULT_OFF);
}
}
if ($aResult['Auth']) {
$aResult['UseLocalProxyForExternalImages'] = (bool)$oConfig->Get('labs', 'use_local_proxy_for_external_images', false);
$aResult['AllowLanguagesOnSettings'] = (bool) $oConfig->Get('webmail', 'allow_languages_on_settings', true);
$aResult['useLocalProxyForExternalImages'] = (bool)$oConfig->Get('labs', 'use_local_proxy_for_external_images', false);
$aResult['allowLanguagesOnSettings'] = (bool) $oConfig->Get('webmail', 'allow_languages_on_settings', true);
$aResult['Capa'] = $this->Capa($bAdmin, $oAccount);
$value = \ini_get('upload_max_filesize');
$upload_max_filesize = \intval($value);
@ -869,7 +879,7 @@ class Actions
case 'K': $upload_max_filesize *= 1024;
}
$aResult['AttachmentLimit'] = \min($upload_max_filesize, ((int) $oConfig->Get('webmail', 'attachment_size_limit', 10)) * 1024 * 1024);
$aResult['PhpUploadSizes'] = array(
$aResult['phpUploadSizes'] = array(
'upload_max_filesize' => $value,
'post_max_size' => \ini_get('post_max_size')
);

View file

@ -36,7 +36,7 @@ trait User
{
$sEmail = \MailSo\Base\Utils::Trim($this->GetActionParam('Email', ''));
$sPassword = $this->GetActionParam('Password', '');
$bSignMe = !empty($this->GetActionParam('SignMe', 0));
$bSignMe = !empty($this->GetActionParam('signMe', 0));
$this->Logger()->AddSecret($sPassword);

View file

@ -60,16 +60,16 @@ class ActionsAdmin extends Actions
return $self->ValidateTheme($sTheme);
});
$this->setConfigFromParams($oConfig, 'UseLocalProxyForExternalImages', 'labs', 'use_local_proxy_for_external_images', 'bool');
$this->setConfigFromParams($oConfig, 'useLocalProxyForExternalImages', 'labs', 'use_local_proxy_for_external_images', 'bool');
$this->setConfigFromParams($oConfig, 'AllowLanguagesOnSettings', 'webmail', 'allow_languages_on_settings', 'bool');
$this->setConfigFromParams($oConfig, 'AllowLanguagesOnLogin', 'login', 'allow_languages_on_login', 'bool');
$this->setConfigFromParams($oConfig, 'allowLanguagesOnSettings', 'webmail', 'allow_languages_on_settings', 'bool');
$this->setConfigFromParams($oConfig, 'allowLanguagesOnLogin', 'login', 'allow_languages_on_login', 'bool');
$this->setConfigFromParams($oConfig, 'AttachmentLimit', 'webmail', 'attachment_size_limit', 'int');
$this->setConfigFromParams($oConfig, 'LoginDefaultDomain', 'login', 'default_domain', 'string');
$this->setConfigFromParams($oConfig, 'loginDefaultDomain', 'login', 'default_domain', 'string');
$this->setConfigFromParams($oConfig, 'ContactsEnable', 'contacts', 'enable', 'bool');
$this->setConfigFromParams($oConfig, 'ContactsSync', 'contacts', 'allow_sync', 'bool');
$this->setConfigFromParams($oConfig, 'contactsEnable', 'contacts', 'enable', 'bool');
$this->setConfigFromParams($oConfig, 'contactsSync', 'contacts', 'allow_sync', 'bool');
$this->setConfigFromParams($oConfig, 'ContactsPdoDsn', 'contacts', 'pdo_dsn', 'string');
$this->setConfigFromParams($oConfig, 'ContactsPdoUser', 'contacts', 'pdo_user', 'string');
$this->setConfigFromParams($oConfig, 'ContactsPdoPassword', 'contacts', 'pdo_password', 'dummy');
@ -86,14 +86,14 @@ class ActionsAdmin extends Actions
$this->setConfigFromParams($oConfig, 'CapaUserBackground', 'webmail', 'allow_user_background', 'bool');
$this->setConfigFromParams($oConfig, 'CapaOpenPGP', 'security', 'openpgp', 'bool');
$this->setConfigFromParams($oConfig, 'DetermineUserLanguage', 'login', 'determine_user_language', 'bool');
$this->setConfigFromParams($oConfig, 'DetermineUserDomain', 'login', 'determine_user_domain', 'bool');
$this->setConfigFromParams($oConfig, 'determineUserLanguage', 'login', 'determine_user_language', 'bool');
$this->setConfigFromParams($oConfig, 'determineUserDomain', 'login', 'determine_user_domain', 'bool');
$this->setConfigFromParams($oConfig, 'Title', 'webmail', 'title', 'string');
$this->setConfigFromParams($oConfig, 'LoadingDescription', 'webmail', 'loading_description', 'string');
$this->setConfigFromParams($oConfig, 'FaviconUrl', 'webmail', 'favicon_url', 'string');
$this->setConfigFromParams($oConfig, 'title', 'webmail', 'title', 'string');
$this->setConfigFromParams($oConfig, 'loadingDescription', 'webmail', 'loading_description', 'string');
$this->setConfigFromParams($oConfig, 'faviconUrl', 'webmail', 'favicon_url', 'string');
$this->setConfigFromParams($oConfig, 'EnabledPlugins', 'plugins', 'enable', 'bool');
$this->setConfigFromParams($oConfig, 'pluginsEnable', 'plugins', 'enable', 'bool');
return $this->DefaultResponse($oConfig->Save());
}

View file

@ -21,7 +21,7 @@ class Settings extends \RainLoop\Providers\AbstractProvider
public function Save(\RainLoop\Model\Account $oAccount, \RainLoop\Settings $oSettings) : bool
{
return $this->oDriver->Save($oAccount, $oSettings->DataAsArray());
return $this->oDriver->Save($oAccount, $oSettings->toArray());
}
public function IsActive() : bool

View file

@ -638,7 +638,7 @@ class ServiceActions
$this->Logger()->Write($sResult, \LOG_INFO, 'APPDATA');
return $sResult;
} catch (\Throwable $oException) {
$self->Logger()->WriteExceptionShort($oException);
$this->Logger()->WriteExceptionShort($oException);
\MailSo\Base\Http::StatusHeader(500);
return $oException->getMessage();
}

View file

@ -2,7 +2,7 @@
namespace RainLoop;
class Settings
class Settings implements \JsonSerializable
{
/**
* @var array
@ -14,11 +14,17 @@ class Settings
$this->aData = $aData;
}
public function DataAsArray() : array
public function toArray() : array
{
return $this->aData;
}
#[\ReturnTypeWillChange]
public function jsonSerialize()
{
return $this->aData;;
}
/**
* @param mixed $mDefValue = null
*

View file

@ -15,7 +15,7 @@
<div data-bind="component: {
name: 'Checkbox',
params: { value: enabledPlugins, label: 'TAB_PACKAGES/LABEL_ENABLE_PLUGINS' }
params: { value: pluginsEnable, label: 'TAB_PACKAGES/LABEL_ENABLE_PLUGINS' }
}"></div>
<br>
@ -28,7 +28,7 @@
<div data-bind="template: { name: 'AdminSettingsPackagesTable', data: {f: packagesUpdate} }"></div>
</div>
<div id="packages-installed" data-bind="visible: packagesCurrent().length, css: {'disabled': !enabledPlugins()}">
<div id="packages-installed" data-bind="visible: packagesCurrent().length, css: {'disabled': !pluginsEnable()}">
<div class="legend" data-i18n="TAB_PACKAGES/LEGEND_INSTALLED_PACKAGES"></div>
<div data-bind="template: { name: 'AdminSettingsPackagesTable', data: {f: packagesCurrent} }"></div>
</div>