Index: branches/5.2.x/core/units/email_events/email_events_event_handler.php =================================================================== diff -u -N -r15465 -r15542 --- branches/5.2.x/core/units/email_events/email_events_event_handler.php (.../email_events_event_handler.php) (revision 15465) +++ branches/5.2.x/core/units/email_events/email_events_event_handler.php (.../email_events_event_handler.php) (revision 15542) @@ -1,6 +1,6 @@ Array ('self' => 'debug'), 'OnMassApprove' => Array ('self' => 'debug'), 'OnMassDecline' => Array ('self' => 'debug'), + 'OnSend' => Array ('self' => 'debug'), ); $this->permMapping = array_merge($this->permMapping, $permissions); @@ -193,10 +194,8 @@ $items_info = $this->Application->GetVar('u'); if ( $items_info ) { - $user_id = array_shift(array_keys($items_info)); + list ($user_id, ) = each($items_info); - $selected_ids = $this->getSelectedIDs($event, true); - $ids = $this->Application->RecallVar($event->getPrefixSpecial() . '_selected_ids'); $id_field = $this->Application->getUnitOption($event->Prefix, 'IDField'); $table_name = $this->Application->getUnitOption($event->Prefix, 'TableName'); @@ -726,4 +725,32 @@ $temp_handler->DeleteItems('system-event-subscription', '', $ids); } + + /** + * Sends selected e-mail event + * + * @param kEvent $event + * @return void + * @access protected + */ + protected function OnSend(kEvent $event) + { + $object = $event->getObject(Array ('skip_autoload' => true)); + /* @var $object kDBItem */ + + $ids = $this->StoreSelectedIDs($event); + + foreach ($ids as $id) { + $object->Load($id); + + if ( $object->GetDBField('Type') == EmailEvent::EVENT_TYPE_ADMIN ) { + $this->Application->EmailEventAdmin($object->GetDBField('Event')); + } + else { + $this->Application->EmailEventUser($object->GetDBField('Event')); + } + } + + $this->clearSelectedIDs($event); + } } \ No newline at end of file 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 Index: branches/5.2.x/core/admin_templates/languages/email_message_list.tpl =================================================================== diff -u -N -r15116 -r15542 --- branches/5.2.x/core/admin_templates/languages/email_message_list.tpl (.../email_message_list.tpl) (revision 15116) +++ branches/5.2.x/core/admin_templates/languages/email_message_list.tpl (.../email_message_list.tpl) (revision 15542) @@ -50,6 +50,12 @@ open_popup('emailevents', 'OnExportEmailEvents', 'regional/languages_export'); + + + submit_event('emailevents', 'OnSend'); + + + a_toolbar.AddButton( new ToolBarSeparator('sep2') ); @@ -82,6 +88,6 @@ \ No newline at end of file Index: branches/5.2.x/core/units/email_events/email_events_config.php =================================================================== diff -u -N -r15252 -r15542 --- branches/5.2.x/core/units/email_events/email_events_config.php (.../email_events_config.php) (revision 15252) +++ branches/5.2.x/core/units/email_events/email_events_config.php (.../email_events_config.php) (revision 15542) @@ -1,6 +1,6 @@ Array ( 'prefixes' => Array ('emailevents_List'), 'format' => "!la_title_EmailMessages!", - 'toolbar_buttons' => Array ('new_item', 'edit', 'delete', 'approve', 'decline', 'frontend_mail', 'export', 'view', 'dbl-click'), + 'toolbar_buttons' => Array ('new_item', 'edit', 'delete', 'approve', 'decline', 'frontend_mail', 'export', 'process', 'view', 'dbl-click'), ), 'email_message_edit' => Array (