From 1391648e1b588127746bc449126179c75b9ae29a Mon Sep 17 00:00:00 2001 From: RainLoop Team Date: Sat, 30 Apr 2016 02:42:18 +0300 Subject: [PATCH] Split application data --- dev/App/Abstract.jsx | 10 +- dev/App/Admin.jsx | 2 +- dev/App/User.jsx | 10 +- dev/Common/HtmlEditor.jsx | 4 +- dev/Common/Links.jsx | 10 +- dev/Common/Utils.js | 23 +++++ dev/Promises/AbstractAjax.js | 2 +- dev/Promises/User/Populator.js | 6 +- dev/Remote/AbstractAjax.js | 2 +- dev/Screen/User/MailBox.js | 2 +- dev/Settings/Admin/About.js | 2 +- dev/Settings/User/Folders.js | 2 +- dev/Storage/Settings.jsx | 16 ++++ dev/Stores/User/App.jsx | 2 +- dev/View/Admin/Settings/Pane.js | 2 +- dev/View/Popup/Compose.js | 2 +- dev/View/User/About.js | 2 +- dev/View/User/Login.js | 9 +- dev/View/User/MailBox/MessageList.js | 2 +- .../0.0.0/app/libraries/RainLoop/Actions.php | 93 +++---------------- .../0.0.0/app/libraries/RainLoop/Service.php | 78 +++++++++++++++- rainloop/v/0.0.0/app/templates/Index.html | 35 +++---- 22 files changed, 186 insertions(+), 130 deletions(-) diff --git a/dev/App/Abstract.jsx b/dev/App/Abstract.jsx index 8d0ce8dbc..0dcb24a5c 100644 --- a/dev/App/Abstract.jsx +++ b/dev/App/Abstract.jsx @@ -103,6 +103,10 @@ class AbstractApp extends AbstractBoot return null; } + getApplicationConfiguration(name, default_) { + return this.applicationConfiguration[name] || default_; + } + /** * @param {string} link * @return {boolean} @@ -200,10 +204,10 @@ class AbstractApp extends AbstractBoot const kn = require('Knoin/Knoin'), - inIframe = !!Settings.settingsGet('InIframe') + inIframe = !!Settings.appSettingsGet('inIframe') ; - let customLogoutLink = Utils.pString(Settings.settingsGet('CustomLogoutLink')); + let customLogoutLink = Utils.pString(Settings.appSettingsGet('customLogoutLink')); if (logout) { @@ -273,7 +277,7 @@ class AbstractApp extends AbstractBoot ko.components.register('x-script', require('Component/Script')); // ko.components.register('svg-icon', require('Component/SvgIcon')); - if (Settings.settingsGet('MaterialDesign') && Globals.bAnimationSupported) + if (Settings.appSettingsGet('materialDesign') && Globals.bAnimationSupported) { ko.components.register('Checkbox', require('Component/MaterialDesign/Checkbox')); ko.components.register('CheckboxSimple', require('Component/Checkbox')); diff --git a/dev/App/Admin.jsx b/dev/App/Admin.jsx index 470fc3d51..4be270f11 100644 --- a/dev/App/Admin.jsx +++ b/dev/App/Admin.jsx @@ -225,7 +225,7 @@ class AdminApp extends AbstractApp kn.hideLoading(); - if (!Settings.settingsGet('AllowAdminPanel')) + if (!Settings.appSettingsGet('allowAdminPanel')) { kn.routeOff(); kn.setHash(Links.root(), true); diff --git a/dev/App/User.jsx b/dev/App/User.jsx index 79202f334..4e036abd6 100644 --- a/dev/App/User.jsx +++ b/dev/App/User.jsx @@ -70,7 +70,7 @@ class AppUser extends AbstractApp Remote.jsVersion((sResult, oData) => { if (Enums.StorageResultType.Success === sResult && oData && !oData.Result) { - if (window.parent && !!Settings.settingsGet('InIframe')) + if (window.parent && !!Settings.appSettingsGet('inIframe')) { window.parent.location.reload(); } @@ -79,7 +79,7 @@ class AppUser extends AbstractApp window.location.reload(); } } - }, Settings.settingsGet('Version')); + }, Settings.appSettingsGet('version')); }, {}, 60 * 60 * 1000); if (Settings.settingsGet('UserBackgroundHash')) @@ -1185,7 +1185,7 @@ class AppUser extends AbstractApp Globals.$html.removeClass('rl-user-auth').addClass('rl-user-no-auth'); - const customLoginLink = Utils.pString(Settings.settingsGet('CustomLoginLink')); + const customLoginLink = Utils.pString(Settings.appSettingsGet('customLoginLink')); if (!customLoginLink) { kn.startScreens([ @@ -1239,7 +1239,7 @@ class AppUser extends AbstractApp var $LAB = require('$LAB'), - sJsHash = Settings.settingsGet('JsHash'), + sJsHash = Settings.appSettingsGet('jsHash'), sStartupUrl = Utils.pString(Settings.settingsGet('StartupUrl')), iContactsSyncInterval = Utils.pInt(Settings.settingsGet('ContactsSyncInterval')), bGoogle = Settings.settingsGet('AllowGoogleSocial'), @@ -1411,7 +1411,7 @@ class AppUser extends AbstractApp { _.defer(() => this.initVerticalLayoutResizer(Enums.ClientSideKeyName.FolderListSize)); - if (Tinycon && Settings.settingsGet('FaviconStatus') && !Settings.settingsGet('Filtered')) + if (Tinycon && Settings.appSettingsGet('faviconStatus') && !Settings.appSettingsGet('listPermanentFiltered')) { Tinycon.setOptions({ fallback: false diff --git a/dev/Common/HtmlEditor.jsx b/dev/Common/HtmlEditor.jsx index af20f2d24..e98dd506e 100644 --- a/dev/Common/HtmlEditor.jsx +++ b/dev/Common/HtmlEditor.jsx @@ -238,8 +238,8 @@ class HtmlEditor const config = Globals.oHtmlEditorDefaultConfig, language = Settings.settingsGet('Language'), - allowSource = !!Settings.settingsGet('AllowHtmlEditorSourceButton'), - biti = !!Settings.settingsGet('AllowHtmlEditorBitiButtons') + allowSource = !!Settings.appSettingsGet('allowHtmlEditorSourceButton'), + biti = !!Settings.appSettingsGet('allowHtmlEditorBitiButtons') ; if ((allowSource || !biti) && !config.toolbarGroups.__cfgInited) diff --git a/dev/Common/Links.jsx b/dev/Common/Links.jsx index 659565b48..f80814d56 100644 --- a/dev/Common/Links.jsx +++ b/dev/Common/Links.jsx @@ -10,11 +10,13 @@ class Links this.sBase = '#/'; this.sServer = './?'; - this.sVersion = Settings.settingsGet('Version'); + this.sVersion = Settings.appSettingsGet('version'); + this.sWebPrefix = Settings.appSettingsGet('webPath') || ''; + this.sVersionPrefix = Settings.appSettingsGet('webVersionPath') || 'rainloop/v/' + this.sVersion + '/'; + this.sAdminPath = Settings.appSettingsGet('adminPath') || 'admin'; + this.sAuthSuffix = Settings.settingsGet('AuthAccountHash') || '0'; - this.sWebPrefix = Settings.settingsGet('WebPath') || ''; - this.sAdminPath = Settings.settingsGet('AdminPath') || 'admin'; - this.sVersionPrefix = Settings.settingsGet('WebVersionPath') || 'rainloop/v/' + this.sVersion + '/'; + this.sStaticPrefix = this.sVersionPrefix + 'static/'; } diff --git a/dev/Common/Utils.js b/dev/Common/Utils.js index 21e190737..5d3f8e840 100644 --- a/dev/Common/Utils.js +++ b/dev/Common/Utils.js @@ -13,6 +13,7 @@ $ = require('$'), ko = require('ko'), Autolinker = require('Autolinker'), + JSON = require('JSON'), JSEncrypt = require('JSEncrypt'), Mime = require('Common/Mime'), @@ -1433,6 +1434,28 @@ return (sResult === sFileName) ? '' : sResult; }; + Utils.configurationScriptTagCache = {}; + + /** + * @param {string} sConfiguration + * @return {object} + */ + Utils.getConfigurationFromScriptTag = function (sConfiguration) + { + var oResult = {}; + + if (!Utils.configurationScriptTagCache[sConfiguration]) + { + Utils.configurationScriptTagCache[sConfiguration] = $('script[type="application/json"][data-configuration="' + sConfiguration + '"]'); + } + + try { + oResult = JSON.parse(Utils.configurationScriptTagCache[sConfiguration].text()); + } catch (e) {/* eslint-disable-line no-empty */} + + return oResult; + }; + /** * @param {string} sFileName * @return {string} diff --git a/dev/Promises/AbstractAjax.js b/dev/Promises/AbstractAjax.js index d5e86742c..9e2fd22d6 100644 --- a/dev/Promises/AbstractAjax.js +++ b/dev/Promises/AbstractAjax.js @@ -70,7 +70,7 @@ if (bPost) { - oParameters['XToken'] = Settings.settingsGet('Token'); + oParameters['XToken'] = Settings.appSettingsGet('token'); } Plugins.runHook('ajax-default-request', [sAction, oParameters, sAdditionalGetString]); diff --git a/dev/Promises/User/Populator.js b/dev/Promises/User/Populator.js index 5771d1911..713cec419 100644 --- a/dev/Promises/User/Populator.js +++ b/dev/Promises/User/Populator.js @@ -141,7 +141,7 @@ oData['@Collection'] && Utils.isArray(oData['@Collection'])) { var - iLimit = Utils.pInt(Settings.settingsGet('FolderSpecLimit')), + iLimit = Utils.pInt(Settings.appSettingsGet('folderSpecLimit')), iC = Utils.pInt(oData['CountRec']) ; @@ -163,9 +163,7 @@ FolderStore.namespace = oData.Namespace; } - AppStore.threadsAllowed( - !!Settings.settingsGet('UseImapThread') && - oData.IsThreadsSupported && true); + AppStore.threadsAllowed(!!Settings.appSettingsGet('useImapThread') && oData.IsThreadsSupported && true); FolderStore.folderList.optimized(!!oData.Optimized); diff --git a/dev/Remote/AbstractAjax.js b/dev/Remote/AbstractAjax.js index 28fd8e535..3f7c3d134 100644 --- a/dev/Remote/AbstractAjax.js +++ b/dev/Remote/AbstractAjax.js @@ -169,7 +169,7 @@ if (bPost) { - oParameters['XToken'] = Settings.settingsGet('Token'); + oParameters['XToken'] = Settings.appSettingsGet('token'); } oDefAjax = $.ajax({ diff --git a/dev/Screen/User/MailBox.js b/dev/Screen/User/MailBox.js index 9cf290fd9..509253ecf 100644 --- a/dev/Screen/User/MailBox.js +++ b/dev/Screen/User/MailBox.js @@ -55,7 +55,7 @@ nFoldersInboxUnreadCount = FolderStore.foldersInboxUnreadCount() ; - if (Settings.settingsGet('Filtered')) + if (Settings.appSettingsGet('listPermanentFiltered')) { nFoldersInboxUnreadCount = 0; } diff --git a/dev/Settings/Admin/About.js b/dev/Settings/Admin/About.js index 85f31041d..d5dc0c875 100644 --- a/dev/Settings/Admin/About.js +++ b/dev/Settings/Admin/About.js @@ -18,7 +18,7 @@ */ function AboutAdminSettings() { - this.version = ko.observable(Settings.settingsGet('Version')); + this.version = ko.observable(Settings.appSettingsGet('version')); this.access = ko.observable(!!Settings.settingsGet('CoreAccess')); this.errorDesc = ko.observable(''); diff --git a/dev/Settings/User/Folders.js b/dev/Settings/User/Folders.js index a584c5d69..9c3ed765a 100644 --- a/dev/Settings/User/Folders.js +++ b/dev/Settings/User/Folders.js @@ -60,7 +60,7 @@ } ]}); - this.useImapSubscribe = !!Settings.settingsGet('UseImapSubscribe'); + this.useImapSubscribe = !!Settings.appSettingsGet('useImapSubscribe'); } FoldersUserSettings.prototype.folderEditOnEnter = function (oFolder) diff --git a/dev/Storage/Settings.jsx b/dev/Storage/Settings.jsx index 502b02ab6..6ec6205ac 100644 --- a/dev/Storage/Settings.jsx +++ b/dev/Storage/Settings.jsx @@ -4,9 +4,17 @@ import Utils from 'Common/Utils'; class SettingsStorage { + settings = {}; + appSettings = {}; + constructor() { this.settings = window.rainloopAppData || {}; this.settings = Utils.isNormal(this.settings) ? this.settings : {}; + + this.appSettings = Utils.getConfigurationFromScriptTag('application'); + this.appSettings = Utils.isNormal(this.appSettings) ? this.appSettings : {}; + + window.console.log(this.appSettings); } /** @@ -25,6 +33,14 @@ class SettingsStorage this.settings[name] = value; } + /** + * @param {string} name + * @return {*} + */ + appSettingsGet(name) { + return Utils.isUnd(this.appSettings[name]) ? null : this.appSettings[name]; + } + /** * @param {string} name * @return {boolean} diff --git a/dev/Stores/User/App.jsx b/dev/Stores/User/App.jsx index f1b69355f..5cb322ff8 100644 --- a/dev/Stores/User/App.jsx +++ b/dev/Stores/User/App.jsx @@ -63,7 +63,7 @@ class AppUserStore extends AbstractAppStore this.contactsIsAllowed(!!Settings.settingsGet('ContactsIsAllowed')); - const attachmentsActions = Settings.settingsGet('AttachmentsActions'); + const attachmentsActions = Settings.appSettingsGet('attachmentsActions'); this.attachmentsActions(Utils.isNonEmptyArray(attachmentsActions) ? attachmentsActions : []); this.devEmail = Settings.settingsGet('DevEmail'); diff --git a/dev/View/Admin/Settings/Pane.js b/dev/View/Admin/Settings/Pane.js index 663281af9..4e71f2cdd 100644 --- a/dev/View/Admin/Settings/Pane.js +++ b/dev/View/Admin/Settings/Pane.js @@ -23,7 +23,7 @@ AbstractView.call(this, 'Right', 'AdminPane'); this.adminDomain = ko.observable(Settings.settingsGet('AdminDomain')); - this.version = ko.observable(Settings.settingsGet('Version')); + this.version = ko.observable(Settings.appSettingsGet('version')); this.capa = !!Settings.settingsGet('PremType'); this.community = RL_COMMUNITY; diff --git a/dev/View/Popup/Compose.js b/dev/View/Popup/Compose.js index 3a1b5ab8d..6900d42b3 100644 --- a/dev/View/Popup/Compose.js +++ b/dev/View/Popup/Compose.js @@ -1461,7 +1461,7 @@ }); } - if (!!Settings.settingsGet('AllowCtrlEnterOnCompose')) + if (!!Settings.appSettingsGet('allowCtrlEnterOnCompose')) { key('ctrl+enter, command+enter', Enums.KeyState.Compose, function () { self.sendCommand(); diff --git a/dev/View/User/About.js b/dev/View/User/About.js index bec47516f..0bb2d27f0 100644 --- a/dev/View/User/About.js +++ b/dev/View/User/About.js @@ -21,7 +21,7 @@ { AbstractView.call(this, 'Center', 'About'); - this.version = ko.observable(Settings.settingsGet('Version')); + this.version = ko.observable(Settings.appSettingsGet('version')); kn.constructorEnd(this); } diff --git a/dev/View/User/Login.js b/dev/View/User/Login.js index a46693a95..4e9930488 100644 --- a/dev/View/User/Login.js +++ b/dev/View/User/Login.js @@ -53,8 +53,8 @@ this.logoPowered = !!Settings.settingsGet('LoginPowered'); this.loginDescription = Utils.trim(Settings.settingsGet('LoginDescription')); - this.forgotPasswordLinkUrl = Settings.settingsGet('ForgotPasswordLinkUrl'); - this.registrationLinkUrl = Settings.settingsGet('RegistrationLinkUrl'); + this.forgotPasswordLinkUrl = Settings.appSettingsGet('forgotPasswordLinkUrl'); + this.registrationLinkUrl = Settings.appSettingsGet('registrationLinkUrl'); this.emailError = ko.observable(false); this.passwordError = ko.observable(false); @@ -266,10 +266,9 @@ }, this) ; - if (!!Settings.settingsGet('UseRsaEncryption') && Utils.rsaEncode.supported && - Settings.settingsGet('RsaPublicKey')) + if (Settings.appSettingsGet('rsaPublicKey') && Utils.rsaEncode.supported) { - fLoginRequest(Utils.rsaEncode(sPassword, Settings.settingsGet('RsaPublicKey'))); + fLoginRequest(Utils.rsaEncode(sPassword, Settings.appSettingsGet('rsaPublicKey'))); } else { diff --git a/dev/View/User/MailBox/MessageList.js b/dev/View/User/MailBox/MessageList.js index 075445144..ec0d05dad 100644 --- a/dev/View/User/MailBox/MessageList.js +++ b/dev/View/User/MailBox/MessageList.js @@ -979,7 +979,7 @@ MessageListMailBoxUserView.prototype.initUploaderForAppend = function () { - if (!Settings.settingsGet('AllowAppendMessage') || !this.dragOverArea()) + if (!Settings.appSettingsGet('allowAppendMessage') || !this.dragOverArea()) { return false; } diff --git a/rainloop/v/0.0.0/app/libraries/RainLoop/Actions.php b/rainloop/v/0.0.0/app/libraries/RainLoop/Actions.php index aa3ff9dd4..818717bd5 100644 --- a/rainloop/v/0.0.0/app/libraries/RainLoop/Actions.php +++ b/rainloop/v/0.0.0/app/libraries/RainLoop/Actions.php @@ -1395,25 +1395,24 @@ class Actions $oAccount = null; $oConfig = $this->Config(); - $oPremProvider = $this->PremProvider(); +/* +required by Index.html and rl.js: +NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBackground PluginsLink AuthAccountHash +*/ $aResult = array( - 'Version' => APP_VERSION, 'Auth' => false, 'AccountHash' => '', - 'WebPath' => \RainLoop\Utils::WebPath(), - 'AdminPath' => \strtolower($oConfig->Get('security', 'admin_panel_key', 'admin')), - 'WebVersionPath' => \RainLoop\Utils::WebVersionPath(), 'AccountSignMe' => false, 'AuthAccountHash' => '', 'MailToEmail' => '', 'Email' => '', 'DevEmail' => '', 'DevPassword' => '', - 'Title' => 'RainLoop Webmail', - 'LoadingDescription' => 'RainLoop', + 'Title' => $oConfig->Get('webmail', 'title', 'RainLoop Webmail'), + 'LoadingDescription' => $oConfig->Get('webmail', 'loading_description', 'RainLoop'), 'LoadingDescriptionEsc' => 'RainLoop', - 'FaviconUrl' => '', + 'FaviconUrl' => $oConfig->Get('webmail', 'favicon_url', ''), 'LoginDescription' => '', 'LoginPowered' => true, 'LoginLogo' => '', @@ -1427,89 +1426,27 @@ class Actions 'WelcomePageDisplay' => 'none', 'IncludeCss' => '', 'IncludeBackground' => '', - 'Token' => $oConfig->Get('security', 'csrf_protection', false) ? \RainLoop\Utils::GetCsrfToken() : '', - 'InIframe' => (bool) $oConfig->Get('labs', 'in_iframe', false), - 'AllowAdminPanel' => (bool) $oConfig->Get('security', 'allow_admin_panel', true), - 'AllowHtmlEditorSourceButton' => (bool) $oConfig->Get('labs', 'allow_html_editor_source_button', false), - 'AllowHtmlEditorBitiButtons' => (bool) $oConfig->Get('labs', 'allow_html_editor_biti_buttons', false), - 'AllowCtrlEnterOnCompose' => (bool) $oConfig->Get('labs', 'allow_ctrl_enter_on_compose', false), - 'UseRsaEncryption' => (bool) $oConfig->Get('security', 'use_rsa_encryption', false), - 'RsaPublicKey' => '', - 'CustomLoginLink' => $oConfig->Get('labs', 'custom_login_link', ''), - 'CustomLogoutLink' => $oConfig->Get('labs', 'custom_logout_link', ''), 'LoginDefaultDomain' => $oConfig->Get('login', 'default_domain', ''), 'DetermineUserLanguage' => (bool) $oConfig->Get('login', 'determine_user_language', true), 'DetermineUserDomain' => (bool) $oConfig->Get('login', 'determine_user_domain', false), 'UseLoginWelcomePage' => (bool) $oConfig->Get('login', 'welcome_page', false), - 'ForgotPasswordLinkUrl' => \trim($oConfig->Get('login', 'forgot_password_link_url', '')), - 'RegistrationLinkUrl' => \trim($oConfig->Get('login', 'registration_link_url', '')), + 'StartupUrl' => \trim(\ltrim(\trim($oConfig->Get('labs', 'startup_url', '')), '#/')), 'ContactsIsAllowed' => false, 'ChangePasswordIsAllowed' => false, 'RequireTwoFactor' => false, - 'JsHash' => \md5(\RainLoop\Utils::GetConnectionToken()), - 'UseImapThread' => (bool) $oConfig->Get('labs', 'use_imap_thread', false), - 'UseImapSubscribe' => (bool) $oConfig->Get('labs', 'use_imap_list_subscribe', true), - 'AllowAppendMessage' => (bool) $oConfig->Get('labs', 'allow_message_append', false), - 'MaterialDesign' => (bool) $oConfig->Get('labs', 'use_material_design', true), - 'FolderSpecLimit' => (int) $oConfig->Get('labs', 'folders_spec_limit', 50), - 'StartupUrl' => \trim(\ltrim(\trim($oConfig->Get('labs', 'startup_url', '')), '#/')), - 'FaviconStatus' => (bool) $oConfig->Get('labs', 'favicon_status', true), - 'Filtered' => '' !== \trim(\RainLoop\Api::Config()->Get('labs', 'imap_message_list_permanent_filter', '')), 'Community' => true, 'PremType' => false, 'Admin' => array(), 'Capa' => array(), - 'AttachmentsActions' => array(), 'Plugins' => array() ); - if ($this->GetCapa(false, \RainLoop\Enumerations\Capa::ATTACHMENTS_ACTIONS)) - { - if (!!\class_exists('ZipArchive')) - { - $aResult['AttachmentsActions'][] = 'zip'; - } - - if (\RainLoop\Utils::IsOwnCloudLoggedIn() && \class_exists('OCP\Files')) - { - $aResult['AttachmentsActions'][] = 'owncloud'; - } - - if ($oConfig->Get('social', 'dropbox_enable', false) && 0 < \strlen(\trim($oConfig->Get('social', 'dropbox_api_key', '')))) - { - $aResult['AttachmentsActions'][] = 'dropbox'; - } - } - - $aResult['AllowDropboxSocial'] = (bool) $oConfig->Get('social', 'dropbox_enable', false); - $aResult['DropboxApiKey'] = \trim($oConfig->Get('social', 'dropbox_api_key', '')); - - if ($aResult['UseRsaEncryption'] && - \file_exists(APP_PRIVATE_DATA.'rsa/public') && \file_exists(APP_PRIVATE_DATA.'rsa/private')) - { - $aResult['RsaPublicKey'] = \file_get_contents(APP_PRIVATE_DATA.'rsa/public'); - $aResult['RsaPublicKey'] = $aResult['RsaPublicKey'] ? $aResult['RsaPublicKey'] : ''; - - if (false === \strpos($aResult['RsaPublicKey'], 'PUBLIC KEY')) - { - $aResult['RsaPublicKey'] = ''; - } - } - - if (0 === \strlen($aResult['RsaPublicKey'])) - { - $aResult['UseRsaEncryption'] = false; - } - if (0 < \strlen($sAuthAccountHash)) { $aResult['AuthAccountHash'] = $sAuthAccountHash; } - $aResult['Title'] = $oConfig->Get('webmail', 'title', ''); - $aResult['LoadingDescription'] = $oConfig->Get('webmail', 'loading_description', ''); - $aResult['FaviconUrl'] = $oConfig->Get('webmail', 'favicon_url', ''); - + $oPremProvider = $this->PremProvider(); if ($oPremProvider) { $oPremProvider->PopulateAppData($aResult); @@ -1813,7 +1750,7 @@ class Actions if ($oSettingsLocal instanceof \RainLoop\Settings) { - // if ($this->GetCapa(false, \RainLoop\Enumerations\Capa::FOLDERS, $oAccount)) +// if ($this->GetCapa(false, \RainLoop\Enumerations\Capa::FOLDERS, $oAccount)) $aResult['SentFolder'] = (string) $oSettingsLocal->GetConf('SentFolder', ''); $aResult['DraftFolder'] = (string) $oSettingsLocal->GetConf('DraftFolder', ''); @@ -1851,11 +1788,11 @@ class Actions { $aResult['UserBackgroundName'] = (string) $oSettings->GetConf('UserBackgroundName', $aResult['UserBackgroundName']); $aResult['UserBackgroundHash'] = (string) $oSettings->GetConf('UserBackgroundHash', $aResult['UserBackgroundHash']); - // if (!empty($aResult['UserBackgroundName']) && !empty($aResult['UserBackgroundHash'])) - // { - // $aResult['IncludeBackground'] = './?/Raw/&q[]=/{{USER}}/UserBackground/&q[]=/'. - // $aResult['UserBackgroundHash'].'/'; - // } +// if (!empty($aResult['UserBackgroundName']) && !empty($aResult['UserBackgroundHash'])) +// { +// $aResult['IncludeBackground'] = './?/Raw/&q[]=/{{USER}}/UserBackground/&q[]=/'. +// $aResult['UserBackgroundHash'].'/'; +// } } $aResult['EnableTwoFactor'] = (bool) $oSettings->GetConf('EnableTwoFactor', $aResult['EnableTwoFactor']); diff --git a/rainloop/v/0.0.0/app/libraries/RainLoop/Service.php b/rainloop/v/0.0.0/app/libraries/RainLoop/Service.php index c5c74e0d9..0b663f54b 100644 --- a/rainloop/v/0.0.0/app/libraries/RainLoop/Service.php +++ b/rainloop/v/0.0.0/app/libraries/RainLoop/Service.php @@ -183,7 +183,7 @@ class Service // $aTemplateParameters['{{BaseTemplates}}'] = $this->oServiceActions->compileTemplates($bAdmin, false); $sResult = \strtr(\file_get_contents(APP_VERSION_ROOT_PATH.'app/templates/Index.html'), $aTemplateParameters); - $sResult = \RainLoop\Utils::ClearHtmlOutput($sResult); +// $sResult = \RainLoop\Utils::ClearHtmlOutput($sResult); if (0 < \strlen($sCacheFileName)) { $this->oActions->Cacher()->Set($sCacheFileName, $sResult); @@ -207,6 +207,11 @@ class Service // $sResult .= '][hash:'.$aTemplateParameters['{{BaseHash}}']; // $sResult .= '][session:'.\md5(\RainLoop\Utils::GetShortToken()); + if ($bMobile) + { + $sResult .= '][mobile:true'; + } + if (\RainLoop\Utils::IsOwnCloud()) { $sResult .= '][owncloud:true'; @@ -223,6 +228,76 @@ class Service return $this; } + /** + * @param bool $bAdmin = false + * @param bool $bMobile = false + * + * @return array + */ + private function indexApplicationConfiguration($bAdmin = false, $bMobile = false) + { + $oConfig = $this->oActions->Config(); + + $sRsaPublicKey = ''; + if ($oConfig->Get('security', 'use_rsa_encryption', false) && + \file_exists(APP_PRIVATE_DATA.'rsa/public') && \file_exists(APP_PRIVATE_DATA.'rsa/private')) + { + $sRsaPublicKey = @\file_get_contents(APP_PRIVATE_DATA.'rsa/public') || ''; + if (false === \strpos($sRsaPublicKey, 'PUBLIC KEY')) + { + $sRsaPublicKey = ''; + } + } + + $aAttachmentsActions = array(); + if ($this->oActions->GetCapa(false, \RainLoop\Enumerations\Capa::ATTACHMENTS_ACTIONS)) + { + if (!!\class_exists('ZipArchive')) + { + $aAttachmentsActions[] = 'zip'; + } + + if (\RainLoop\Utils::IsOwnCloudLoggedIn() && \class_exists('OCP\Files')) + { + $aAttachmentsActions[] = 'owncloud'; + } + + if ($oConfig->Get('social', 'dropbox_enable', false) && 0 < \strlen(\trim($oConfig->Get('social', 'dropbox_api_key', '')))) + { + $aAttachmentsActions[] = 'dropbox'; + } + } + + return \array_merge(array( + 'version' => APP_VERSION, + 'mobile' => $bMobile, + 'webPath' => \RainLoop\Utils::WebPath(), + 'webVersionPath' => \RainLoop\Utils::WebVersionPath(), + 'token' => $oConfig->Get('security', 'csrf_protection', false) ? \RainLoop\Utils::GetCsrfToken() : '', + 'inIframe' => (bool) $oConfig->Get('labs', 'in_iframe', false), + 'allowHtmlEditorSourceButton' => (bool) $oConfig->Get('labs', 'allow_html_editor_source_button', false), + 'allowHtmlEditorBitiButtons' => (bool) $oConfig->Get('labs', 'allow_html_editor_biti_buttons', false), + 'allowCtrlEnterOnCompose' => (bool) $oConfig->Get('labs', 'allow_ctrl_enter_on_compose', false), + 'customLoginLink' => $oConfig->Get('labs', 'custom_login_link', ''), + 'customLogoutLink' => $oConfig->Get('labs', 'custom_logout_link', ''), + 'forgotPasswordLinkUrl' => \trim($oConfig->Get('login', 'forgot_password_link_url', '')), + 'registrationLinkUrl' => \trim($oConfig->Get('login', 'registration_link_url', '')), + 'jsHash' => \md5(\RainLoop\Utils::GetConnectionToken()), + 'useImapThread' => (bool) $oConfig->Get('labs', 'use_imap_thread', false), + 'useImapSubscribe' => (bool) $oConfig->Get('labs', 'use_imap_list_subscribe', true), + 'allowAppendMessage' => (bool) $oConfig->Get('labs', 'allow_message_append', false), + 'materialDesign' => (bool) $oConfig->Get('labs', 'use_material_design', true), + 'folderSpecLimit' => (int) $oConfig->Get('labs', 'folders_spec_limit', 50), + 'faviconStatus' => (bool) $oConfig->Get('labs', 'favicon_status', true), + 'listPermanentFiltered' => '' !== \trim(\RainLoop\Api::Config()->Get('labs', 'imap_message_list_permanent_filter', '')), + 'attachmentsActions' => $aAttachmentsActions, + 'rsaPublicKey' => $sRsaPublicKey + ), $bAdmin ? array( + 'adminPath' => \strtolower($oConfig->Get('security', 'admin_panel_key', 'admin')), + 'allowAdminPanel' => (bool) $oConfig->Get('security', 'allow_admin_panel', true), + ) : array()); + } + /** * @param bool $bAdmin = false * @param bool $bMobile = false @@ -271,6 +346,7 @@ class Service '{{BaseAppOpenPgpScriptLink}}' => $aData['OpenPgpJsLink'], '{{BaseAppMainCommonScriptLink}}' => $aData['AppJsCommonLink'], '{{BaseAppMainScriptLink}}' => $aData['AppJsLink'], + '{{BaseApplicationConfigurationJson}}' => \json_encode($this->indexApplicationConfiguration($bAdmin, $bMobile)), '{{BaseVersion}}' => APP_VERSION, // '{{BaseViewport}}' => $bMobile ? 'width=device-width,initial-scale=1,user-scalable=no' : 'width=950,maximum-scale=2', '{{BaseViewport}}' => 'width=950,maximum-scale=2', diff --git a/rainloop/v/0.0.0/app/templates/Index.html b/rainloop/v/0.0.0/app/templates/Index.html index 661c7ecd4..743ee8cf6 100644 --- a/rainloop/v/0.0.0/app/templates/Index.html +++ b/rainloop/v/0.0.0/app/templates/Index.html @@ -51,23 +51,6 @@
-
An Error occurred,
@@ -85,6 +68,24 @@
+ +