Identities refactoring and improvements (Reply-To and BCC)

This commit is contained in:
RainLoop Team 2015-02-06 19:26:20 +04:00
parent 3e01887f85
commit 493191375f
43 changed files with 578 additions and 1051 deletions

View file

@ -232,11 +232,11 @@ abstract class NetClient
$this->bSecure = \MailSo\Net\Enumerations\ConnectionSecurityType::UseSSL(
$this->iConnectedPort, $this->iSecurityType);
$this->sConnectedHost = \in_array(\strtolower(\substr($this->sConnectedHost, 0, 6)), array('ssl://', 'tcp://')) ?
\substr($this->sConnectedHost, 6) : $this->sConnectedHost;
$this->sConnectedHost = ($this->bSecure ? 'ssl://' : 'tcp://').$this->sConnectedHost;
// $this->sConnectedHost = ($this->bSecure ? 'ssl://' : '').$this->sConnectedHost;
if (!\preg_match('/^[a-z0-9._]{2,8}:\/\//i', $this->sConnectedHost))
{
$this->sConnectedHost = ($this->bSecure ? 'ssl://' : 'tcp://').$this->sConnectedHost;
// $this->sConnectedHost = ($this->bSecure ? 'ssl://' : '').$this->sConnectedHost;
}
if (!$this->bSecure && \MailSo\Net\Enumerations\ConnectionSecurityType::SSL === $this->iSecurityType)
{
@ -307,21 +307,29 @@ abstract class NetClient
}
}
/**
* @param {int} $iCryptoType = STREAM_CRYPTO_METHOD_TLS_CLIENT
*/
public function EnableCrypto($iCryptoType = STREAM_CRYPTO_METHOD_TLS_CLIENT)
public function EnableCrypto()
{
$bError = true;
if (\is_resource($this->rConnect) &&
\MailSo\Base\Utils::FunctionExistsAndEnabled('stream_socket_enable_crypto'))
{
if (!@\stream_socket_enable_crypto($this->rConnect, true, $iCryptoType))
switch (true)
{
$this->writeLogException(
new \MailSo\Net\Exceptions\Exception('Cannot enable STARTTLS. [type='.$iCryptoType.']'),
\MailSo\Log\Enumerations\Type::ERROR, true);
case defined('STREAM_CRYPTO_METHOD_ANY_CLIENT') &&
@\stream_socket_enable_crypto($this->rConnect, true, STREAM_CRYPTO_METHOD_ANY_CLIENT):
case @\stream_socket_enable_crypto($this->rConnect, true, STREAM_CRYPTO_METHOD_TLS_CLIENT):
case @\stream_socket_enable_crypto($this->rConnect, true, STREAM_CRYPTO_METHOD_SSLv23_CLIENT):
$bError = false;
break;
}
}
if ($bError)
{
$this->writeLogException(
new \MailSo\Net\Exceptions\Exception('Cannot enable STARTTLS.'),
\MailSo\Log\Enumerations\Type::ERROR, true);
}
}
/**

View file

@ -1521,9 +1521,6 @@ class Actions
$aResult['UseThreads'] = (bool) $oConfig->Get('defaults', 'mail_use_threads', false);
$aResult['ReplySameFolder'] = (bool) $oConfig->Get('defaults', 'mail_reply_same_folder', false);
$aResult['ContactsAutosave'] = (bool) $oConfig->Get('defaults', 'contacts_autosave', true);
$aResult['DefaultIdentityID'] = '';
$aResult['DisplayName'] = '';
$aResult['ReplyTo'] = '';
$aResult['Signature'] = '';
$aResult['EnableTwoFactor'] = false;
$aResult['ParentEmail'] = '';
@ -1557,12 +1554,14 @@ class Actions
$aResult['MPP'] = (int) $oSettings->GetConf('MPP', $aResult['MPP']);
$aResult['SoundNotification'] = (bool) $oSettings->GetConf('SoundNotification', $aResult['SoundNotification']);
$aResult['DesktopNotifications'] = (bool) $oSettings->GetConf('DesktopNotifications', $aResult['DesktopNotifications']);
$aResult['Layout'] = (int) $oSettings->GetConf('Layout', $aResult['Layout']);
$aResult['UseCheckboxesInList'] = (bool) $oSettings->GetConf('UseCheckboxesInList', $aResult['UseCheckboxesInList']);
$aResult['Layout'] = (int) $oSettings->GetConf('Layout', $aResult['Layout']);
$aResult['UseThreads'] = (bool) $oSettingsLocal->GetConf('UseThreads', $aResult['UseThreads']);
$aResult['ReplySameFolder'] = (bool) $oSettingsLocal->GetConf('ReplySameFolder', $aResult['ReplySameFolder']);
$aResult['Signature'] = $oSettingsLocal->GetConf('Signature', $aResult['Signature']);
if ($this->GetCapa(false, \RainLoop\Enumerations\Capa::USER_BACKGROUND, $oAccount))
{
$aResult['UserBackgroundName'] = (string) $oSettings->GetConf('UserBackgroundName', $aResult['UserBackgroundName']);
@ -1574,11 +1573,6 @@ class Actions
// }
}
$aResult['DefaultIdentityID'] = $oSettingsLocal->GetConf('DefaultIdentityID', $oAccount ? $oAccount->Email() : $aResult['DefaultIdentityID']);
$aResult['DisplayName'] = $oSettingsLocal->GetConf('DisplayName', $aResult['DisplayName']);
$aResult['ReplyTo'] = $oSettingsLocal->GetConf('ReplyTo', $aResult['ReplyTo']);
$aResult['Signature'] = $oSettingsLocal->GetConf('Signature', $aResult['Signature']);
$aResult['EnableTwoFactor'] = !!$oSettings->GetConf('EnableTwoFactor', $aResult['EnableTwoFactor']);
$aResult['ParentEmail'] = $oAccount->ParentEmail();
@ -2088,7 +2082,11 @@ class Actions
'accounts'
);
$aAccounts = $sAccounts ? @\unserialize($sAccounts) : array();
if ('' !== $sAccounts && '{' === \substr($sAccounts, 0, 1))
{
$aAccounts = @\json_decode($sAccounts, true);
}
if (\is_array($aAccounts) && 0 < \count($aAccounts))
{
if (1 === \count($aAccounts))
@ -2135,31 +2133,47 @@ class Actions
{
$aSubIdentities = array();
$oSettingsLocal = $this->SettingsProvider(true)->Load($oAccount);
if ($oSettingsLocal)
$sData = $this->StorageProvider(true)->Get($oAccount,
\RainLoop\Providers\Storage\Enumerations\StorageType::CONFIG,
'identities'
);
if ('' !== $sData && '[' === \substr($sData, 0, 1))
{
$sData = $oSettingsLocal->GetConf('Identities', '');
if ('' !== $sData && '[' === \substr($sData, 0, 1))
{
$aSubIdentities = @\json_decode($sData, true);
$aSubIdentities = \is_array($aSubIdentities) ? $aSubIdentities : array();
}
$aSubIdentities = @\json_decode($sData, true);
}
if (0 < \count($aSubIdentities))
$bHasAccountIdentity = false;
if (\is_array($aSubIdentities) && 0 < \count($aSubIdentities))
{
foreach ($aSubIdentities as $aItem)
{
if (isset($aItem['Id'], $aItem['Email'], $aItem['Name'], $aItem['ReplyTo'], $aItem['Bcc']) &&
$aItem['Id'] !== $oAccount->Email())
{
$oItem = \RainLoop\Model\Identity::NewInstance($aItem['Id'], $aItem['Email'],
$aItem['Name'], $aItem['ReplyTo'], $aItem['Bcc']);
$oItem = \RainLoop\Model\Identity::NewInstance();
$oItem->FromJSON($aItem);
$aIdentities[] = $oItem;
if ($oItem && $oItem->Validate())
{
if ('' === $oItem->Id())
{
$oItem->SetEmail($oAccount->Email());
$bHasAccountIdentity = true;
\array_unshift($aIdentities, $oItem);
}
else
{
\array_push($aIdentities, $oItem);
}
}
}
}
if (!$bHasAccountIdentity)
{
\array_unshift($aIdentities,
\RainLoop\Model\Identity::NewInstanceFromAccount($oAccount));
}
}
return $aIdentities;
@ -2167,61 +2181,35 @@ class Actions
/**
* @param \RainLoop\Model\Account $oAccount
* @param string $sID
* @param bool $bFirstOnEmpty = false
*
* @return array
* @return \RainLoop\Model\Identity
*/
public function GetIdentitiesNew($oAccount)
public function GetIdentityByID($oAccount, $sID, $bFirstOnEmpty = false)
{
$aIdentities = array();
if ($oAccount)
$aIdentities = $this->GetIdentities($oAccount);
if (\is_array($aIdentities))
{
$oAccountIdentity = \RainLoop\Model\Identity::NewInstance('', $oAccount->Email());
$aSubIdentities = array();
$oSettingsLocal = $this->SettingsProvider(true)->Load($oAccount);
if ($oSettingsLocal)
foreach ($aIdentities as $oIdentity)
{
$sData = $oSettingsLocal->GetConf('Identities', '');
if ('' !== $sData && '[' === \substr($sData, 0, 1))
if ($oIdentity && $sID === $oIdentity->Id())
{
$aSubIdentities = @\json_decode($sData, true);
$aSubIdentities = \is_array($aSubIdentities) ? $aSubIdentities : array();
return $oIdentity;
}
}
if (0 < \count($aSubIdentities))
{
foreach ($aSubIdentities as $aItem)
{
if (isset($aItem['Id'], $aItem['Email']))
{
if (0 < \strlen($aItem['Id']))
{
$oItem = \RainLoop\Model\Identity::NewInstance($aItem['Id'], $aItem['Email']);
}
else
{
$oItem = $oAccountIdentity;
}
$oItem->SetName(isset($aItem['Name']) ? $aItem['Name'] : '');
$oItem->SetReplyTo(isset($aItem['ReplyTo']) ? $aItem['ReplyTo'] : '');
$oItem->SetBcc(isset($aItem['Bcc']) ? $aItem['Bcc'] : '');
$oItem->SetSignature(isset($aItem['Signature']) ? $aItem['Signature'] : '');
if ('' !== $oItem->Id())
{
\array_push($aIdentities, $oItem);
}
}
}
}
\array_unshift($aIdentities, $oAccountIdentity);
}
return $aIdentities;
return $bFirstOnEmpty && \is_array($aIdentities) && isset($aIdentities[0]) ? $aIdentities[0] : null;
}
/**
* @param \RainLoop\Model\Account $oAccount
*
* @return \RainLoop\Model\Identity
*/
public function GetAccountIdentity($oAccount)
{
return $this->GetIdentityByID($oAccount, '', true);
}
/**
@ -2246,7 +2234,7 @@ class Actions
$this->StorageProvider()->Put($oAccount,
\RainLoop\Providers\Storage\Enumerations\StorageType::CONFIG,
'accounts',
@\serialize($aAccounts)
@\json_encode($aAccounts)
);
}
}
@ -2259,20 +2247,17 @@ class Actions
*/
public function SetIdentities($oAccount, $aIdentities = array())
{
$oSettingsLocal = $this->SettingsProvider(true)->Load($oAccount);
if ($oSettingsLocal)
$aResult = array();
foreach ($aIdentities as $oItem)
{
$aResult = array();
foreach ($aIdentities as $oItem)
{
$aResult[] = $oItem->ToSimpleJSON(false);
}
$oSettingsLocal->SetConf('Identities', @\json_encode($aResult));
return $this->SettingsProvider(true)->Save($oAccount, $oSettingsLocal);
$aResult[] = $oItem->ToSimpleJSON(false);
}
return false;
return $this->StorageProvider(true)->Put($oAccount,
\RainLoop\Providers\Storage\Enumerations\StorageType::CONFIG,
'identities',
@\json_encode($aResult)
);
}
/**
@ -2443,55 +2428,26 @@ class Actions
{
$oAccount = $this->getAccountFromToken();
if (!$this->GetCapa(false, \RainLoop\Enumerations\Capa::ADDITIONAL_IDENTITIES, $oAccount))
$oIdentity = \RainLoop\Model\Identity::NewInstance();
if (!$oIdentity->FromJSON($this->GetActionParams(), true))
{
return $this->FalseResponse(__FUNCTION__);
throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::InvalidInputArgument);
}
$sId = \trim($this->GetActionParam('Id', ''));
$sEmail = \trim($this->GetActionParam('Email', ''));
$sName = \trim($this->GetActionParam('Name', ''));
$sReplyTo = \trim($this->GetActionParam('ReplyTo', ''));
$sBcc = \trim($this->GetActionParam('Bcc', ''));
$aIdentitiesForSave = array();
if (empty($sEmail))
{
throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::UnknownError);
}
$oEditIdentity = null;
$aIdentities = $this->GetIdentities($oAccount);
if (0 < \strlen($sId))
foreach ($aIdentities as $oItem)
{
foreach ($aIdentities as &$oItem)
if ($oItem && $oItem->Id() !== $oIdentity->Id())
{
if ($oItem && $sId === $oItem->Id())
{
$oEditIdentity =& $oItem;
break;
}
$aIdentitiesForSave[] = $oItem;
}
}
else
{
$sId = \md5($sEmail.\microtime(true));
}
if (!$oEditIdentity)
{
$aIdentities[] = \RainLoop\Model\Identity::NewInstance($sId, $sEmail, $sName, $sReplyTo, $sBcc);
}
else
{
$oEditIdentity
->SetEmail($sEmail)
->SetName($sName)
->SetReplyTo($sReplyTo)
->SetBcc($sBcc)
;
}
$aIdentitiesForSave[] = $oIdentity;
return $this->DefaultResponse(__FUNCTION__, $this->SetIdentities($oAccount, $aIdentities));
return $this->DefaultResponse(__FUNCTION__, $this->SetIdentities($oAccount, $aIdentitiesForSave));
}
/**
@ -2503,11 +2459,6 @@ class Actions
{
$oAccount = $this->getAccountFromToken();
if (!$this->GetCapa(false, \RainLoop\Enumerations\Capa::ADDITIONAL_IDENTITIES, $oAccount))
{
return $this->FalseResponse(__FUNCTION__);
}
$sId = \trim($this->GetActionParam('IdToDelete', ''));
if (empty($sId))
{
@ -2569,15 +2520,9 @@ class Actions
}
}
$mIdentities = false;
if ($this->GetCapa(false, \RainLoop\Enumerations\Capa::ADDITIONAL_IDENTITIES, $oAccount))
{
$mIdentities = $this->GetIdentities($oAccount);
}
return $this->DefaultResponse(__FUNCTION__, array(
'Accounts' => $mAccounts,
'Identities' => $mIdentities
'Identities' => $this->GetIdentities($oAccount)
));
}
@ -2663,33 +2608,6 @@ class Actions
));
}
/**
* @return array
*
* @throws \MailSo\Base\Exceptions\Exception
*/
public function DoAccountsAndIdentitiesNew()
{
$oAccount = $this->getAccountFromToken();
$mAccounts = false;
if ($this->GetCapa(false, \RainLoop\Enumerations\Capa::ADDITIONAL_ACCOUNTS, $oAccount))
{
$mAccounts = $this->GetAccounts($oAccount);
$mAccounts = \array_keys($mAccounts);
foreach ($mAccounts as $iIndex => $sName)
{
$mAccounts[$iIndex] = \MailSo\Base\Utils::IdnToUtf8($sName);
}
}
return $this->DefaultResponse(__FUNCTION__, array(
'Accounts' => $mAccounts,
'Identities' => $this->GetIdentitiesNew($oAccount)
));
}
/**
* @param \RainLoop\Model\Account $oAccount
*/
@ -2879,9 +2797,6 @@ class Actions
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;
@ -2984,7 +2899,6 @@ class Actions
});
$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);
@ -4461,9 +4375,6 @@ class Actions
$this->setSettingsFromParams($oSettingsLocal, 'UseThreads', 'bool');
$this->setSettingsFromParams($oSettingsLocal, 'ReplySameFolder', 'bool');
$this->setSettingsFromParams($oSettingsLocal, 'DefaultIdentityID', 'string');
$this->setSettingsFromParams($oSettingsLocal, 'DisplayName', 'string');
$this->setSettingsFromParams($oSettingsLocal, 'ReplyTo', 'string');
$this->setSettingsFromParams($oSettingsLocal, 'Signature', 'string');
return $this->DefaultResponse(__FUNCTION__,
@ -5204,10 +5115,11 @@ class Actions
*/
private function buildMessage($oAccount, $bWithDraftInfo = true)
{
$sFrom = $this->GetActionParam('From', '');
$sIdentityID = $this->GetActionParam('IdentityID', '');
$sTo = $this->GetActionParam('To', '');
$sCc = $this->GetActionParam('Cc', '');
$sBcc = $this->GetActionParam('Bcc', '');
$sReplyTo = $this->GetActionParam('ReplyTo', '');
$sSubject = $this->GetActionParam('Subject', '');
$bTextIsHtml = '1' === $this->GetActionParam('TextIsHtml', '0');
$bReadReceiptRequest = '1' === $this->GetActionParam('ReadReceiptRequest', '0');
@ -5224,26 +5136,23 @@ class Actions
$oMessage->SetXMailer('RainLoop/'.APP_VERSION);
$oSettingsLocal = $this->SettingsProvider(true)->Load($oAccount);
if ($this->GetCapa(false, \RainLoop\Enumerations\Capa::ADDITIONAL_IDENTITIES, $oAccount))
$oFromIdentity = $this->GetIdentityByID($oAccount, $sIdentityID);
if ($oFromIdentity)
{
$oMessage->SetFrom(\MailSo\Mime\Email::Parse($sFrom));
$oMessage->SetFrom(\MailSo\Mime\Email::NewInstance(
$oFromIdentity->Email(), $oFromIdentity->Name()));
}
else
{
$sDisplayName = \trim($oSettingsLocal->GetConf('DisplayName', ''));
$sReplyTo = \trim($oSettingsLocal->GetConf('ReplyTo', ''));
$oMessage->SetFrom(\MailSo\Mime\Email::Parse($oAccount->Email()));
}
$oMessage->SetFrom(\MailSo\Mime\Email::NewInstance($oAccount->Email(), $sDisplayName));
if (!empty($sReplyTo))
if (!empty($sReplyTo))
{
$oReplyTo = \MailSo\Mime\EmailCollection::NewInstance($sReplyTo);
if ($oReplyTo && 0 < $oReplyTo->Count())
{
$oReplyTo = \MailSo\Mime\EmailCollection::NewInstance($sReplyTo);
if ($oReplyTo && $oReplyTo->Count())
{
$oMessage->SetReplyTo($oReplyTo);
}
$oMessage->SetReplyTo($oReplyTo);
}
}
@ -5380,7 +5289,9 @@ class Actions
$sSubject = $this->GetActionParam('Subject', '');
$sText = $this->GetActionParam('Text', '');
if (empty($sReadReceipt) || empty($sSubject) || empty($sText))
$oIdentity = $this->GetAccountIdentity($oAccount);
if (empty($sReadReceipt) || empty($sSubject) || empty($sText) || !$oIdentity)
{
throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::UnknownError);
}
@ -5390,13 +5301,9 @@ class Actions
$oMessage->SetXMailer('RainLoop/'.APP_VERSION);
$oSettingsLocal = $this->SettingsProvider(true)->Load($oAccount);
$sDisplayName = \trim($oSettingsLocal->GetConf('DisplayName', ''));
$sReplyTo = \trim($oSettingsLocal->GetConf('ReplyTo', ''));
$oMessage->SetFrom(\MailSo\Mime\Email::NewInstance($oAccount->Email(), $sDisplayName));
$oMessage->SetFrom(\MailSo\Mime\Email::NewInstance($oIdentity->Email(), $oIdentity->Name()));
$sReplyTo = $oIdentity->ReplyTo();
if (!empty($sReplyTo))
{
$oReplyTo = \MailSo\Mime\EmailCollection::NewInstance($sReplyTo);
@ -7374,11 +7281,6 @@ class Actions
$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) &&
($bAdmin || ($oAccount && !$oAccount->IsAdditionalAccount())))
{
@ -8284,6 +8186,14 @@ class Actions
$this->aCurrentActionParams[$sKey] : $mDefault;
}
/**
* @return mixed
*/
public function GetActionParams()
{
return $this->aCurrentActionParams;
}
/**
* @param string $sKey
*

View file

@ -15,5 +15,4 @@ class Capa
const FILTERS = 'FILTERS';
const ATTACHMENT_THUMBNAILS = 'ATTACHMENT_THUMBNAILS';
const ADDITIONAL_ACCOUNTS = 'ADDITIONAL_ACCOUNTS';
const ADDITIONAL_IDENTITIES = 'ADDITIONAL_IDENTITIES';
}

View file

@ -30,35 +30,36 @@ class Identity
private $sBcc;
/**
* @param string $sId
* @param string $sEmail
* @param string $sName
* @param string $sReplyTo
* @param string $sBcc
* @param string $sId = ''
* @param string $sEmail = ''
*
* @return void
*/
protected function __construct($sId, $sEmail, $sName, $sReplyTo, $sBcc)
protected function __construct($sId = '', $sEmail = '')
{
$this->sId = $sId;
$this->sEmail = \MailSo\Base\Utils::IdnToAscii($sEmail, true);
$this->sName = \trim($sName);
$this->sReplyTo = \trim($sReplyTo);
$this->sBcc = \trim($sBcc);
$this->sEmail = $sEmail;
$this->sName = '';
$this->sReplyTo = '';
$this->sBcc = '';
}
/**
* @param string $sId
* @param string $sEmail
* @param string $sName = ''
* @param string $sReplyTo = ''
* @param string $sBcc = ''
* @return \RainLoop\Model\Identity
*/
public static function NewInstance()
{
return new self();
}
/**
* @param \RainLoop\Model\Account $oAccount
*
* @return \RainLoop\Model\Identity
*/
public static function NewInstance($sId, $sEmail, $sName = '', $sReplyTo = '', $sBcc = '')
public static function NewInstanceFromAccount(\RainLoop\Model\Account $oAccount)
{
return new self($sId, $sEmail, $sName, $sReplyTo, $sBcc);
return new self('', $oAccount->Email());
}
/**
@ -69,18 +70,6 @@ class Identity
return $this->sId;
}
/**
* @param string $sId
*
* @return \RainLoop\Model\Identity
*/
public function SetId($sId)
{
$this->sId = $sId;
return $this;
}
/**
* @return string
*/
@ -96,7 +85,7 @@ class Identity
*/
public function SetEmail($sEmail)
{
$this->sEmail = \MailSo\Base\Utils::IdnToAscii($sEmail, true);
$this->sEmail = $sEmail;
return $this;
}
@ -109,18 +98,6 @@ class Identity
return $this->sName;
}
/**
* @param string $sName
*
* @return \RainLoop\Model\Identity
*/
public function SetName($sName)
{
$this->sName = $sName;
return $this;
}
/**
* @return string
*/
@ -129,18 +106,6 @@ class Identity
return $this->sReplyTo;
}
/**
* @param string $sReplyTo
*
* @return \RainLoop\Model\Identity
*/
public function SetReplyTo($sReplyTo)
{
$this->sReplyTo = $sReplyTo;
return $this;
}
/**
* @return string
*/
@ -150,15 +115,25 @@ class Identity
}
/**
* @param string $sBcc
* @param array $aData
* @param bool $bAjax = false
*
* @return \RainLoop\Model\Identity
* @return bool
*/
public function SetBcc($sBcc)
public function FromJSON($aData, $bAjax = false)
{
$this->sBcc = $sBcc;
if (isset($aData['Id'], $aData['Email']) && !empty($aData['Email']))
{
$this->sId = $aData['Id'];
$this->sEmail = $bAjax ? \MailSo\Base\Utils::IdnToAscii($aData['Email'], true) : $aData['Email'];
$this->sName = isset($aData['Name']) ? $aData['Name'] : '';
$this->sReplyTo = !empty($aData['ReplyTo']) ? $aData['ReplyTo'] : '';
$this->sBcc = !empty($aData['Bcc']) ? $aData['Bcc'] : '';
return $this;
return true;
}
return false;
}
/**
@ -176,4 +151,12 @@ class Identity
'Bcc' => $this->Bcc()
);
}
/**
* @return bool
*/
public function Validate()
{
return !empty($this->sEmail);
}
}

View file

@ -12,7 +12,6 @@
<meta http-equiv="refresh" content="0; URL=./?/BadBrowser" />
<![endif]-->
<script data-cfasync="false">
window.__rlt__ = (new Date).getTime();
if (!window.navigator || !window.navigator.cookieEnabled) {
window.document.location.replace('./?/NoCookie');
}

View file

@ -136,13 +136,6 @@
value: capaAdditionalAccounts
}
}"></div>
<div data-bind="component: {
name: 'Checkbox',
params: {
label: 'Allow additional identities',
value: capaAdditionalIdentities
}
}"></div>
</div>
</div>
</div>

View file

@ -243,6 +243,11 @@
&nbsp;
<span class="bcc" data-bind="text: viewBcc, title: viewBcc"></span>
</div>
<div data-bind="visible: '' !== viewReplyTo()">
<span class="i18n uiLabel labelBcc" data-i18n-text="MESSAGE/LABEL_REPLY_TO"></span>:
&nbsp;
<span class="bcc" data-bind="text: viewReplyTo, title: viewReplyTo"></span>
</div>
<div data-bind="visible: '' !== viewDate()">
<span class="i18n uiLabel labelBcc" data-i18n-text="MESSAGE/LABEL_DATE"></span>:
&nbsp;

View file

@ -36,7 +36,7 @@
<div class="dropdown pull-left" data-bind="registrateBootstrapDropdown: true, openDropdownTrigger: identitiesDropdownTrigger">
<a class="dropdown-toggle g-ui-dropdown e-identity" href="#" tabindex="-1"
id="identity-label-id" role="button" data-toggle="dropdown"
data-bind="text: currentIdentityString, dropdownCloser: true, css: {'multiply': 1 < identitiesOptions().length }">
data-bind="text: currentIdentityView, dropdownCloser: true, css: {'multiply': 1 < identitiesOptions().length }">
</a>
<!-- ko if: 1 < identitiesOptions().length -->
<ul class="dropdown-menu g-ui-menu" role="menu" aria-labelledby="identity-label-id">
@ -90,8 +90,14 @@
<span class="i18n g-ui-link" data-i18n-text="COMPOSE/TITLE_CC"
data-bind="visible: !showCc(), click: function () { showCc(true); }"></span>
&nbsp;&nbsp;
<span class="i18n g-ui-link" data-i18n-text="COMPOSE/TITLE_BCC"
data-bind="visible: !showBcc(), click: function () { showBcc(true); }"></span>
<span data-bind="visible: !showBcc()">
<span class="i18n g-ui-link" data-i18n-text="COMPOSE/TITLE_BCC"
data-bind="click: function () { showBcc(true); }"></span>
&nbsp;&nbsp;
</span>
<span class="i18n g-ui-link" data-i18n-text="COMPOSE/TITLE_REPLY_TO"
data-bind="visible: !showReplyTo(), click: function () { showReplyTo(true); }"></span>
&nbsp;
</span>
</div>
</div>
@ -124,7 +130,7 @@
<input type="text" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" data-bind="emailsTags: bcc, autoCompleteSource: emailsSource" />
</div>
</div>
<div class="e-row reply-to-row" data-bind="visible: false">
<div class="e-row reply-to-row" data-bind="visible: showReplyTo">
<div class="e-cell e-label">
<span class="i18n" data-i18n-text="COMPOSE/TITLE_REPLY_TO"></span>
</div>

View file

@ -37,7 +37,7 @@
data-bind="value: name, onEnter: addOrEditIdentityCommand, hasfocus: name.focused" />
</div>
</div>
<div class="control-group" data-bind="css: {'error': replyTo.hasError}" style="display: none">
<div class="control-group" data-bind="css: {'error': replyTo.hasError}">
<label class="i18n control-label" data-i18n-text="POPUPS_IDENTITIES/LABEL_REPLY_TO"></label>
<div class="controls">
<input type="text" class="inputReplyTo input-large"
@ -45,7 +45,7 @@
data-bind="value: replyTo, onEnter: addOrEditIdentityCommand, hasfocus: replyTo.focused" />
</div>
</div>
<div class="control-group" data-bind="css: {'error': bcc.hasError}" style="display: none">
<div class="control-group" data-bind="css: {'error': bcc.hasError}">
<label class="i18n control-label" data-i18n-text="POPUPS_IDENTITIES/LABEL_BCC"></label>
<div class="controls">
<input type="text" class="inputBcc input-large"
@ -56,7 +56,7 @@
</div>
</div>
<div class="modal-footer">
<a class="btn buttonAddAccount" data-bind="command: addOrEditIdentityCommand">
<a class="btn buttonAddIdentity" data-bind="command: addOrEditIdentityCommand">
<i data-bind="visible: !edit(), css: {'icon-user-add': !submitRequest(), 'icon-spinner animated': submitRequest()}"></i>
<i data-bind="visible: edit, css: {'icon-ok': !submitRequest(), 'icon-spinner animated': submitRequest()}"></i>
&nbsp;&nbsp;

View file

@ -96,6 +96,10 @@ pre {
<td class="tt i18n" data-i18n-text="MESSAGE/PRINT_LABEL_BCC"></td>
<td class="tv" data-bind="text: popupBcc"></td>
</tr>
<tr data-bind="visible: '' !== popupReplyTo">
<td class="tt i18n" data-i18n-text="MESSAGE/PRINT_LABEL_REPLY_TO"></td>
<td class="tv" data-bind="text: popupReplyTo"></td>
</tr>
<tr data-bind="visible: '' !== popupDate">
<td class="tt i18n" data-i18n-text="MESSAGE/PRINT_LABEL_DATE"></td>
<td class="tv" data-bind="text: popupDate"></td>

View file

@ -1,7 +1,7 @@
<div class="b-settings-accounts g-ui-user-select-none">
<div class="form-horizontal">
<div class="legend">
<span class="i18n" data-i18n-text="SETTINGS_ACCOUNTS/LEGEND_ACCOUNTS"></span>
<span class="i18n" data-i18n-text="SETTINGS_ACCOUNTS/LEGEND_ACCOUNTS_AND_IDENTITIES"></span>
</div>
</div>
<a class="btn" data-bind="click: addNewAccount">
@ -9,12 +9,18 @@
&nbsp;&nbsp;
<span class="i18n" data-i18n-text="SETTINGS_ACCOUNTS/BUTTON_ADD_ACCOUNT"></span>
</a>
&nbsp;&nbsp;
<a class="btn" data-bind="click: addNewIdentity">
<i class="icon-user-add"></i>
&nbsp;&nbsp;
<span class="i18n" data-i18n-text="SETTINGS_ACCOUNTS/BUTTON_ADD_IDENTITY"></span>
</a>
<div class="process-place" data-bind="style: {'visibility': visibility }">
<i class="icon-spinner animated"></i>
&nbsp;&nbsp;
<span data-bind="text: processText"></span>
</div>
<table class="table table-hover list-table" data-bind="i18nUpdate: accounts">
<table class="table table-hover list-table accounts-list" data-bind="i18nUpdate: accounts">
<colgroup>
<col />
<col style="width: 150px" />
@ -29,13 +35,42 @@
<span class="account-name" data-bind="text: email"></span>
</td>
<td>
<span data-bind="visible: !canBeDalete()"></span>
<a class="btn btn-small btn-small-small btn-danger pull-right button-delete button-delete-transitions" data-bind="visible: canBeDalete, css: {'delete-access': deleteAccess}, click: function(oAccount) { $root.deleteAccount(oAccount); }">
<span data-bind="visible: !canBeDeleted()"></span>
<a class="btn btn-small btn-small-small btn-danger pull-right button-delete button-delete-transitions" data-bind="visible: canBeDeleted, css: {'delete-access': deleteAccess}, click: function(oAccount) { $root.deleteAccount(oAccount); }">
<span class="i18n" data-i18n-text="SETTINGS_ACCOUNTS/DELETING_ASK"></span>
</a>
</td>
<td>
<span class="delete-account" data-bind="visible: !deleteAccess() && canBeDalete(), click: function (oAccount) { $root.accountForDeletion(oAccount); }">
<span class="delete-account" data-bind="visible: !deleteAccess() && canBeDeleted(), click: function (oAccount) { $root.accountForDeletion(oAccount); }">
<i class="icon-trash"></i>
</span>
</td>
</tr>
</tbody>
</table>
<br />
<br />
<table class="table table-hover list-table identities-list" data-bind="i18nUpdate: identities">
<colgroup>
<col />
<col style="width: 150px" />
<col style="width: 1%" />
</colgroup>
<tbody data-bind="foreach: identities">
<tr class="identity-item">
<td class="e-action">
<span class="identity-img icon-user"></span>
&nbsp;&nbsp;
<span class="identity-name" data-bind="text: formattedName()"></span>
</td>
<td>
<span data-bind="visible: !canBeDeleted()"></span>
<a class="btn btn-small btn-small-small btn-danger pull-right button-delete button-delete-transitions" data-bind="visible: canBeDeleted, css: {'delete-access': deleteAccess}, click: function(oIdentity) { $root.deleteIdentity(oIdentity); }">
<span class="i18n" data-i18n-text="SETTINGS_ACCOUNTS/DELETING_ASK"></span>
</a>
</td>
<td>
<span class="delete-identity" data-bind="visible: !deleteAccess() && canBeDeleted(), click: function (oIdentity) { $root.identityForDeletion(oIdentity); }">
<i class="icon-trash"></i>
</span>
</td>

View file

@ -93,7 +93,7 @@
</a>
</td>
<td>
<span class="delete-filter" data-bind="visible: !deleteAccess() && canBeDalete(), click: function (oFilter) { $root.filterForDeletion(oFilter); }">
<span class="delete-filter" data-bind="visible: !deleteAccess() && canBeDeleted(), click: function (oFilter) { $root.filterForDeletion(oFilter); }">
<i class="icon-trash"></i>
</span>
</td>

View file

@ -1,107 +0,0 @@
<div class="b-settings-identities">
<div class="form-horizontal">
<div class="legend g-ui-user-select-none">
<span class="i18n" data-i18n-text="SETTINGS_IDENTITIES/LEGEND_IDENTITY"></span>
</div>
<div class="control-group g-ui-user-select-none" data-bind="if: 0 < identities().length">
<label class="control-label" data-bind="i18nUpdate: identities">
<span class="i18n" data-i18n-text="SETTINGS_IDENTITIES/LABEL_DEFAULT"></span>
</label>
<div class="controls">
<div data-bind="component: {
name: 'Select',
params: {
options: identitiesOptions,
value: defaultIdentityID,
optionsText: 'name',
optionsValue: 'id',
trigger: defaultIdentityIDTrigger
}
}"></div>
</div>
</div>
<div class="control-group g-ui-user-select-none">
<label class="control-label">
<span class="i18n" data-i18n-text="SETTINGS_IDENTITIES/LABEL_DISPLAY_NAME"></span>
</label>
<div class="controls">
<div data-bind="component: {
name: 'Input',
params: {
value: displayName,
size: 4,
trigger: displayNameTrigger
}
}"></div>
</div>
</div>
<!-- <div class="control-group g-ui-user-select-none" style="display: none">
<label class="control-label">
<span class="i18n" data-i18n-text="SETTINGS_IDENTITIES/LABEL_REPLY_TO"></span>
</label>
<div class="controls">
<div data-bind="component: {
name: 'Input',
params: {
value: replyTo,
size: 4
}
}"></div>
</div>
</div>-->
<div class="control-group">
<label class="control-label g-ui-user-select-none">
<span class="i18n" data-i18n-text="SETTINGS_IDENTITIES/LABEL_SIGNATURE"></span>
</label>
<div class="controls">
<div class="e-signature-place" data-bind="initDom: signatureDom"></div>
&nbsp;&nbsp;
<div data-bind="component: {
name: 'SaveTrigger',
params: { value: signatureTrigger, verticalAlign: 'top' }
}"></div>
</div>
</div>
</div>
<br />
<div class="form-horizontal g-ui-user-select-none">
<div class="legend">
<span class="i18n" data-i18n-text="SETTINGS_IDENTITIES/LEGEND_IDENTITIES"></span>
</div>
</div>
<a class="btn g-ui-user-select-none" data-bind="click: addNewIdentity">
<i class="icon-user-add"></i>
&nbsp;&nbsp;
<span class="i18n" data-i18n-text="SETTINGS_IDENTITIES/BUTTON_ADD_IDENTITY"></span>
</a>
<div class="process-place g-ui-user-select-none" data-bind="style: {'visibility': visibility }">
<i class="icon-spinner animated"></i>
&nbsp;&nbsp;
<span data-bind="text: processText"></span>
</div>
<table class="table table-hover list-table g-ui-user-select-none" data-bind="i18nUpdate: identities">
<colgroup>
<col />
<col style="width: 140px" />
<col style="width: 1%" />
</colgroup>
<tbody data-bind="foreach: identities">
<tr class="identity-item">
<td class="e-action">
<span class="identity-img icon-user"></span>
<span class="identity-name" data-bind="text: formattedName()"></span>
</td>
<td>
<a class="btn btn-small btn-small-small btn-danger pull-right button-delete button-delete-transitions" data-bind="css: {'delete-access': deleteAccess()}, click: function(oIdentity) { $root.deleteIdentity(oIdentity); }">
<span class="i18n" data-i18n-text="SETTINGS_IDENTITIES/DELETING_ASK"></span>
</a>
</td>
<td>
<span class="delete-identity" data-bind="visible: !deleteAccess() && canBeDalete(), click: function (oIdentity) { $root.identityForDeletion(oIdentity); }">
<i class="icon-trash"></i>
</span>
</td>
</tr>
</tbody>
</table>
</div>

View file

@ -1,49 +0,0 @@
<div class="b-settings-identity">
<div class="form-horizontal">
<div class="legend g-ui-user-select-none">
<span class="i18n" data-i18n-text="SETTINGS_IDENTITY/LEGEND_IDENTITY"></span>
</div>
<div class="control-group g-ui-user-select-none">
<label class="control-label">
<span class="i18n" data-i18n-text="SETTINGS_IDENTITY/LABEL_DISPLAY_NAME"></span>
</label>
<div class="controls">
<div data-bind="component: {
name: 'Input',
params: {
value: displayName,
size: 4,
trigger: displayNameTrigger
}
}"></div>
</div>
</div>
<!-- <div class="control-group g-ui-user-select-none" style="display: none">
<label class="control-label">
<span class="i18n" data-i18n-text="SETTINGS_IDENTITY/LABEL_REPLY_TO"></span>
</label>
<div class="controls">
<div data-bind="component: {
name: 'Input',
params: {
value: replyTo,
size: 4
}
}"></div>
</div>
</div>-->
<div class="control-group">
<label class="control-label g-ui-user-select-none">
<span class="i18n" data-i18n-text="SETTINGS_IDENTITY/LABEL_SIGNATURE"></span>
</label>
<div class="controls">
<div class="e-signature-place" data-bind="initDom: signatureDom"></div>
&nbsp;&nbsp;
<div data-bind="component: {
name: 'SaveTrigger',
params: { value: signatureTrigger, verticalAlign: 'top' }
}"></div>
</div>
</div>
</div>
</div>

View file

@ -131,10 +131,12 @@ LABEL_TO = "To"
LABEL_TO_SHORT = "to"
LABEL_CC = "CC"
LABEL_BCC = "BCC"
LABEL_REPLY_TO = "Reply-To"
PRINT_LABEL_FROM = "From"
PRINT_LABEL_TO = "To"
PRINT_LABEL_CC = "CC"
PRINT_LABEL_BCC = "BCC"
PRINT_LABEL_REPLY_TO = "Reply-To"
PRINT_LABEL_DATE = "Date"
PRINT_LABEL_SUBJECT = "Subject"
PRINT_LABEL_ATTACHMENTS = "Attachments"
@ -201,7 +203,7 @@ TITLE_FROM = "From"
TITLE_TO = "To"
TITLE_CC = "CC"
TITLE_BCC = "BCC"
TITLE_REPLY_TO = "Reply To"
TITLE_REPLY_TO = "Reply-To"
TITLE_SUBJECT = "Subject"
LINK_SHOW_INPUTS = "show all fields"
BUTTON_SEND = "Send"
@ -254,7 +256,9 @@ BUTTON_ADD_IDENTITY = "Add"
BUTTON_UPDATE_IDENTITY = "Update"
LABEL_EMAIL = "Email"
LABEL_NAME = "Name"
LABEL_REPLY_TO = "Reply To"
LABEL_REPLY_TO = "Reply-To"
LABEL_SIGNATURE = "Signature"
LABEL_CC = "Cc"
LABEL_BCC = "Bcc"
[POPUPS_CREATE_FOLDER]
@ -527,9 +531,11 @@ TO_MANY_FOLDERS_DESC_2 = "We have shown only a part of them, to avoid performanc
[SETTINGS_ACCOUNTS]
LEGEND_ACCOUNTS = "Account List"
BUTTON_ADD_ACCOUNT = "Add Account"
LEGEND_ACCOUNTS_AND_IDENTITIES = "Accounts and Identities"
BUTTON_ADD_ACCOUNT = "Add an Account"
BUTTON_ADD_IDENTITY= "Add an Identity"
BUTTON_DELETE = "Delete"
LOADING_PROCESS = "Updating account list"
LOADING_PROCESS = "Updating..."
DELETING_ASK = "Are you sure?"
[SETTINGS_IDENTITIES]