From 768ce1d85e98b5263d7a2697b34a1c00e9405b32 Mon Sep 17 00:00:00 2001 From: RainLoop Team Date: Fri, 6 May 2016 22:06:16 +0300 Subject: [PATCH] Small fixes --- dev/Storage/Settings.jsx | 2 +- .../0.0.0/app/libraries/RainLoop/Actions.php | 80 +++++++++++++++- .../0.0.0/app/libraries/RainLoop/Service.php | 93 ++----------------- .../app/libraries/RainLoop/ServiceActions.php | 4 +- rainloop/v/0.0.0/app/templates/Index.html | 1 - 5 files changed, 90 insertions(+), 90 deletions(-) diff --git a/dev/Storage/Settings.jsx b/dev/Storage/Settings.jsx index ea1c14512..a14ba2136 100644 --- a/dev/Storage/Settings.jsx +++ b/dev/Storage/Settings.jsx @@ -11,7 +11,7 @@ class SettingsStorage this.settings = window.rainloopAppData || {}; this.settings = Utils.isNormal(this.settings) ? this.settings : {}; - this.appSettings = Utils.getConfigurationFromScriptTag('application'); + this.appSettings = this.settings.System || null; this.appSettings = Utils.isNormal(this.appSettings) ? this.appSettings : {}; } 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 a0c3341b7..9c5eb6863 100644 --- a/rainloop/v/0.0.0/app/libraries/RainLoop/Actions.php +++ b/rainloop/v/0.0.0/app/libraries/RainLoop/Actions.php @@ -1380,6 +1380,81 @@ class Actions return !$this->PremProvider(); } + /** + * @param bool $bAdmin = false + * @param bool $bMobile = false + * @param bool $bMobileDevice = false + * + * @return array + */ + public function AppDataSystem($bAdmin = false, $bMobile = false, $bMobileDevice = false) + { + $oConfig = $this->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->GetCapa(false, $bMobile, \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, + 'mobileDevice' => $bMobileDevice, + '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', '')), + 'themes' => $this->GetThemes($bMobile, false), + 'languages' => $this->GetLanguages(false), + 'languagesAdmin' => $this->GetLanguages(true), + '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 * @param bool $bMobile = false @@ -1387,7 +1462,7 @@ class Actions * * @return array */ - public function AppData($bAdmin, $bMobile = false, $sAuthAccountHash = '') + public function AppData($bAdmin, $bMobile = false, $bMobileDevice = false, $sAuthAccountHash = '') { if (0 < \strlen($sAuthAccountHash) && \preg_match('/[^_\-\.a-zA-Z0-9]/', $sAuthAccountHash)) { @@ -1440,7 +1515,8 @@ NewThemeLink IncludeCss LoadingDescriptionEsc TemplatesLink LangLink IncludeBack 'PremType' => false, 'Admin' => array(), 'Capa' => array(), - 'Plugins' => array() + 'Plugins' => array(), + 'System' => $this->AppDataSystem($bAdmin, $bMobile, $bMobileDevice) ); if (0 < \strlen($sAuthAccountHash)) 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 c067e9545..d27dac8fa 100644 --- a/rainloop/v/0.0.0/app/libraries/RainLoop/Service.php +++ b/rainloop/v/0.0.0/app/libraries/RainLoop/Service.php @@ -194,11 +194,6 @@ class Service } $aTemplateParameters = $this->indexTemplateParameters($bAdmin, $bMobile, $bMobileDevice); - if (!empty($aTemplateParameters['{{BaseApplicationConfigurationJson}}'])) - { - $this->oActions->Logger()->Write($aTemplateParameters['{{BaseApplicationConfigurationJson}}'], - \MailSo\Log\Enumerations\Type::INFO, 'APP'); - } $sCacheFileName = ''; if ($this->oActions->Config()->Get('labs', 'cache_system_data', true) && !empty($aTemplateParameters['{{BaseHash}}'])) @@ -257,81 +252,6 @@ class Service return $this; } - /** - * @param bool $bAdmin = false - * @param bool $bMobile = false - * @param bool $bMobileDevice = false - * - * @return array - */ - private function indexApplicationConfiguration($bAdmin = false, $bMobile = false, $bMobileDevice = 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, $bMobile, \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, - 'mobileDevice' => $bMobileDevice, - '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', '')), - 'themes' => $this->oActions->GetThemes($bMobile, false), - 'languages' => $this->oActions->GetLanguages(false), - 'languagesAdmin' => $this->oActions->GetLanguages(true), - '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 string $sPath * @@ -339,9 +259,9 @@ class Service */ private function staticPath($sPath) { - $sStaticSuffix = $this->oActions->IsOpen() ? '?vo' : '?vs'; - - return \RainLoop\Utils::WebStaticPath().$sPath.$sStaticSuffix; + $sResult = \RainLoop\Utils::WebStaticPath().$sPath; + return $sResult.(false === \strpos($sResult, '?') ? '?' : '&'). + ($this->oActions->IsOpen() ? 'v=community' : 'v=standard'); } /** @@ -377,8 +297,12 @@ class Service 'AppJsLink' => $this->staticPath('js/'.($bAppJsDebug ? '' : 'min/').($bAdmin ? 'admin' : 'app').'.js') ); + $aAdd = array(); + $aAdd[] = $bMobile ? 'mobile' : 'no-mobile'; + $aAdd[] = $bMobileDevice ? '1' : '0'; + $aTemplateParameters = array( - '{{BaseAppDataScriptLink}}' => ($bAdmin ? './?/AdminAppData' : './?/AppData').($bMobile ? '@mobile/' : '/'), + '{{BaseAppDataScriptLink}}' => ($bAdmin ? './?/AdminAppData' : './?/AppData').(0 < \count($aAdd) ? '@'.\implode('-', $aAdd) : '').'/', '{{BaseAppFaviconPngLinkTag}}' => $aData['FaviconPngLink'] ? '' : '', '{{BaseAppFaviconTouchLinkTag}}' => $aData['AppleTouchLink'] ? '' : '', '{{BaseAppAppleTouchFile}}' => $aData['AppleTouchLink'], @@ -389,7 +313,6 @@ class Service '{{BaseAppOpenPgpScriptLink}}' => $aData['OpenPgpJsLink'], '{{BaseAppMainCommonScriptLink}}' => $aData['AppJsCommonLink'], '{{BaseAppMainScriptLink}}' => $aData['AppJsLink'], - '{{BaseApplicationConfigurationJson}}' => @\json_encode($this->indexApplicationConfiguration($bAdmin, $bMobile, $bMobileDevice)), '{{BaseVersion}}' => APP_VERSION, '{{BaseViewport}}' => $bMobile ? 'width=device-width,initial-scale=1,user-scalable=no' : 'width=950,maximum-scale=2', '{{BaseDir}}' => 'ltr' diff --git a/rainloop/v/0.0.0/app/libraries/RainLoop/ServiceActions.php b/rainloop/v/0.0.0/app/libraries/RainLoop/ServiceActions.php index 08a3cc4ae..ee69ccd21 100644 --- a/rainloop/v/0.0.0/app/libraries/RainLoop/ServiceActions.php +++ b/rainloop/v/0.0.0/app/libraries/RainLoop/ServiceActions.php @@ -1256,7 +1256,9 @@ class ServiceActions $this->oActions->SetSpecAuthToken($sAuthAccountHash); } - $sResult = $this->compileAppData($this->oActions->AppData($bAdmin, 'mobile' === $sAdd, $sAuthAccountHash), false); + $sResult = $this->compileAppData($this->oActions->AppData($bAdmin, + 0 === \strpos($sAdd, 'mobile'), '1' === \substr($sAdd, -1), + $sAuthAccountHash), false); $this->Logger()->Write($sResult, \MailSo\Log\Enumerations\Type::INFO, 'APPDATA'); diff --git a/rainloop/v/0.0.0/app/templates/Index.html b/rainloop/v/0.0.0/app/templates/Index.html index cf8b65624..d30932d35 100644 --- a/rainloop/v/0.0.0/app/templates/Index.html +++ b/rainloop/v/0.0.0/app/templates/Index.html @@ -68,7 +68,6 @@
-