Changeset View
Changeset View
Standalone View
Standalone View
branches/5.2.x/core/kernel/utility/email.php
Show First 20 Lines • Show All 403 Lines • ▼ Show 20 Line(s) | |||||
* | * | ||||
* @return void | * @return void | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function _processRecipients() | protected function _processRecipients() | ||||
{ | { | ||||
$this->_collectRecipients(); | $this->_collectRecipients(); | ||||
$header_mapping = Array ( | $header_mapping = $this->getHeaderMapping(); | ||||
EmailTemplate::RECIPIENT_TYPE_TO => 'To', | |||||
EmailTemplate::RECIPIENT_TYPE_CC => 'Cc', | |||||
EmailTemplate::RECIPIENT_TYPE_BCC => 'Bcc', | |||||
); | |||||
$default_email = $this->Application->ConfigValue('DefaultEmailSender'); | $default_email = $this->Application->ConfigValue('DefaultEmailSender'); | ||||
$this->recipients = array_map(Array ($this, '_transformRecipientsIntoPairs'), $this->recipients); | $this->recipients = array_map(Array ($this, '_transformRecipientsIntoPairs'), $this->recipients); | ||||
foreach ($this->recipients as $recipient_type => $recipients) { | foreach ($this->recipients as $recipient_type => $recipients) { | ||||
// add recipients to email | // add recipients to email | ||||
if ( !$recipients ) { | if ( !$recipients ) { | ||||
continue; | continue; | ||||
Show All 22 Lines | |||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function _collectRecipients() | protected function _collectRecipients() | ||||
{ | { | ||||
$this->_addRecipientsFromXml($this->emailTemplate->GetDBField('Recipients')); | $this->_addRecipientsFromXml($this->emailTemplate->GetDBField('Recipients')); | ||||
$this->_overwriteToRecipient(); | $this->_overwriteToRecipient(); | ||||
$this->_addRecipientByUserId(); | $this->_addRecipientByUserId(); | ||||
$this->_addRecipientFromParams(); | $this->_addRecipientFromParams(); | ||||
$this->_moveDirectRecipients(); | |||||
if ( ($this->emailTemplate->GetDBField('Type') == EmailTemplate::TEMPLATE_TYPE_ADMIN) && !$this->recipients[EmailTemplate::RECIPIENT_TYPE_TO] ) { | if ( ($this->emailTemplate->GetDBField('Type') == EmailTemplate::TEMPLATE_TYPE_ADMIN) && !$this->recipients[EmailTemplate::RECIPIENT_TYPE_TO] ) { | ||||
// admin email template without direct recipient -> send to admin | // admin email template without direct recipient -> send to admin | ||||
$this->_addDefaultRecipient(); | $this->_addDefaultRecipient(); | ||||
} | } | ||||
} | } | ||||
/** | /** | ||||
▲ Show 20 Lines • Show All 106 Lines • ▼ Show 20 Line(s) | |||||
} | } | ||||
if ( $add_recipient ) { | if ( $add_recipient ) { | ||||
array_unshift($this->recipients[EmailTemplate::RECIPIENT_TYPE_TO], $add_recipient); | array_unshift($this->recipients[EmailTemplate::RECIPIENT_TYPE_TO], $add_recipient); | ||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* Move recipients, that were added manually via "$this->sender->Add*" methods. | |||||
* | |||||
* @return void | |||||
* @access protected | |||||
*/ | |||||
protected function _moveDirectRecipients() | |||||
{ | |||||
foreach ( $this->getHeaderMapping() as $recipient_type => $header_name ) { | |||||
$manual_recipients = $this->sender->GetRecipientsByHeader($header_name); | |||||
if ( !$manual_recipients ) { | |||||
continue; | |||||
} | |||||
foreach ( $manual_recipients as $manual_recipient ) { | |||||
$this->recipients[$recipient_type][] = array( | |||||
'RecipientName' => $manual_recipient['Name'], | |||||
'RecipientAddressType' => EmailTemplate::ADDRESS_TYPE_EMAIL, | |||||
'RecipientAddress' => $manual_recipient['Email'], | |||||
); | |||||
} | |||||
$this->sender->SetHeader($header_name, ''); | |||||
} | |||||
} | |||||
/** | |||||
* Returns mapping between recipient type and header name. | |||||
* | |||||
* @return array | |||||
*/ | |||||
protected function getHeaderMapping() | |||||
{ | |||||
return array( | |||||
EmailTemplate::RECIPIENT_TYPE_TO => 'To', | |||||
EmailTemplate::RECIPIENT_TYPE_CC => 'Cc', | |||||
EmailTemplate::RECIPIENT_TYPE_BCC => 'Bcc', | |||||
); | |||||
} | |||||
/** | |||||
* This is default recipient, when we can't determine actual one | * This is default recipient, when we can't determine actual one | ||||
* | * | ||||
* @return void | * @return void | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function _addDefaultRecipient() | protected function _addDefaultRecipient() | ||||
{ | { | ||||
$xml = $this->Application->ConfigValue('DefaultEmailRecipients'); | $xml = $this->Application->ConfigValue('DefaultEmailRecipients'); | ||||
▲ Show 20 Lines • Show All 278 Lines • Show Last 20 Lines |