mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-01 05:29:20 +03:00
Identities refactoring and improvements (Reply-To and BCC)
This commit is contained in:
parent
3e01887f85
commit
493191375f
43 changed files with 578 additions and 1051 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue