Small refactoring: Identity

This commit is contained in:
RainLoop Team 2015-10-29 23:47:23 +03:00
parent e3b62d24d8
commit 2ab17f8eff
3 changed files with 6 additions and 6 deletions

View file

@ -19,7 +19,7 @@
{ {
AbstractModel.call(this, 'IdentityModel'); AbstractModel.call(this, 'IdentityModel');
this.id = ko.observable(sId); this.id = ko.observable(sId || '');
this.email = ko.observable(sEmail); this.email = ko.observable(sEmail);
this.name = ko.observable(''); this.name = ko.observable('');

View file

@ -170,7 +170,7 @@
{ {
this.edit(true); this.edit(true);
this.id = oIdentity.id(); this.id = oIdentity.id() || '';
this.name(oIdentity.name()); this.name(oIdentity.name());
this.email(oIdentity.email()); this.email(oIdentity.email());
this.replyTo(oIdentity.replyTo()); this.replyTo(oIdentity.replyTo());

View file

@ -47,8 +47,8 @@ class Identity
*/ */
protected function __construct($sId = '', $sEmail = '') protected function __construct($sId = '', $sEmail = '')
{ {
$this->sId = $sId; $this->sId = empty($sId) ? '' : $sId;
$this->sEmail = $sEmail; $this->sEmail = empty($sEmail) ? '' : $sEmail;
$this->sName = ''; $this->sName = '';
$this->sReplyTo = ''; $this->sReplyTo = '';
$this->sBcc = ''; $this->sBcc = '';
@ -152,9 +152,9 @@ class Identity
*/ */
public function FromJSON($aData, $bAjax = false) public function FromJSON($aData, $bAjax = false)
{ {
if (isset($aData['Id'], $aData['Email']) && !empty($aData['Email'])) if (!empty($aData['Email']))
{ {
$this->sId = $aData['Id']; $this->sId = !empty($aData['Id']) ? $aData['Id'] : '';
$this->sEmail = $bAjax ? \MailSo\Base\Utils::IdnToAscii($aData['Email'], true) : $aData['Email']; $this->sEmail = $bAjax ? \MailSo\Base\Utils::IdnToAscii($aData['Email'], true) : $aData['Email'];
$this->sName = isset($aData['Name']) ? $aData['Name'] : ''; $this->sName = isset($aData['Name']) ? $aData['Name'] : '';
$this->sReplyTo = !empty($aData['ReplyTo']) ? $aData['ReplyTo'] : ''; $this->sReplyTo = !empty($aData['ReplyTo']) ? $aData['ReplyTo'] : '';