Small fixes

This commit is contained in:
RainLoop Team 2014-10-19 22:04:28 +04:00
parent aabed21b19
commit c6ec3fb311
6 changed files with 71 additions and 49 deletions

View file

@ -36,7 +36,6 @@
* @enum {string} * @enum {string}
*/ */
Enums.Capa = { Enums.Capa = {
'Prem': 'PREM',
'TwoFactor': 'TWO_FACTOR', 'TwoFactor': 'TWO_FACTOR',
'OpenPGP': 'OPEN_PGP', 'OpenPGP': 'OPEN_PGP',
'Prefetch': 'PREFETCH', 'Prefetch': 'PREFETCH',

View file

@ -20,7 +20,7 @@
Settings = require('Storage/Settings') Settings = require('Storage/Settings')
; ;
this.capa = !!Settings.capa(Enums.Capa.Prem); this.capa = !!Settings.settingsGet('PremType');
this.capa = true; this.capa = true;
this.title = ko.observable(Settings.settingsGet('Title')); this.title = ko.observable(Settings.settingsGet('Title'));

View file

@ -4,9 +4,7 @@
'use strict'; 'use strict';
var var
window = require('window'),
_ = require('_'), _ = require('_'),
$ = require('$'),
ko = require('ko'), ko = require('ko'),
Enums = require('Common/Enums'), Enums = require('Common/Enums'),

View file

@ -7,8 +7,6 @@
_ = require('_'), _ = require('_'),
ko = require('ko'), ko = require('ko'),
Enums = require('Common/Enums'),
Settings = require('Storage/Settings'), Settings = require('Storage/Settings'),
Data = require('Storage/Admin/Data'), Data = require('Storage/Admin/Data'),
Remote = require('Storage/Admin/Remote'), Remote = require('Storage/Admin/Remote'),
@ -29,7 +27,7 @@
this.version = ko.observable(Settings.settingsGet('Version')); this.version = ko.observable(Settings.settingsGet('Version'));
this.adminManLoadingVisibility = Data.adminManLoadingVisibility; this.adminManLoadingVisibility = Data.adminManLoadingVisibility;
this.capa = !!Settings.capa(Enums.Capa.Prem); this.capa = !!Settings.settingsGet('PremType');
this.capa = false; this.capa = false;
kn.constructorEnd(this); kn.constructorEnd(this);

View file

@ -953,6 +953,14 @@ class Actions
return $this->GetAccountFromCustomToken($this->getAuthToken(), $bThrowExceptionOnFalse); return $this->GetAccountFromCustomToken($this->getAuthToken(), $bThrowExceptionOnFalse);
} }
/**
* @return bool
*/
private function PremType()
{
return false;
}
/** /**
* @param bool $bAdmin * @param bool $bAdmin
* @param string $sAuthAccountHash = '' * @param string $sAuthAccountHash = ''
@ -1003,6 +1011,7 @@ class Actions
'UseImapThread' => (bool) $oConfig->Get('labs', 'use_imap_thread', false), 'UseImapThread' => (bool) $oConfig->Get('labs', 'use_imap_thread', false),
'UseImapSubscribe' => (bool) $oConfig->Get('labs', 'use_imap_list_subscribe', true), 'UseImapSubscribe' => (bool) $oConfig->Get('labs', 'use_imap_list_subscribe', true),
'AllowAppendMessage' => (bool) $oConfig->Get('labs', 'allow_message_append', false), 'AllowAppendMessage' => (bool) $oConfig->Get('labs', 'allow_message_append', false),
'PremType' => $this->PremType(),
'Capa' => array(), 'Capa' => array(),
'Plugins' => array() 'Plugins' => array()
); );
@ -1029,7 +1038,7 @@ class Actions
$aResult['AuthAccountHash'] = $sAuthAccountHash; $aResult['AuthAccountHash'] = $sAuthAccountHash;
} }
if ($this->GetCapa(true, \RainLoop\Enumerations\Capa::PREM)) if ($this->PremType() || true)
{ {
$aResult['Title'] = $oConfig->Get('webmail', 'title', ''); $aResult['Title'] = $oConfig->Get('webmail', 'title', '');
$aResult['LoadingDescription'] = $oConfig->Get('webmail', 'loading_description', ''); $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, 'DetermineUserLanguage', 'login', 'determine_user_language', 'bool');
$this->setConfigFromParams($oConfig, 'DetermineUserDomain', 'login', 'determine_user_domain', '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, 'Title', 'webmail', 'title', 'string');
$this->setConfigFromParams($oConfig, 'LoadingDescription', 'webmail', 'loading_description', 'string'); $this->setConfigFromParams($oConfig, 'LoadingDescription', 'webmail', 'loading_description', 'string');
@ -2557,32 +2566,28 @@ class Actions
} }
/** /**
* @return array * @return string
*/ */
public function DoAdminLicensing() public function licenseHelper($sForce = false, $iCacheTimeInMin = 5)
{ {
$iStart = \time(); $sDomain = APP_SITE;
$this->IsAdminLoggined();
$sForce = '1' === (string) $this->GetActionParam('Force', '0');
$mResult = false;
$iErrorCode = -1;
$oCacher = $this->Cacher();
$oHttp = \MailSo\Base\Http::SingletonInstance(); $oHttp = \MailSo\Base\Http::SingletonInstance();
if ($oHttp->CheckLocalhost(APP_SITE))
if ($oHttp->CheckLocalhost($sDomain))
{ {
return $this->DefaultResponse(__FUNCTION__, $mResult); return 'NO';
} }
$sDomain = APP_SITE;
if (2 < \strlen($sDomain))
{
$sValue = ''; $sValue = '';
$iTime = $this->Cacher()->GetTimer(\RainLoop\KeyPathHelper::LicensingDomainKeyValue($sDomain)); if (!$sForce && $oCacher)
if (!$sForce && $iTime + 60 * 5 > \time())
{ {
$sValue = $this->Cacher()->Get(\RainLoop\KeyPathHelper::LicensingDomainKeyValue($sDomain)); $iTime = $oCacher->GetTimer(\RainLoop\KeyPathHelper::LicensingDomainKeyValue($sDomain));
if ($iTime + 60 * $iCacheTimeInMin > \time())
{
$sValue = $oCacher->Get(\RainLoop\KeyPathHelper::LicensingDomainKeyValue($sDomain));
}
} }
if (0 === \strlen($sValue)) if (0 === \strlen($sValue))
@ -2591,7 +2596,7 @@ class Actions
$sContentType = ''; $sContentType = '';
$sValue = $oHttp->GetUrlAsString(APP_API_PATH.'status/'.\urlencode($sDomain), $sValue = $oHttp->GetUrlAsString(APP_API_PATH.'status/'.\urlencode($sDomain),
'RainLoop', $sContentType, $iCode, $this->Logger(), 10, 'RainLoop/'.APP_VERSION, $sContentType, $iCode, $this->Logger(), 10,
$this->Config()->Get('labs', 'curl_proxy', ''), $this->Config()->Get('labs', 'curl_proxy_auth', ''), $this->Config()->Get('labs', 'curl_proxy', ''), $this->Config()->Get('labs', 'curl_proxy_auth', ''),
array(), false array(), false
); );
@ -2601,17 +2606,40 @@ class Actions
$sValue = ''; $sValue = '';
} }
if ($oCacher)
{
$oCacher->Set(\RainLoop\KeyPathHelper::LicensingDomainKeyValue($sDomain), $sValue);
$oCacher->SetTimer(\RainLoop\KeyPathHelper::LicensingDomainKeyValue($sDomain));
}
}
return $sValue;
}
/**
* @return array
*/
public function DoAdminLicensing()
{
$iStart = \time();
$this->IsAdminLoggined();
$bForce = '1' === (string) $this->GetActionParam('Force', '0');
$mResult = false;
$iErrorCode = -1;
if (2 < \strlen(APP_SITE))
{
$sValue = $this->licenseHelper($bForce);
if ($iStart === \time()) if ($iStart === \time())
{ {
\sleep(1); \sleep(1);
} }
$this->Cacher()->Set(\RainLoop\KeyPathHelper::LicensingDomainKeyValue($sDomain), $sValue);
$this->Cacher()->SetTimer(\RainLoop\KeyPathHelper::LicensingDomainKeyValue($sDomain));
}
$aMatch = array(); $aMatch = array();
if (5 < \strlen($sValue) && \preg_match('/^EXPIRED:([\d]+)$/', $sValue, $aMatch)) if (\preg_match('/^EXPIRED:([\d]+)$/', $sValue, $aMatch))
{ {
$mResult = array( $mResult = array(
'Banned' => false, 'Banned' => false,
@ -6406,7 +6434,6 @@ class Actions
$oConfig = $this->Config(); $oConfig = $this->Config();
$aResult = array( $aResult = array(
\RainLoop\Enumerations\Capa::PREM,
// \RainLoop\Enumerations\Capa::FILTERS // \RainLoop\Enumerations\Capa::FILTERS
); );

View file

@ -138,7 +138,7 @@
<div class="controls"> <div class="controls">
<label data-bind="click: function () { dropboxEnable(!dropboxEnable()); }"> <label data-bind="click: function () { dropboxEnable(!dropboxEnable()); }">
<i data-bind="css: dropboxEnable() ? 'icon-checkbox-checked' : 'icon-checkbox-unchecked'"></i> <i data-bind="css: dropboxEnable() ? 'icon-checkbox-checked' : 'icon-checkbox-unchecked'"></i>
Enable Dropbox Integration (Compose attachments) Enable Dropbox Integration (Compose view)
</label> </label>
</div> </div>
</div> </div>