Index: branches/5.3.x/core/units/email_events/email_events_event_handler.php =================================================================== diff -u -N -r15483 -r15584 --- branches/5.3.x/core/units/email_events/email_events_event_handler.php (.../email_events_event_handler.php) (revision 15483) +++ branches/5.3.x/core/units/email_events/email_events_event_handler.php (.../email_events_event_handler.php) (revision 15584) @@ -1,6 +1,6 @@ Application->getUnitOption($event->Prefix, 'Fields'); + $fields['Module']['options'] = $this->_getModules(); - foreach ($this->Application->ModuleInfo as $module_name => $module_info) { - if ( $module_name == 'In-Portal' ) { - continue; - } - - $options[$module_name] = $module_name; + if ( $this->Application->findModule('Name', 'Custom') ) { + $fields['Module']['default'] = 'Custom'; } - $fields = $this->Application->getUnitOption($event->Prefix, 'Fields'); - $fields['Module']['options'] = $options; $this->Application->setUnitOption($event->Prefix, 'Fields', $fields); + $ml_helper = $this->Application->recallObject('kMultiLanguageHelper'); + /* @var $ml_helper kMultiLanguageHelper */ + + $ml_helper->replaceMLCalculatedFields($event); + if ( $this->Application->GetVar('regional') ) { $this->Application->setUnitOption($event->Prefix, 'PopulateMlFields', true); } } /** + * Returns modules, where e-mail event can be added to + * + * @return Array + * @access protected + */ + protected function _getModules() + { + $ret = Array (); + + foreach ($this->Application->ModuleInfo as $module_name => $module_info) { + if ( $module_name == 'In-Portal' ) { + continue; + } + + $ret[$module_name] = $module_name; + } + + return $ret; + } + + /** * Prepare temp tables and populate it * with items selected in the grid * @@ -371,6 +392,16 @@ $object->SetDBField('ReplacementTagsXML', $xml); $this->setRequired($event); + + $ml_helper = $this->Application->recallObject('kMultiLanguageHelper'); + /* @var $ml_helper kMultiLanguageHelper */ + + $translation_fields = $this->getTranslationFields(); + $source_language = $ml_helper->getSourceLanguage($object->GetDBField('TranslateFromLanguage')); + + foreach ($translation_fields as $translation_field) { + $object->SetDBField('Source' . $translation_field, $object->GetDBField('l' . $source_language . '_' . $translation_field)); + } } /** @@ -454,8 +485,8 @@ */ function translationChanged($object) { + $translation_fields = $this->getTranslationFields(); $changed_fields = array_keys($object->GetChangedFields()); - $translation_fields = Array ('Subject', 'HtmlBody', 'PlainTextBody'); foreach ($changed_fields as $changed_field) { $changed_field = preg_replace('/^l[\d]+_/', '', $changed_field); @@ -469,6 +500,17 @@ } /** + * Returns fields, that can be translated + * + * @return Array + * @access protected + */ + protected function getTranslationFields() + { + return Array ('Subject', 'HtmlBody', 'PlainTextBody'); + } + + /** * Don't allow to enable/disable events in non-debug mode * * @param kEvent $event @@ -726,4 +768,21 @@ $temp_handler->DeleteItems('system-event-subscription', '', $ids); } + + /** + * Updates translation state for all saved phrases + * + * @param kEvent $event + * @return void + * @access protected + */ + protected function OnBeforeCopyToLive(kEvent $event) + { + parent::OnBeforeCopyToLive($event); + + $ml_helper = $this->Application->recallObject('kMultiLanguageHelper'); + /* @var $ml_helper kMultiLanguageHelper */ + + $ml_helper->updateTranslationState($event); + } } \ No newline at end of file