Fix not spam translate (Closes #168)

Small refactoring and fixes
This commit is contained in:
RainLoop Team 2014-05-16 19:57:50 +04:00
parent 07b0f20305
commit d3ee36bb97
68 changed files with 629 additions and 392 deletions

View file

@ -981,28 +981,21 @@ class Actions
'LoginDescription' => '',
'LoginCss' => '',
'Token' => $oConfig->Get('security', 'csrf_protection', false) ? \RainLoop\Utils::GetCsrfToken() : '',
'OpenPGP' => $oConfig->Get('security', 'openpgp', false),
'AllowTwoFactorAuth' => (bool) $oConfig->Get('security', 'allow_two_factor_auth', false),
'InIframe' => (bool) $oConfig->Get('labs', 'in_iframe', false),
'AllowAdminPanel' => (bool) $oConfig->Get('security', 'allow_admin_panel', true),
'AllowHtmlEditorSourceButton' => (bool) $oConfig->Get('labs', 'allow_html_editor_source_button', false),
'CustomLoginLink' => $oConfig->Get('labs', 'custom_login_link', ''),
'CustomLogoutLink' => $oConfig->Get('labs', 'custom_logout_link', ''),
'AllowAdditionalAccounts' => (bool) $oConfig->Get('webmail', 'allow_additional_accounts', true),
'AllowIdentities' => (bool) $oConfig->Get('webmail', 'allow_identities', true),
'AllowPrefetch' => (bool) $oConfig->Get('labs', 'allow_prefetch', true),
'AllowGravatar' => (bool) $oConfig->Get('labs', 'allow_gravatar', true),
'AllowCustomLogin' => (bool) $oConfig->Get('login', 'allow_custom_login', false),
'LoginDefaultDomain' => $oConfig->Get('login', 'default_domain', ''),
'DetermineUserLanguage' => (bool) $oConfig->Get('login', 'determine_user_language', true),
'AllowThemes' => (bool) $oConfig->Get('webmail', 'allow_themes', true),
'ChangePasswordIsAllowed' => false,
'ContactsIsAllowed' => false,
'ChangePasswordIsAllowed' => false,
'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),
'Capa' => $this->Capa(),
'Capa' => array(),
'Plugins' => array()
);
@ -1011,7 +1004,7 @@ class Actions
$aResult['AuthAccountHash'] = $sAuthAccountHash;
}
if ($this->GetCapa(\RainLoop\Enumerations\Capa::PREM))
if ($this->GetCapa(true, \RainLoop\Enumerations\Capa::PREM))
{
$aResult['Title'] = $oConfig->Get('webmail', 'title', '');
$aResult['LoadingDescription'] = $oConfig->Get('webmail', 'loading_description', '');
@ -1113,6 +1106,8 @@ class Actions
{
$aResult['AllowDropboxSocial'] = false;
}
$aResult['Capa'] = $this->Capa(false, $oAccount);
}
else
{
@ -1157,6 +1152,8 @@ class Actions
$aResult['WeakPassword'] = $oConfig->ValidatePassword('12345');
}
$aResult['Capa'] = $this->Capa(true);
}
$aResult['ProjectHash'] = \md5($aResult['AccountHash'].APP_VERSION.$this->Plugins()->Hash());
@ -2034,6 +2031,36 @@ class Actions
}
}
/**
* @param \RainLoop\Config\Application $oConfig
* @param string $sParamName
* @param string $sCapa
*/
private function setCapaFromParams(&$oConfig, $sParamName, $sCapa)
{
switch ($sCapa)
{
case \RainLoop\Enumerations\Capa::ADDITIONAL_ACCOUNTS:
$this->setConfigFromParams($oConfig, $sParamName, 'webmail', 'allow_additional_accounts', 'bool');
break;
case \RainLoop\Enumerations\Capa::ADDITIONAL_IDENTITIES:
$this->setConfigFromParams($oConfig, $sParamName, 'webmail', 'allow_identities', 'bool');
break;
case \RainLoop\Enumerations\Capa::TWO_FACTOR:
$this->setConfigFromParams($oConfig, $sParamName, 'security', 'allow_two_factor_auth', 'bool');
break;
case \RainLoop\Enumerations\Capa::GRAVATAR:
$this->setConfigFromParams($oConfig, $sParamName, 'labs', 'allow_gravatar', 'bool');
break;
case \RainLoop\Enumerations\Capa::THEMES:
$this->setConfigFromParams($oConfig, $sParamName, 'webmail', 'allow_themes', 'bool');
break;
case \RainLoop\Enumerations\Capa::OPEN_PGP:
$this->setConfigFromParams($oConfig, $sParamName, 'security', 'openpgp', 'bool');
break;
}
}
/**
* @param \RainLoop\Settings $oSettings
* @param string $sConfigName
@ -2091,7 +2118,6 @@ class Actions
return $self->ValidateTheme($sTheme);
});
$this->setConfigFromParams($oConfig, 'AllowThemes', 'webmail', 'allow_themes', 'bool');
$this->setConfigFromParams($oConfig, 'AllowLanguagesOnSettings', 'webmail', 'allow_languages_on_settings', 'bool');
$this->setConfigFromParams($oConfig, 'AllowLanguagesOnLogin', 'login', 'allow_languages_on_login', 'bool');
$this->setConfigFromParams($oConfig, 'AllowCustomLogin', 'login', 'allow_custom_login', 'bool');
@ -2108,14 +2134,16 @@ class Actions
return $self->ValidateContactPdoType($sType);
});
$this->setConfigFromParams($oConfig, 'AllowAdditionalAccounts', 'webmail', 'allow_additional_accounts', 'bool');
$this->setConfigFromParams($oConfig, 'AllowIdentities', 'webmail', 'allow_identities', 'bool');
$this->setConfigFromParams($oConfig, 'AllowGravatar', 'labs', 'allow_gravatar', 'bool');
$this->setCapaFromParams($oConfig, 'CapaAdditionalAccounts', \RainLoop\Enumerations\Capa::ADDITIONAL_ACCOUNTS);
$this->setCapaFromParams($oConfig, 'CapaAdditionalIdentities', \RainLoop\Enumerations\Capa::ADDITIONAL_IDENTITIES);
$this->setCapaFromParams($oConfig, 'CapaTwoFactorAuth', \RainLoop\Enumerations\Capa::TWO_FACTOR);
$this->setCapaFromParams($oConfig, 'CapaOpenPGP', \RainLoop\Enumerations\Capa::OPEN_PGP);
$this->setCapaFromParams($oConfig, 'CapaGravatar', \RainLoop\Enumerations\Capa::GRAVATAR);
$this->setCapaFromParams($oConfig, 'CapaThemes', \RainLoop\Enumerations\Capa::THEMES);
$this->setConfigFromParams($oConfig, 'DetermineUserLanguage', 'login', 'determine_user_language', 'bool');
if ($this->GetCapa(\RainLoop\Enumerations\Capa::PREM))
if ($this->GetCapa(true, \RainLoop\Enumerations\Capa::PREM))
{
$this->setConfigFromParams($oConfig, 'Title', 'webmail', 'title', 'string');
$this->setConfigFromParams($oConfig, 'LoadingDescription', 'webmail', 'loading_description', 'string');
@ -2126,8 +2154,6 @@ class Actions
}
$this->setConfigFromParams($oConfig, 'TokenProtection', 'security', 'csrf_protection', 'bool');
$this->setConfigFromParams($oConfig, 'OpenPGP', 'security', 'openpgp', 'bool');
$this->setConfigFromParams($oConfig, 'AllowTwoFactorAuth', 'security', 'allow_two_factor_auth', 'bool');
$this->setConfigFromParams($oConfig, 'EnabledPlugins', 'plugins', 'enable', 'bool');
$this->setConfigFromParams($oConfig, 'GoogleEnable', 'social', 'google_enable', 'bool');
@ -5959,23 +5985,64 @@ class Actions
}
/**
* @param bool $bAdmin
* @param \RainLoop\Account $oAccount
*
* @return array
*/
public function Capa()
public function Capa($bAdmin, $oAccount = null)
{
return array(
\RainLoop\Enumerations\Capa::PREM
);
$oConfig = $this->Config();
$aResult = array(\RainLoop\Enumerations\Capa::PREM);
if ($oConfig->Get('webmail', 'allow_additional_accounts', false))
{
$aResult[] = \RainLoop\Enumerations\Capa::ADDITIONAL_ACCOUNTS;
}
if ($oConfig->Get('webmail', 'allow_identities', true))
{
$aResult[] = \RainLoop\Enumerations\Capa::ADDITIONAL_IDENTITIES;
}
if ($oConfig->Get('security', 'allow_two_factor_auth', false))
{
$aResult[] = \RainLoop\Enumerations\Capa::TWO_FACTOR;
}
if ($oConfig->Get('labs', 'allow_gravatar', false))
{
$aResult[] = \RainLoop\Enumerations\Capa::GRAVATAR;
}
if ($oConfig->Get('labs', 'allow_prefetch', false))
{
$aResult[] = \RainLoop\Enumerations\Capa::PREFETCH;
}
if ($oConfig->Get('webmail', 'allow_themes', false))
{
$aResult[] = \RainLoop\Enumerations\Capa::THEMES;
}
if ($oConfig->Get('security', 'openpgp', false))
{
$aResult[] = \RainLoop\Enumerations\Capa::OPEN_PGP;
}
return $aResult;
}
/**
* @param bool $bAdmin
* @param string $sName
*
* @return bool
*/
public function GetCapa($sName)
public function GetCapa($bAdmin, $sName)
{
return \in_array($sName, $this->Capa());
return \in_array($sName, $this->Capa($bAdmin));
}
/**

View file

@ -5,4 +5,11 @@ namespace RainLoop\Enumerations;
class Capa
{
const PREM = 'PREM';
const TWO_FACTOR = 'TWO_FACTOR';
const OPEN_PGP = 'OPEN_PGP';
const PREFETCH = 'PREFETCH';
const GRAVATAR = 'GRAVATAR';
const THEMES = 'THEMES';
const ADDITIONAL_ACCOUNTS = 'ADDITIONAL_ACCOUNTS';
const ADDITIONAL_IDENTITIES = 'ADDITIONAL_IDENTITIES';
}

View file

@ -2,7 +2,7 @@
<div class="b-toolbar">
<div class="btn-group show-on-panel-disabled">
<a class="btn buttonResize" data-bind="click: function () { leftPanelDisabled(!leftPanelDisabled()); }">
<i class="icon-resize"></i>
<i data-bind="css: {'icon-resize-out': leftPanelDisabled(), 'icon-resize-in': !leftPanelDisabled()}"></i>
</a>
</div>
</div>

View file

@ -0,0 +1,22 @@
<div class="b-admin-about">
<div class="form-horizontal">
<div class="legend">
About
</div>
<div class="control-group">
<div class="raw">
<div class="span4">
<div class="rl-logo"></div>
</div>
<div class="span4">
RainLoop Webmail
<br />
v<span data-bind="text: version"></span>
</div>
</div>
</div>
<div class="control-group">
</div>
</div>
</div>

View file

@ -4,9 +4,9 @@
Branding
</div>
<div class="control-group">
<label class="control-label">
<label class="control-label">
Page Title
</label>
</label>
<div class="controls">
<input type="text" class="span5" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"
data-bind="value: title, saveTrigger: title.trigger" />

View file

@ -42,28 +42,28 @@
<i data-bind="css: allowLanguagesOnSettings() ? 'icon-checkbox-checked' : 'icon-checkbox-unchecked'"></i>
Allow language selection on settings screen
</label>
<label data-bind="click: function () { allowThemes(!allowThemes()); }">
<i data-bind="css: allowThemes() ? 'icon-checkbox-checked' : 'icon-checkbox-unchecked'"></i>
<label data-bind="click: function () { capaThemes(!capaThemes()); }">
<i data-bind="css: capaThemes() ? 'icon-checkbox-checked' : 'icon-checkbox-unchecked'"></i>
Allow theme selection on settings screen
</label>
</div>
</div>
<div class="control-group">
<div class="controls">
<label data-bind="click: function () { allowAdditionalAccounts(!allowAdditionalAccounts()); }">
<i data-bind="css: allowAdditionalAccounts() ? 'icon-checkbox-checked' : 'icon-checkbox-unchecked'"></i>
<label data-bind="click: function () { capaAdditionalAccounts(!capaAdditionalAccounts()); }">
<i data-bind="css: capaAdditionalAccounts() ? 'icon-checkbox-checked' : 'icon-checkbox-unchecked'"></i>
Allow additional accounts
</label>
<label data-bind="click: function () { allowIdentities(!allowIdentities()); }">
<i data-bind="css: allowIdentities() ? 'icon-checkbox-checked' : 'icon-checkbox-unchecked'"></i>
<label data-bind="click: function () { capaAdditionalIdentities(!capaAdditionalIdentities()); }">
<i data-bind="css: capaAdditionalIdentities() ? 'icon-checkbox-checked' : 'icon-checkbox-unchecked'"></i>
Allow additional identities
</label>
</div>
</div>
<div class="control-group">
<div class="controls">
<label class="inline" data-bind="click: function () { allowGravatar(!allowGravatar()); }">
<i data-bind="css: allowGravatar() ? 'icon-checkbox-checked' : 'icon-checkbox-unchecked'"></i>
<label class="inline" data-bind="click: function () { capaGravatar(!capaGravatar()); }">
<i data-bind="css: capaGravatar() ? 'icon-checkbox-checked' : 'icon-checkbox-unchecked'"></i>
Allow Gravatar
</label>
(<a class="g-ui-link" href="http://en.gravatar.com/" target="_blank">http://en.gravatar.com/</a>)

View file

@ -14,8 +14,8 @@
</div>
<div class="control-group">
<div class="controls">
<label data-bind="click: function () { openPGP(!openPGP()); }">
<i data-bind="css: openPGP() ? 'icon-checkbox-checked' : 'icon-checkbox-unchecked'"></i>
<label data-bind="click: function () { capaOpenPGP(!capaOpenPGP()); }">
<i data-bind="css: capaOpenPGP() ? 'icon-checkbox-checked' : 'icon-checkbox-unchecked'"></i>
&nbsp;&nbsp;
Allow OpenPGP <span style="color:red">(beta)</span>
</label>
@ -23,8 +23,8 @@
</div>
<div class="control-group">
<div class="controls">
<label data-bind="click: function () { allowTwoFactorAuth(!allowTwoFactorAuth()); }">
<i data-bind="css: allowTwoFactorAuth() ? 'icon-checkbox-checked' : 'icon-checkbox-unchecked'"></i>
<label data-bind="click: function () { capaTwoFactorAuth(!capaTwoFactorAuth()); }">
<i data-bind="css: capaTwoFactorAuth() ? 'icon-checkbox-checked' : 'icon-checkbox-unchecked'"></i>
&nbsp;&nbsp;
Allow 2-Step Verification (Google Authenticator)
</label>

View file

@ -30,7 +30,7 @@
</div>
<div class="btn-group">
<a class="btn buttonResize" data-bind="click: function () { leftPanelDisabled(!leftPanelDisabled()); }">
<i class="icon-resize"></i>
<i data-bind="css: {'icon-resize-out': leftPanelDisabled(), 'icon-resize-in': !leftPanelDisabled()}"></i>
</a>
</div>
</div>

View file

@ -120,7 +120,7 @@
</a>
</li>
<li class="divider"></li>
<li class="e-item" data-bind="visible: allowOpenPGP, click: openOpenPgpPopup, css: {'disabled': isHtml()}">
<li class="e-item" data-bind="visible: capaOpenPGP, click: openOpenPgpPopup, css: {'disabled': isHtml()}">
<a class="e-link">
<i class="icon-key"></i>
&nbsp;&nbsp;

View file

@ -1,8 +1,8 @@
<div class="b-settins-left g-ui-user-select-none">
<div class="b-toolbar">
<div class="btn-group show-on-panel-disabled">
<div class="btn-group">
<a class="btn buttonResize" data-bind="click: function () { leftPanelDisabled(!leftPanelDisabled()); }">
<i class="icon-resize"></i>
<i data-bind="css: {'icon-resize-out': leftPanelDisabled(), 'icon-resize-in': !leftPanelDisabled()}"></i>
</a>
</div>
</div>

View file

@ -32,7 +32,7 @@
<!-- /ko -->
<li class="divider" role="presentation"></li>
<!-- /ko -->
<!-- ko if: allowAddAccount -->
<!-- ko if: capaAdditionalAccounts -->
<li class="e-item" role="presentation">
<a class="e-link menuitem" href="#" tabindex="-1" data-bind="click: addAccountClick">
<i class="icon-user-add"></i>