diff --git a/dev/Common/Enums.js b/dev/Common/Enums.js index ed0b73545..777e1136a 100644 --- a/dev/Common/Enums.js +++ b/dev/Common/Enums.js @@ -36,7 +36,6 @@ * @enum {string} */ Enums.Capa = { - 'Prem': 'PREM', 'TwoFactor': 'TWO_FACTOR', 'OpenPGP': 'OPEN_PGP', 'Prefetch': 'PREFETCH', diff --git a/dev/Settings/Admin/Branding.js b/dev/Settings/Admin/Branding.js index 87c822fef..471355be3 100644 --- a/dev/Settings/Admin/Branding.js +++ b/dev/Settings/Admin/Branding.js @@ -20,7 +20,7 @@ Settings = require('Storage/Settings') ; - this.capa = !!Settings.capa(Enums.Capa.Prem); + this.capa = !!Settings.settingsGet('PremType'); this.capa = true; this.title = ko.observable(Settings.settingsGet('Title')); diff --git a/dev/Settings/User/Themes.js b/dev/Settings/User/Themes.js index 8786d075e..f534cd32c 100644 --- a/dev/Settings/User/Themes.js +++ b/dev/Settings/User/Themes.js @@ -4,9 +4,7 @@ 'use strict'; var - window = require('window'), _ = require('_'), - $ = require('$'), ko = require('ko'), Enums = require('Common/Enums'), diff --git a/dev/View/Admin/Settings/Pane.js b/dev/View/Admin/Settings/Pane.js index b7e058cbd..84dfeb50a 100644 --- a/dev/View/Admin/Settings/Pane.js +++ b/dev/View/Admin/Settings/Pane.js @@ -7,8 +7,6 @@ _ = require('_'), ko = require('ko'), - Enums = require('Common/Enums'), - Settings = require('Storage/Settings'), Data = require('Storage/Admin/Data'), Remote = require('Storage/Admin/Remote'), @@ -29,7 +27,7 @@ this.version = ko.observable(Settings.settingsGet('Version')); this.adminManLoadingVisibility = Data.adminManLoadingVisibility; - this.capa = !!Settings.capa(Enums.Capa.Prem); + this.capa = !!Settings.settingsGet('PremType'); this.capa = false; kn.constructorEnd(this); diff --git a/rainloop/v/0.0.0/app/src/RainLoop/Actions.php b/rainloop/v/0.0.0/app/src/RainLoop/Actions.php index d3a533a77..e8e88af77 100644 --- a/rainloop/v/0.0.0/app/src/RainLoop/Actions.php +++ b/rainloop/v/0.0.0/app/src/RainLoop/Actions.php @@ -953,6 +953,14 @@ class Actions return $this->GetAccountFromCustomToken($this->getAuthToken(), $bThrowExceptionOnFalse); } + /** + * @return bool + */ + private function PremType() + { + return false; + } + /** * @param bool $bAdmin * @param string $sAuthAccountHash = '' @@ -1003,6 +1011,7 @@ class Actions '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), + 'PremType' => $this->PremType(), 'Capa' => array(), 'Plugins' => array() ); @@ -1029,7 +1038,7 @@ class Actions $aResult['AuthAccountHash'] = $sAuthAccountHash; } - if ($this->GetCapa(true, \RainLoop\Enumerations\Capa::PREM)) + if ($this->PremType() || true) { $aResult['Title'] = $oConfig->Get('webmail', 'title', ''); $aResult['LoadingDescription'] = $oConfig->Get('webmail', 'loading_description', ''); @@ -2452,7 +2461,7 @@ class Actions $this->setConfigFromParams($oConfig, 'DetermineUserLanguage', 'login', 'determine_user_language', 'bool'); $this->setConfigFromParams($oConfig, 'DetermineUserDomain', 'login', 'determine_user_domain', 'bool'); - if ($this->GetCapa(true, \RainLoop\Enumerations\Capa::PREM)) + if ($this->PremType() || true) { $this->setConfigFromParams($oConfig, 'Title', 'webmail', 'title', 'string'); $this->setConfigFromParams($oConfig, 'LoadingDescription', 'webmail', 'loading_description', 'string'); @@ -2556,6 +2565,57 @@ class Actions )); } + /** + * @return string + */ + public function licenseHelper($sForce = false, $iCacheTimeInMin = 5) + { + $sDomain = APP_SITE; + + $oCacher = $this->Cacher(); + $oHttp = \MailSo\Base\Http::SingletonInstance(); + + if ($oHttp->CheckLocalhost($sDomain)) + { + return 'NO'; + } + + $sValue = ''; + if (!$sForce && $oCacher) + { + $iTime = $oCacher->GetTimer(\RainLoop\KeyPathHelper::LicensingDomainKeyValue($sDomain)); + if ($iTime + 60 * $iCacheTimeInMin > \time()) + { + $sValue = $oCacher->Get(\RainLoop\KeyPathHelper::LicensingDomainKeyValue($sDomain)); + } + } + + if (0 === \strlen($sValue)) + { + $iCode = 0; + $sContentType = ''; + + $sValue = $oHttp->GetUrlAsString(APP_API_PATH.'status/'.\urlencode($sDomain), + 'RainLoop/'.APP_VERSION, $sContentType, $iCode, $this->Logger(), 10, + $this->Config()->Get('labs', 'curl_proxy', ''), $this->Config()->Get('labs', 'curl_proxy_auth', ''), + array(), false + ); + + if (200 !== $iCode) + { + $sValue = ''; + } + + if ($oCacher) + { + $oCacher->Set(\RainLoop\KeyPathHelper::LicensingDomainKeyValue($sDomain), $sValue); + $oCacher->SetTimer(\RainLoop\KeyPathHelper::LicensingDomainKeyValue($sDomain)); + } + } + + return $sValue; + } + /** * @return array */ @@ -2564,54 +2624,22 @@ class Actions $iStart = \time(); $this->IsAdminLoggined(); - $sForce = '1' === (string) $this->GetActionParam('Force', '0'); + $bForce = '1' === (string) $this->GetActionParam('Force', '0'); $mResult = false; $iErrorCode = -1; - $oHttp = \MailSo\Base\Http::SingletonInstance(); - if ($oHttp->CheckLocalhost(APP_SITE)) + if (2 < \strlen(APP_SITE)) { - return $this->DefaultResponse(__FUNCTION__, $mResult); - } + $sValue = $this->licenseHelper($bForce); - $sDomain = APP_SITE; - if (2 < \strlen($sDomain)) - { - $sValue = ''; - $iTime = $this->Cacher()->GetTimer(\RainLoop\KeyPathHelper::LicensingDomainKeyValue($sDomain)); - if (!$sForce && $iTime + 60 * 5 > \time()) + if ($iStart === \time()) { - $sValue = $this->Cacher()->Get(\RainLoop\KeyPathHelper::LicensingDomainKeyValue($sDomain)); - } - - if (0 === \strlen($sValue)) - { - $iCode = 0; - $sContentType = ''; - - $sValue = $oHttp->GetUrlAsString(APP_API_PATH.'status/'.\urlencode($sDomain), - 'RainLoop', $sContentType, $iCode, $this->Logger(), 10, - $this->Config()->Get('labs', 'curl_proxy', ''), $this->Config()->Get('labs', 'curl_proxy_auth', ''), - array(), false - ); - - if (200 !== $iCode) - { - $sValue = ''; - } - - if ($iStart === \time()) - { - \sleep(1); - } - - $this->Cacher()->Set(\RainLoop\KeyPathHelper::LicensingDomainKeyValue($sDomain), $sValue); - $this->Cacher()->SetTimer(\RainLoop\KeyPathHelper::LicensingDomainKeyValue($sDomain)); + \sleep(1); } $aMatch = array(); - if (5 < \strlen($sValue) && \preg_match('/^EXPIRED:([\d]+)$/', $sValue, $aMatch)) + if (\preg_match('/^EXPIRED:([\d]+)$/', $sValue, $aMatch)) { $mResult = array( 'Banned' => false, @@ -6406,7 +6434,6 @@ class Actions $oConfig = $this->Config(); $aResult = array( - \RainLoop\Enumerations\Capa::PREM, // \RainLoop\Enumerations\Capa::FILTERS ); diff --git a/rainloop/v/0.0.0/app/templates/Views/Admin/AdminSettingsSocial.html b/rainloop/v/0.0.0/app/templates/Views/Admin/AdminSettingsSocial.html index 4ea590e2d..937f3e83b 100644 --- a/rainloop/v/0.0.0/app/templates/Views/Admin/AdminSettingsSocial.html +++ b/rainloop/v/0.0.0/app/templates/Views/Admin/AdminSettingsSocial.html @@ -138,7 +138,7 @@