Changeset View
Changeset View
Standalone View
Standalone View
core/kernel/utility/email.php
Show First 20 Lines • Show All 363 Lines • ▼ Show 20 Line(s) | |||||
WHERE Username = ' . $this->Conn->qstr($address); | WHERE Username = ' . $this->Conn->qstr($address); | ||||
$user_info = $this->Conn->GetRow($sql); | $user_info = $this->Conn->GetRow($sql); | ||||
if ( $user_info ) { | if ( $user_info ) { | ||||
// user still exists | // user still exists | ||||
$this->fromEmail = $user_info['Email']; | $this->fromEmail = $user_info['Email']; | ||||
$this->fromName = trim($user_info['FirstName'] . ' ' . $user_info['LastName']); | $this->fromName = trim($user_info['FirstName'] . ' ' . $user_info['LastName']); | ||||
/** @var UsersItem $user */ | |||||
$user = $this->Application->recallObject( | $user = $this->Application->recallObject( | ||||
'u.email-from', | 'u.email-from', | ||||
null, | null, | ||||
array('live_table' => true, 'skip_autoload' => true) | array('live_table' => true, 'skip_autoload' => true) | ||||
); | ); | ||||
/* @var $user UsersItem */ | |||||
$user->Load($user_info['PortalUserId']); | $user->Load($user_info['PortalUserId']); | ||||
} | } | ||||
break; | break; | ||||
} | } | ||||
if ( $this->emailTemplate->GetDBField('SenderName') ) { | if ( $this->emailTemplate->GetDBField('SenderName') ) { | ||||
$this->fromName = $this->emailTemplate->GetDBField('SenderName'); | $this->fromName = $this->emailTemplate->GetDBField('SenderName'); | ||||
▲ Show 20 Lines • Show All 82 Lines • ▼ Show 20 Line(s) | |||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function _addRecipientsFromXml($xml) | protected function _addRecipientsFromXml($xml) | ||||
{ | { | ||||
if ( !$xml ) { | if ( !$xml ) { | ||||
return false; | return false; | ||||
} | } | ||||
/** @var MInputHelper $minput_helper */ | |||||
$minput_helper = $this->Application->recallObject('MInputHelper'); | $minput_helper = $this->Application->recallObject('MInputHelper'); | ||||
/* @var $minput_helper MInputHelper */ | |||||
// group recipients by type | // group recipients by type | ||||
$records = $minput_helper->parseMInputXML($xml); | $records = $minput_helper->parseMInputXML($xml); | ||||
foreach ($records as $record) { | foreach ($records as $record) { | ||||
$this->recipients[$record['RecipientType']][] = $record; | $this->recipients[$record['RecipientType']][] = $record; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Line(s) | |||||
); | ); | ||||
if ( $user_info['Language'] && !isset($this->params['language_id']) ) { | if ( $user_info['Language'] && !isset($this->params['language_id']) ) { | ||||
$this->params['language_id'] = $user_info['Language']; | $this->params['language_id'] = $user_info['Language']; | ||||
} | } | ||||
array_unshift($this->recipients[EmailTemplate::RECIPIENT_TYPE_TO], $add_recipient); | array_unshift($this->recipients[EmailTemplate::RECIPIENT_TYPE_TO], $add_recipient); | ||||
/** @var UsersItem $user */ | |||||
$user = $this->Application->recallObject( | $user = $this->Application->recallObject( | ||||
'u.email-to', | 'u.email-to', | ||||
null, | null, | ||||
array('live_table' => true, 'skip_autoload' => true) | array('live_table' => true, 'skip_autoload' => true) | ||||
); | ); | ||||
/* @var $user UsersItem */ | |||||
$user->Load($this->recipientUserId); | $user->Load($this->recipientUserId); | ||||
} | } | ||||
/** | /** | ||||
* Update with custom data given during event execution (email + name) | * Update with custom data given during event execution (email + name) | ||||
* | * | ||||
* @return void | * @return void | ||||
▲ Show 20 Lines • Show All 162 Lines • ▼ Show 20 Line(s) | |||||
// ensure that language is set | // ensure that language is set | ||||
if ( !isset($this->params['language_id']) ) { | if ( !isset($this->params['language_id']) ) { | ||||
$this->params['language_id'] = $this->Application->GetVar('m_lang'); | $this->params['language_id'] = $this->Application->GetVar('m_lang'); | ||||
} | } | ||||
$language_id = $restore ? $prev_language_id : $this->params['language_id']; | $language_id = $restore ? $prev_language_id : $this->params['language_id']; | ||||
$this->Application->SetVar('m_lang', $language_id); | $this->Application->SetVar('m_lang', $language_id); | ||||
/** @var LanguagesItem $language */ | |||||
$language = $this->Application->recallObject('lang.current'); | $language = $this->Application->recallObject('lang.current'); | ||||
/* @var $language LanguagesItem */ | |||||
$language->Load($language_id); | $language->Load($language_id); | ||||
$this->Application->Phrases->LanguageId = $language_id; | $this->Application->Phrases->LanguageId = $language_id; | ||||
$this->Application->Phrases->Phrases = Array (); | $this->Application->Phrases->Phrases = Array (); | ||||
} | } | ||||
/** | /** | ||||
Show All 34 Lines | |||||
*/ | */ | ||||
protected function _applyMessageDesign($text, $is_html = true) | protected function _applyMessageDesign($text, $is_html = true) | ||||
{ | { | ||||
static $design_templates = Array(); | static $design_templates = Array(); | ||||
$design_key = 'L' . $this->params['language_id'] . ':' . ($is_html ? 'html' : 'text'); | $design_key = 'L' . $this->params['language_id'] . ':' . ($is_html ? 'html' : 'text'); | ||||
if ( !isset($design_templates[$design_key]) ) { | if ( !isset($design_templates[$design_key]) ) { | ||||
/** @var LanguagesItem $language */ | |||||
$language = $this->Application->recallObject('lang.current'); | $language = $this->Application->recallObject('lang.current'); | ||||
/* @var $language LanguagesItem */ | |||||
$design_template = $language->GetDBField($is_html ? 'HtmlEmailTemplate' : 'TextEmailTemplate'); | $design_template = $language->GetDBField($is_html ? 'HtmlEmailTemplate' : 'TextEmailTemplate'); | ||||
if ( !$is_html && !$design_template ) { | if ( !$is_html && !$design_template ) { | ||||
$design_template = $this->sender->ConvertToText($language->GetDBField('HtmlEmailTemplate'), true); | $design_template = $this->sender->ConvertToText($language->GetDBField('HtmlEmailTemplate'), true); | ||||
} | } | ||||
$design_templates[$design_key] = $design_template; | $design_templates[$design_key] = $design_template; | ||||
▲ Show 20 Lines • Show All 53 Lines • ▼ Show 20 Line(s) | |||||
$parser_params = $this->Application->Parser->Params; // backup parser params | $parser_params = $this->Application->Parser->Params; // backup parser params | ||||
$this->Application->Parser->SetParams($this->params); | $this->Application->Parser->SetParams($this->params); | ||||
$template_name = 'et_' . $this->emailTemplate->GetID() . '_' . crc32($text); | $template_name = 'et_' . $this->emailTemplate->GetID() . '_' . crc32($text); | ||||
$text = $this->Application->Parser->Parse($this->_normalizeLineEndings($text), $template_name); | $text = $this->Application->Parser->Parse($this->_normalizeLineEndings($text), $template_name); | ||||
$this->Application->Parser->SetParams($parser_params); // restore parser params | $this->Application->Parser->SetParams($parser_params); // restore parser params | ||||
/** @var CategoryHelper $category_helper */ | |||||
$category_helper = $this->Application->recallObject('CategoryHelper'); | $category_helper = $this->Application->recallObject('CategoryHelper'); | ||||
/* @var $category_helper CategoryHelper */ | |||||
return $category_helper->replacePageIds($is_html ? $this->_removeTrailingLineEndings($text) : $text); | return $category_helper->replacePageIds($is_html ? $this->_removeTrailingLineEndings($text) : $text); | ||||
} | } | ||||
/** | /** | ||||
* Substitutes replacement tags in given text | * Substitutes replacement tags in given text | ||||
* | * | ||||
* @param string $text | * @param string $text | ||||
▲ Show 20 Lines • Show All 46 Lines • Show Last 20 Lines |