From f1b85dda1303ee36871e35c29224a15bcf2c9e75 Mon Sep 17 00:00:00 2001 From: RainLoop Team Date: Mon, 16 Feb 2015 18:42:24 +0400 Subject: [PATCH] Added warning message to admin panel. --- dev/App/Admin.js | 5 ++ dev/Settings/Admin/About.js | 2 + dev/Stores/Admin/Core.js | 2 + .../0.0.0/app/libraries/RainLoop/Actions.php | 48 +++++++++++++++---- .../Views/Admin/AdminSettingsAbout.html | 11 ++++- 5 files changed, 58 insertions(+), 10 deletions(-) diff --git a/dev/App/Admin.js b/dev/App/Admin.js index e039ca6ff..8995d0448 100644 --- a/dev/App/Admin.js +++ b/dev/App/Admin.js @@ -140,6 +140,7 @@ Remote.updateCoreData(function (sResult, oData) { CoreStore.coreUpdating(false); + CoreStore.coreVersion(''); CoreStore.coreRemoteVersion(''); CoreStore.coreRemoteRelease(''); CoreStore.coreVersionCompare(-2); @@ -173,6 +174,8 @@ CoreStore.coreType(oData.Result.Type || 'stable'); CoreStore.coreUpdatable(!!oData.Result.Updatable); CoreStore.coreAccess(!!oData.Result.Access); + CoreStore.coreWarning(!!oData.Result.Warning); + CoreStore.coreVersion(oData.Result.Version || ''); CoreStore.coreRemoteVersion(oData.Result.RemoteVersion || ''); CoreStore.coreRemoteRelease(oData.Result.RemoteRelease || ''); CoreStore.coreVersionCompare(Utils.pInt(oData.Result.VersionCompare)); @@ -182,6 +185,8 @@ CoreStore.coreReal(false); CoreStore.coreChannel('stable'); CoreStore.coreType('stable'); + CoreStore.coreWarning(false); + CoreStore.coreVersion(''); CoreStore.coreRemoteVersion(''); CoreStore.coreRemoteRelease(''); CoreStore.coreVersionCompare(-2); diff --git a/dev/Settings/Admin/About.js b/dev/Settings/Admin/About.js index 24583076a..fde43a866 100644 --- a/dev/Settings/Admin/About.js +++ b/dev/Settings/Admin/About.js @@ -26,6 +26,8 @@ this.coreAccess = CoreStore.coreAccess; this.coreChecking = CoreStore.coreChecking; this.coreUpdating = CoreStore.coreUpdating; + this.coreWarning = CoreStore.coreWarning; + this.coreVersion = CoreStore.coreVersion; this.coreRemoteVersion = CoreStore.coreRemoteVersion; this.coreRemoteRelease = CoreStore.coreRemoteRelease; this.coreVersionCompare = CoreStore.coreVersionCompare; diff --git a/dev/Stores/Admin/Core.js b/dev/Stores/Admin/Core.js index 6c08eac60..cd1b71c3a 100644 --- a/dev/Stores/Admin/Core.js +++ b/dev/Stores/Admin/Core.js @@ -17,8 +17,10 @@ this.coreType = ko.observable('stable'); this.coreUpdatable = ko.observable(true); this.coreAccess = ko.observable(true); + this.coreWarning = ko.observable(false); this.coreChecking = ko.observable(false).extend({'throttle': 100}); this.coreUpdating = ko.observable(false).extend({'throttle': 100}); + this.coreVersion = ko.observable(''); this.coreRemoteVersion = ko.observable(''); this.coreRemoteRelease = ko.observable(''); this.coreVersionCompare = ko.observable(-2); 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 abf36e70b..69c65a709 100644 --- a/rainloop/v/0.0.0/app/libraries/RainLoop/Actions.php +++ b/rainloop/v/0.0.0/app/libraries/RainLoop/Actions.php @@ -1566,7 +1566,7 @@ class Actions if ($this->GetCapa(false, \RainLoop\Enumerations\Capa::THEMES, $oAccount)) { - $sTheme = $oSettings->GetConf('Theme', $sTheme); + $sTheme = $oSettingsLocal->GetConf('Theme', $sTheme); } $aResult['SentFolder'] = $oSettingsLocal->GetConf('SentFolder', ''); @@ -4095,16 +4095,38 @@ class Actions $sVersion = empty($aData['version']) ? '' : $aData['version']; $sType = empty($aData['channel']) ? 'stable' : $aData['channel']; + $sWarnings = empty($aData['warnings']) ? '' : $aData['warnings']; + $aWarnings = $sWarnings ? explode('|', $sWarnings) : array(); + + $sCurrentVersion = APP_VERSION; + + $bShowWarning = false; + if ($sCurrentVersion !== APP_DEV_VERSION) + { + foreach ($aWarnings as $sWarningVersion) + { + $sWarningVersion = \trim($sWarningVersion); + + if (\version_compare($sCurrentVersion, $sWarningVersion, '<') && + \version_compare($sVersion, $sWarningVersion, '>=')) + { + $bShowWarning = true; + break; + } + } + } + return $this->DefaultResponse(__FUNCTION__, array( 'Real' => $bReal, 'Access' => $bRainLoopAccess, 'Updatable' => $bRainLoopUpdatable, + 'Warning' => $bShowWarning, 'Channel' => $this->getCoreChannel(), 'Type' => $sType, - 'Version' => APP_VERSION, + 'Version' => $sCurrentVersion, 'RemoteVersion' => $sVersion, 'RemoteRelease' => empty($aData['release']) ? '' : $aData['release'], - 'VersionCompare' => \version_compare(APP_VERSION, $sVersion) + 'VersionCompare' => \version_compare($sCurrentVersion, $sVersion) )); } @@ -4634,13 +4656,13 @@ class Actions if ($this->GetCapa(false, \RainLoop\Enumerations\Capa::THEMES, $oAccount)) { - $this->setSettingsFromParams($oSettings, 'Theme', 'string', function ($sTheme) use ($self) { + $this->setSettingsFromParams($oSettingsLocal, 'Theme', 'string', function ($sTheme) use ($self) { return $self->ValidateTheme($sTheme); }); } else { - $oSettings->SetConf('Theme', $this->ValidateLanguage($oConfig->Get('webmail', 'theme', 'Default'))); + $oSettingsLocal->SetConf('Theme', $this->ValidateLanguage($oConfig->Get('webmail', 'theme', 'Default'))); } $this->setSettingsFromParams($oSettings, 'MPP', 'int', function ($iValue) { @@ -8620,11 +8642,19 @@ class Actions $sLanguage = $this->Config()->Get('webmail', 'language', 'en'); $sTheme = $this->Config()->Get('webmail', 'theme', 'Default'); - $oSettings = $oAccount instanceof \RainLoop\Model\Account ? $this->SettingsProvider()->Load($oAccount) : null; - if ($oSettings instanceof \RainLoop\Settings) + if ($oAccount instanceof \RainLoop\Model\Account) { - $sLanguage = $oSettings->GetConf('Language', $sLanguage); - $sTheme = $oSettings->GetConf('Theme', $sTheme); + $oSettings = $this->SettingsProvider()->Load($oAccount); + if ($oSettings instanceof \RainLoop\Settings) + { + $sLanguage = $oSettings->GetConf('Language', $sLanguage); + } + + $oSettingsLocal = $this->SettingsProvider(true)->Load($oAccount); + if ($oSettingsLocal instanceof \RainLoop\Settings) + { + $sTheme = $oSettingsLocal->GetConf('Theme', $sTheme); + } } $sLanguage = $this->ValidateLanguage($sLanguage); diff --git a/rainloop/v/0.0.0/app/templates/Views/Admin/AdminSettingsAbout.html b/rainloop/v/0.0.0/app/templates/Views/Admin/AdminSettingsAbout.html index cd07c251c..5e07de81c 100644 --- a/rainloop/v/0.0.0/app/templates/Views/Admin/AdminSettingsAbout.html +++ b/rainloop/v/0.0.0/app/templates/Views/Admin/AdminSettingsAbout.html @@ -12,7 +12,7 @@ http://rainloop.net/ -
+

RainLoop

@@ -37,6 +37,15 @@ ()
+ +
+ +    + Warning! +    + Please read the change log before updating. +
+