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}
*/
Enums.Capa = {
'Prem': 'PREM',
'TwoFactor': 'TWO_FACTOR',
'OpenPGP': 'OPEN_PGP',
'Prefetch': 'PREFETCH',

View file

@ -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'));

View file

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

View file

@ -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);

View file

@ -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
);

View file

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