Index: branches/5.2.x/core/kernel/utility/email.php =================================================================== diff -u -N -r15383 -r15542 --- branches/5.2.x/core/kernel/utility/email.php (.../email.php) (revision 15383) +++ branches/5.2.x/core/kernel/utility/email.php (.../email.php) (revision 15542) @@ -1,6 +1,6 @@ emailEvent = $this->Application->recallObject('emailevents', null, Array ('skip_autoload' => true)); + // use "-item" special prevent error, when e-mail sent out from e-mail events list + $this->emailEvent = $this->Application->recallObject('emailevents.-item', null, Array ('skip_autoload' => true)); if ( !$this->emailEvent->isLoaded() || !$this->_sameEvent($name, $type) ) { // get event parameters by name & type @@ -744,7 +745,7 @@ $design_templates[$design_key] = $design_template; } - return $this->_parseText(str_replace('$body', $text, $design_templates[$design_key])); + return $this->_parseText(str_replace('$body', $text, $design_templates[$design_key]), $is_html); } /** @@ -768,7 +769,7 @@ } if ( isset($this->params['use_custom_design']) && $this->params['use_custom_design'] ) { - $message_body = $this->_parseText($message_body); + $message_body = $this->_parseText($message_body, $is_html); } else { $message_body = $this->_applyMessageDesign($message_body, $is_html); @@ -781,10 +782,11 @@ * Parse message template and return headers (as array) and message body part * * @param string $text + * @param bool $is_html * @return string * @access protected */ - protected function _parseText($text) + protected function _parseText($text, $is_html = true) { $text = $this->_substituteReplacementTags($text); @@ -796,15 +798,15 @@ $this->Application->InitParser(); $parser_params = $this->Application->Parser->Params; // backup parser params - $this->Application->Parser->SetParams( array_merge($parser_params, $this->params) ); + $this->Application->Parser->SetParams($this->params); - $text = $this->Application->Parser->Parse($text, 'email_template'); + $text = $this->Application->Parser->Parse($this->_normalizeLineEndings($text), 'email_template'); $this->Application->Parser->SetParams($parser_params); // restore parser params $category_helper = $this->Application->recallObject('CategoryHelper'); /* @var $category_helper CategoryHelper */ - return $category_helper->replacePageIds($this->_normalizeLineEndings($text)); + return $category_helper->replacePageIds($is_html ? $this->_removeTrailingLineEndings($text) : $text); } /** @@ -834,18 +836,26 @@ } /** - * Normalizes line endings in given text + * Convert Unix/Windows/Mac line ending into Unix line endings * * @param string $text * @return string * @access protected */ protected function _normalizeLineEndings($text) { - // remove trailing line endings - $text = preg_replace('/(\n|\r)+/', "\\1", $text); - - // convert Unix/Windows/Mac line ending into Unix line endings return str_replace(Array ("\r\n", "\r"), "\n", $text); } + + /** + * Remove trailing line endings + * + * @param $text + * @return string + * @access protected + */ + protected function _removeTrailingLineEndings($text) + { + return preg_replace('/(\n|\r)+/', "\\1", $text); + } } \ No newline at end of file