Index: branches/5.1.x/core/admin_templates/regional/email_messages_edit.tpl
===================================================================
diff -u -r12657 -r13140
--- branches/5.1.x/core/admin_templates/regional/email_messages_edit.tpl (.../email_messages_edit.tpl) (revision 12657)
+++ branches/5.1.x/core/admin_templates/regional/email_messages_edit.tpl (.../email_messages_edit.tpl) (revision 13140)
@@ -11,12 +11,12 @@
-
+
@@ -75,8 +91,8 @@
-
+
\ No newline at end of file
Index: branches/5.1.x/core/admin_templates/groups/groups_list.tpl
===================================================================
diff -u -r13086 -r13140
--- branches/5.1.x/core/admin_templates/groups/groups_list.tpl (.../groups_list.tpl) (revision 13086)
+++ branches/5.1.x/core/admin_templates/groups/groups_list.tpl (.../groups_list.tpl) (revision 13140)
@@ -30,15 +30,6 @@
a_toolbar.AddButton( new ToolBarSeparator('sep1') );
- /*
-
- a_toolbar.AddButton( new ToolBarButton('e-mail', '', function() {
- openSelector('emailmessages', '', 'UserEmail', null, 'OnPrepareMassRecipients');
- }
- ) );
-
- */
-
a_toolbar.AddButton(
new ToolBarButton(
Index: branches/5.1.x/core/install/install_schema.sql
===================================================================
diff -u -r13086 -r13140
--- branches/5.1.x/core/install/install_schema.sql (.../install_schema.sql) (revision 13086)
+++ branches/5.1.x/core/install/install_schema.sql (.../install_schema.sql) (revision 13140)
@@ -69,16 +69,6 @@
UNIQUE KEY VariableName (VariableName)
);
-CREATE TABLE EmailMessage (
- EmailMessageId int(10) NOT NULL auto_increment,
- Template longtext,
- MessageType enum('html','text') NOT NULL default 'text',
- LanguageId int(11) NOT NULL default '0',
- EventId int(11) NOT NULL default '0',
- `Subject` text,
- PRIMARY KEY (EmailMessageId)
-);
-
CREATE TABLE EmailQueue (
EmailQueueId int(10) unsigned NOT NULL AUTO_INCREMENT,
ToEmail varchar(255) NOT NULL DEFAULT '',
@@ -103,19 +93,35 @@
);
CREATE TABLE Events (
- EventId int(11) NOT NULL auto_increment,
- Event varchar(40) NOT NULL default '',
+ EventId int(11) NOT NULL AUTO_INCREMENT,
+ `Event` varchar(40) NOT NULL DEFAULT '',
ReplacementTags text,
- Enabled int(11) NOT NULL default '1',
- FrontEndOnly tinyint(3) unsigned NOT NULL default '0',
- FromUserId int(11) default NULL,
- Module varchar(40) NOT NULL default '',
- Description varchar(255) NOT NULL default '',
- `Type` int(11) NOT NULL default '0',
- PRIMARY KEY (EventId),
+ l1_Subject text,
+ l2_Subject text,
+ l3_Subject text,
+ l4_Subject text,
+ l5_Subject text,
+ l1_Body longtext,
+ l2_Body longtext,
+ l3_Body longtext,
+ l4_Body longtext,
+ l5_Body longtext,
+ Headers text,
+ MessageType varchar(4) NOT NULL DEFAULT 'text',
+ Enabled int(11) NOT NULL DEFAULT '1',
+ FrontEndOnly tinyint(3) unsigned NOT NULL DEFAULT '0',
+ FromUserId int(11) DEFAULT NULL,
+ Module varchar(40) NOT NULL DEFAULT '',
+ l1_Description text,
+ l2_Description text,
+ l3_Description text,
+ l4_Description text,
+ l5_Description text,
+ `Type` int(11) NOT NULL DEFAULT '0',
+ PRIMARY KEY (EventId),
KEY `Type` (`Type`),
KEY Enabled (Enabled),
- KEY Event (Event),
+ KEY `Event` (`Event`),
KEY FrontEndOnly (FrontEndOnly)
);
Index: branches/5.1.x/core/units/languages/languages_event_handler.php
===================================================================
diff -u -r13086 -r13140
--- branches/5.1.x/core/units/languages/languages_event_handler.php (.../languages_event_handler.php) (revision 13086)
+++ branches/5.1.x/core/units/languages/languages_event_handler.php (.../languages_event_handler.php) (revision 13140)
@@ -1,6 +1,6 @@
getObject();
- $from_lang_id = $object->GetDBField('CopyFromLanguage');
+ /* @var $object kDBItem */
- if( ($event->MasterEvent->status == erSUCCESS) && $object->GetDBField('CopyLabels') == 1 && ($from_lang_id > 0) )
- {
- $lang_id = $object->GetID();
+ $src_language = $object->GetDBField('CopyFromLanguage');
- // 1. phrases import
- $phrases_live = $this->Application->getUnitOption('phrases','TableName');
- $phrases_temp = $this->Application->GetTempName($phrases_live, 'prefix:phrases');
- $sql = 'INSERT INTO '.$phrases_temp.'
- SELECT Phrase, Translation, PhraseType, 0-PhraseId, '.$lang_id.', '.adodb_mktime().', "", Module
- FROM '.$phrases_live.'
- WHERE LanguageId='.$from_lang_id;
- $this->Conn->Query($sql);
+ if ($object->GetDBField('CopyLabels') && $src_language) {
+ $dst_language = $object->GetID();
- // 2. events import
- $em_table_live = $this->Application->getUnitOption('emailmessages','TableName');
- $em_table_temp = $this->Application->GetTempName($em_table_live, 'prefix:emailmessages');
+ // 1. schedule data copy after OnSave event is executed
+ $var_name = $event->getPrefixSpecial() . '_copy_data' . $this->Application->GetVar('m_wid');
+ $pending_actions = $this->Application->RecallVar($var_name, Array ());
- $sql = 'SELECT * FROM '.$em_table_live.' WHERE LanguageId = '.$from_lang_id;
- $email_messages = $this->Conn->Query($sql);
- if($email_messages)
- {
- $id = $this->Conn->GetOne('SELECT MIN(EmailMessageId) FROM '.$em_table_live);
- if($id > 0) $id = 0;
- $id--;
+ if ($pending_actions) {
+ $pending_actions = unserialize($pending_actions);
+ }
- $sqls = Array();
- foreach($email_messages as $email_message)
- {
- $sqls[] = $id.','.$this->Conn->qstr($email_message['Template']).','.$this->Conn->qstr($email_message['MessageType']).','.$lang_id.','.$email_message['EventId'];
- $id--;
- }
- $sql = 'INSERT INTO '.$em_table_temp.'(EmailMessageId,Template,MessageType,LanguageId,EventId) VALUES ('.implode('),(',$sqls).')';
+ $pending_actions[$src_language] = $dst_language;
+ $this->Application->StoreVar($var_name, serialize($pending_actions));
+
+ if ($object->IsTempTable()) {
+ // 2. phrases import
+ $phrases_live = $this->Application->getUnitOption('phrases','TableName');
+ $phrases_temp = $this->Application->GetTempName($phrases_live, 'prefix:phrases');
+
+ $sql = 'INSERT INTO ' . $phrases_temp . '(Phrase, PhraseKey, Translation, PhraseType, PhraseId, LanguageId, LastChanged, LastChangeIP, Module)
+ SELECT Phrase, PhraseKey, Translation, PhraseType, 0-PhraseId, ' . $dst_language . ', ' . adodb_mktime() . ', "", Module
+ FROM ' . $phrases_live . '
+ WHERE LanguageId = ' . $src_language;
$this->Conn->Query($sql);
}
@@ -218,6 +213,51 @@
}
/**
+ * Saves language from temp table to live
+ *
+ * @param kEvent $event
+ */
+ function OnSave(&$event)
+ {
+ parent::OnSave($event);
+
+ if ($event->status != erSUCCESS) {
+ return ;
+ }
+
+ $var_name = $event->getPrefixSpecial() . '_copy_data' . $this->Application->GetVar('m_wid');
+ $pending_actions = $this->Application->RecallVar($var_name, Array ());
+
+ if ($pending_actions) {
+ $pending_actions = unserialize($pending_actions);
+ }
+
+ // create multilingual columns for phrases & email events table first (actual for 6+ language)
+ $ml_helper =& $this->Application->recallObject('kMultiLanguageHelper');
+// $ml_helper->createFields('phrases');
+ $ml_helper->createFields('emailevents');
+
+ foreach ($pending_actions as $src_language => $dst_language) {
+ // phrases import
+ /*$sql = 'UPDATE ' . $this->Application->getUnitOption('phrases', 'TableName') . '
+ SET l' . $dst_language . '_Translation = l' . $src_language . '_Translation';
+ $this->Conn->Query($sql);*/
+
+ // events import
+ $sql = 'UPDATE ' . $this->Application->getUnitOption('emailevents', 'TableName') . '
+ SET
+ l' . $dst_language . '_Subject = l' . $src_language . '_Subject,
+ l' . $dst_language . '_Body = l' . $src_language . '_Body,
+ l' . $dst_language . '_Description = l' . $src_language . '_Description';
+ $this->Conn->Query($sql);
+ }
+
+ $this->Application->RemoveVar($var_name);
+
+ $event->CallSubEvent('OnReflectMultiLingualFields');
+ }
+
+ /**
* Prepare temp tables for creating new item
* but does not create it. Actual create is
* done in OnPreSaveCreated
@@ -425,6 +465,27 @@
}
/**
+ * Deletes phrases and email events on given language
+ *
+ * @param kEvent $event
+ */
+ function OnAfterItemDelete(&$event)
+ {
+ parent::OnAfterItemDelete($event);
+
+ $object =& $event->getObject();
+ /* @var $object kDBItem */
+
+ $fields_hash = Array (
+ 'l' . $object->GetID() . '_Subject' => NULL,
+ 'l' . $object->GetID() . '_Body' => NULL,
+ 'l' . $object->GetID() . '_Description' => NULL,
+ );
+
+ $this->Conn->doUpdate($fields_hash, $this->Application->getUnitOption('emailevents', 'TableName'), 1);
+ }
+
+ /**
* Copy missing phrases across all system languages (starting from primary)
*
* @param kEvent $event
Index: branches/5.1.x/core/units/email_events/email_events_config.php
===================================================================
diff -u -r13086 -r13140
--- branches/5.1.x/core/units/email_events/email_events_config.php (.../email_events_config.php) (revision 13086)
+++ branches/5.1.x/core/units/email_events/email_events_config.php (.../email_events_config.php) (revision 13140)
@@ -1,6 +1,6 @@
Array ('class' => 'kDBItem', 'file' => '', 'build_event' => 'OnItemBuild'),
'ListClass' => Array ('class' => 'kDBList', 'file' => '', 'build_event' => 'OnListBuild'),
'EventHandlerClass' => Array ('class' => 'EmailEventsEventsHandler', 'file' => 'email_events_event_handler.php', 'build_event' => 'OnBuild'),
- 'TagProcessorClass' => Array ('class' => 'kDBTagProcessor', 'file' => '', 'build_event' => 'OnBuild'),
+ 'TagProcessorClass' => Array ('class' => 'EmailEventTagProcessor', 'file' => 'email_event_tp.php', 'build_event' => 'OnBuild'),
'AutoLoad' => true,
@@ -36,24 +36,52 @@
'TitlePresets' => Array (
'default' => Array (
+ 'new_status_labels' => Array ('emailevents' => '!la_title_Adding_E-mail!'),
+ 'edit_status_labels' => Array ('emailevents' => '!la_title_Editing_E-mail!'),
'edit_status_labels' => Array ('emailevents' => '!la_title_EditingEmailEvent!'),
),
+ // for editing in Regional section
'email_settings_list' => Array ('prefixes' => Array ('emailevents.module_List'), 'format' => '!la_title_EmailSettings!'),
'email_settings_edit' => Array (
'prefixes' => Array ('emailevents'), 'format' => "#emailevents_status# '#emailevents_titlefield#'",
'toolbar_buttons' => Array ('select', 'cancel', 'reset_edit', 'prev', 'next'),
),
+ // for separate grid with email editing
+ 'email_messages_direct_list' => Array (
+ 'prefixes' => Array ('emailevents_List'), 'format' => "!la_title_EmailMessages!",
+ 'toolbar_buttons' => Array ('new_item', 'edit', 'delete', 'approve', 'decline', 'view', 'dbl-click'),
+ ),
+
+ 'email_messages_edit_direct' => Array (
+ 'prefixes' => Array ('emailevents'),
+ 'format' => '#emailevents_status# - #emailevents_titlefield#',
+ 'toolbar_buttons' => Array ('select', 'cancel', 'reset_edit'),
+ ),
+
+ // for mass mailing
'email_send_form' => Array ('prefixes' => Array (), 'format' => '!la_title_SendEmail!'),
'email_prepare' => Array ('prefixes' => Array (), 'format' => '!la_title_PreparingEmailsForSending!. !la_title_PleaseWait!'),
'email_send' => Array ('prefixes' => Array (), 'format' => '!la_title_SendingPreparedEmails!. !la_title_PleaseWait!'),
'email_send_complete' => Array ('prefixes' => Array (), 'format' => '!la_title_SendMailComplete!'),
),
- 'PermSection' => Array ('main' => 'in-portal:configure_lang'),
+ 'PermSection' => Array ('main' => 'in-portal:configemail'),
+ 'Sections' => Array (
+ 'in-portal:configemail' => Array (
+ 'parent' => 'in-portal:site',
+ 'icon' => 'email_templates',
+ 'label' => 'la_tab_E-mails',
+ 'url' => Array ('t' => 'languages/email_message_list', 'pass' => 'm'),
+ 'permissions' => Array ('view', 'add', 'edit', 'delete'),
+ 'priority' => 5,
+ 'type' => stTREE,
+ ),
+ ),
+
'FilterMenu' => Array (
'Groups' => Array (
Array ('mode' => 'AND', 'filters' => Array ('show_enabled', 'show_disabled', 'show_frontonly'), 'type' => WHERE_FILTER),
@@ -81,15 +109,42 @@
),
'ListSortings' => Array (
- '' => Array ('Sorting' => Array ('Module' => 'asc', 'Description' => 'asc')),
- 'module' => Array ('Sorting' => Array ('Description' => 'asc') ),
+ '' => Array (
+ 'ForcedSorting' => Array ('Enabled' => 'desc'),
+ 'Sorting' => Array ('Module' => 'asc', 'Description' => 'asc'),
+ ),
+ 'module' => Array (
+ 'ForcedSorting' => Array ('Enabled' => 'desc'),
+ 'Sorting' => Array ('Description' => 'asc')
+ ),
),
+ 'PopulateMlFields' => true,
+
'Fields' => Array (
'EventId' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0),
- 'Event' => Array ('type' => 'string', 'not_null' => 1, 'required' => 1, 'default' => ''),
+ 'Event' => Array ('type' => 'string', 'not_null' => 1, 'unique' => Array ('Type'), 'required' => 1, 'default' => ''),
+ 'Headers' => Array ('type' => 'string', 'default' => NULL),
'ReplacementTags' => Array ('type' => 'string', 'default' => NULL),
+ 'Subject' => Array (
+ 'type' => 'string',
+ 'formatter' => 'kMultiLanguage', 'db_type' => 'text',
+ 'required' => 1, 'default' => null
+ ),
+
+ 'Body' => Array (
+ 'type' => 'string',
+ 'formatter' => 'kMultiLanguage', 'db_type' => 'longtext',
+ 'required' => 1, 'default' => null
+ ),
+
+ 'MessageType' => Array (
+ 'type' => 'string',
+ 'formatter' => 'kOptionsFormatter', 'options' => Array ('text' => 'la_Text', 'html' => 'la_Html'), 'use_phrases' => 1,
+ 'not_null' => 1, 'required' => 1, 'default' => 'text'
+ ),
+
'Enabled' => Array (
'type' => 'int',
'formatter' => 'kOptionsFormatter', 'options' => Array (1 => 'la_Yes', 0 => 'la_No'), 'use_phrases' => 1,
@@ -108,12 +163,20 @@
'default' => NULL
),
- 'Module' => Array ('type' => 'string', 'not_null' => 1, 'required' => 1, 'default' => ''),
- 'Description' => Array ('type' => 'string', 'not_null' => 1, 'required' => 1, 'default' => ''),
+ 'Module' => Array (
+ 'type' => 'string',
+ 'formatter' => 'kOptionsFormatter', 'options' => Array (),
+ 'not_null' => 1, 'required' => 1, 'default' => ''
+ ),
+ 'Description' => Array (
+ 'type' => 'string',
+ 'formatter' => 'kMultiLanguage',
+ 'not_null' => 1, 'default' => '', 'db_type' => 'text',
+ ),
'Type' => Array (
'type' => 'int',
'formatter' => 'kOptionsFormatter', 'options' => Array (1 => 'la_Text_Admin', 0 => 'la_Text_User'), 'use_phrases' => 1,
- 'not_null' => 1, 'required' => 1, 'default' => 0
+ 'not_null' => 1, 'unique' => Array ('Event'), 'required' => 1, 'default' => 0
),
),
@@ -122,6 +185,7 @@
),
'Grids' => Array (
+ // used on "Email Events" tab in language editing in "Regional" section
'Default' => Array (
'Icons' => Array (
'default' => 'icon16_item.png',
@@ -130,14 +194,33 @@
),
'Fields' => Array (
'EventId' => Array ('title' => 'la_col_Id', 'filter_block' => 'grid_range_filter', 'width' => 70, ),
- 'Description' => Array ( 'title' => 'la_col_Description', 'data_block' => 'label_grid_checkbox_td', 'filter_block' => 'grid_like_filter', 'width' => 250, ),
+ 'Description' => Array ( 'title' => 'la_col_Description', 'filter_block' => 'grid_like_filter', 'width' => 250, ),
'Event' => Array ( 'title' => 'la_col_Event', 'filter_block' => 'grid_like_filter', 'width' => 250, ),
- 'Module' => Array ( 'title' => 'la_col_Module', 'filter_block' => 'grid_like_filter', 'width' => 100, ),
+ 'Module' => Array ( 'title' => 'la_col_Module', 'filter_block' => 'grid_options_filter', 'width' => 100, ),
'Type' => Array ( 'title' => 'la_col_Type', 'filter_block' => 'grid_options_filter', 'width' => 120, ),
'Enabled' => Array ( 'title' => 'la_col_Status', 'filter_block' => 'grid_options_filter', 'width' => 80, ),
),
),
+ // used on "Email Templates" section
+ 'Emails' => Array (
+ 'Icons' => Array (
+ 'default' => 'icon16_item.png',
+ 0 => 'icon16_disabled.png',
+ 1 => 'icon16_item.png',
+ ),
+ 'Fields' => Array (
+ 'EventId' => Array ( 'title' => 'la_col_Id', 'filter_block' => 'grid_range_filter', 'width' => 60, ),
+ 'Event' => Array ( 'title' => 'la_col_Event', 'filter_block' => 'grid_like_filter', 'width' => 250, ),
+ 'Subject' => Array ( 'title' => 'la_col_Subject', 'filter_block' => 'grid_like_filter', 'no_special' => 0, 'width' => 300, ),
+ 'Description' => Array ( 'title' => 'la_col_Description', 'filter_block' => 'grid_like_filter', 'width' => 250, ),
+ 'Type' => Array ( 'title' => 'la_col_Type', 'filter_block' => 'grid_options_filter', 'width' => 60, ),
+ 'Enabled' => Array ( 'title' => 'la_col_Enabled', 'filter_block' => 'grid_options_filter', 'width' => 70, ),
+ 'Module' => Array ( 'title' => 'la_col_Module', 'filter_block' => 'grid_options_filter', 'width' => 100, ),
+ ),
+ ),
+
+ // used on "E-Mail" section in each module
'EmailSettings' => Array (
'Icons' => Array (
'default' => 'icon16_item.png',
@@ -146,7 +229,7 @@
),
'Fields' => Array (
'EventId' => Array ('title' => 'la_col_Id', 'filter_block' => 'grid_range_filter', 'width' => 70, ),
- 'Description' => Array ('title' => 'la_col_EventDescription', 'data_block' => 'label_grid_checkbox_td', 'width' => 250, ),
+ 'Description' => Array ('title' => 'la_col_EventDescription', 'width' => 250, ),
'FromUser' => Array ('title' => 'la_col_FromToUser', 'data_block' => 'from_user_td', 'filter_block' => 'grid_like_filter', 'width' => 150, ),
'Type' => Array ('title' => 'la_col_RecipientType', 'filter_block' => 'grid_options_filter', 'width' => 120, ),
'FrontEndOnly' => Array ('title' => 'la_col_FrontEndOnly', 'filter_block' => 'grid_options_filter', 'width' => 120, ),
Fisheye: Tag 13140 refers to a dead (removed) revision in file `branches/5.1.x/core/admin_templates/emails/send_queue.tpl'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 13140 refers to a dead (removed) revision in file `branches/5.1.x/core/admin_templates/emails/send_complete.tpl'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 13140 refers to a dead (removed) revision in file `branches/5.1.x/core/admin_templates/emails/mass_mail.tpl'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 13140 refers to a dead (removed) revision in file `branches/5.1.x/core/admin_templates/emails/prepare_queue.tpl'.
Fisheye: No comparison available. Pass `N' to diff?
Index: branches/5.1.x/core/units/helpers/email_message_helper.php
===================================================================
diff -u -r12657 -r13140
--- branches/5.1.x/core/units/helpers/email_message_helper.php (.../email_message_helper.php) (revision 12657)
+++ branches/5.1.x/core/units/helpers/email_message_helper.php (.../email_message_helper.php) (revision 13140)
@@ -1,7 +1,7 @@
_removeTrailingCRLF($ret);
+ $ret .= 'Subject: ' . $fields_hash['Subject'] . "\n\n";
+ $ret .= $fields_hash['Body'];
+
+ return $ret;
+ }
+
+ /**
+ * Remove trailing CR/LF chars from string
+ *
+ * @param string $string
+ * @return string
+ */
+ function _removeTrailingCRLF($string)
+ {
+ return preg_replace('/(\n|\r)+/',"\\1",$string);
+ }
}
\ No newline at end of file
Index: branches/5.1.x/core/install/english.lang
===================================================================
diff -u -r13086 -r13140
--- branches/5.1.x/core/install/english.lang (.../english.lang) (revision 13086)
+++ branches/5.1.x/core/install/english.lang (.../english.lang) (revision 13140)
@@ -535,32 +535,6 @@
RmllbGQgaXMgcmVxdWlyZWQ=
RmllbGQgdmFsdWUgbXVzdCBiZSB1bmlxdWU=
RmllbGQgaXMgb3V0IG9mIHJhbmdlLCBwb3NzaWJsZSB2YWx1ZXMgZnJvbSAlcyB0byAlcw==
- QWRkIENhdGVnb3J5
- QWRkIFBlbmRpbmcgQ2F0ZWdvcnk=
- QXBwcm92ZSBDYXRlZ29yeQ==
- RGVueSBDYXRlZ29yeQ==
- Q29tbW9uIEZvb3RlciBUZW1wbGF0ZQ==
- VGhpcyBlLW1haWwgaXMgc2VudCB0byBhIHVzZXIgYWZ0ZXIgZmlsbGluZyBpbiB0aGUgQ29udGFjdCBVcyBmb3Jt
- QWRkIExpbms=
- QWRkIFBlbmRpbmcgTGluaw==
- QXBwcm92ZSBQZW5kaW5nIExpbms=
- RGVueSBMaW5r
- QXBwcm92ZSBMaW5rIE1vZGlmaWNhdGlvbg==
- RGVjbGluZSBsaW5rIG1vZGlmaWNhdGlvbg==
- TGluayBNb2RpZmljYXRpb24gUGVuZGluZw==
- TmV3IFByaXZhdGUgTWVzc2FnZQ==
- QWRkIFVzZXI=
- QWRkIFBlbmRpbmcgVXNlcg==
- QXBwcm92ZSBVc2Vy
- RGVueSBVc2Vy
- Rm9yZ290IFBhc3N3b3Jk
- TWVtYmVyc2hpcCBleHBpcmF0aW9uIG5vdGljZQ==
- TWVtYmVyc2hpcCBleHBpcmVk
- UGFzc3dvcmQgQ29uZmlybWF0aW9u
- VXNlciBzdWJzY3JpYmVk
- U3VnZ2VzdCB0byBhIGZyaWVuZA==
- VXNlciB1bnN1YnNjcmliZWQ=
- VmFsaWRhdGUgVXNlcg==
RXhwb3J0IGZvbGRlciBpcyBub3Qgd3JpdGFibGU=
RXJyb3IgY3JlYXRpbmcgZm9sZGVyLiBFcnJvciBudW1iZXI6
UGxlYXNlIG5hbWUgeW91ciBmaWxlcyB0byBiZSB3ZWItZnJpZW5kbHkuIFdlIHJlY29tbWVuZCB1c2luZyBvbmx5IHRoZXNlIGNoYXJhY3RlcnMgaW4gZmlsZSBuYW1lczogDQpMZXR0ZXJzIGEteiwgQS1aLCBOdW1iZXJzIDAtOSwgIl8iICh1bmRlcnNjb3JlKSwgIi0iIChkYXNoKSwgIiAiIChzcGFjZSksICIuIiAocGVyaW9kKQ0KUGxlYXNlIGF2b2lkIHVzaW5nIGFueSBvdGhlciBjaGFyYWN0ZXJzIGxpa2UgcXVvdGVzLCBicmFja2V0cywgcXVvdGF0aW9uIG1hcmtzLCAiPyIsICIhIiwgIj0iLCBmb3JlaWduIHN5bWJvbHMsIGV0Yy4=
@@ -1380,6 +1354,7 @@
QWRkaW5nIFNlY3Rpb24=
QWRkaW5nIFNlYXJjaCBGaWVsZA==
QWRkaW5nIENNUyBCbG9jaw==
+ QWRkaW5nIEVtYWlsIEV2ZW50
QWRkaW5nIEZvcm0=
QWRkaW5nIEZvcm0gRmllbGQ=
QWRkaW5nIEdyb3Vw
Index: branches/5.1.x/core/admin_templates/languages/email_message_edit.tpl
===================================================================
diff -u -r12657 -r13140
--- branches/5.1.x/core/admin_templates/languages/email_message_edit.tpl (.../email_message_edit.tpl) (revision 12657)
+++ branches/5.1.x/core/admin_templates/languages/email_message_edit.tpl (.../email_message_edit.tpl) (revision 13140)
@@ -1,7 +1,7 @@
-
+
-
-
+
+
+
Index: branches/5.1.x/admin/system_presets/simple/email_events_emailevents.php
===================================================================
diff -u
--- branches/5.1.x/admin/system_presets/simple/email_events_emailevents.php (revision 0)
+++ branches/5.1.x/admin/system_presets/simple/email_events_emailevents.php (revision 13140)
@@ -0,0 +1,58 @@
+ Array ('edit', 'view', 'dbl-click'),
+
+// edit email body direct
+// 'email_messages_edit_direct' => Array ('select', 'cancel', 'reset_edit'),
+ );
+
+ // fields to hide
+ $hidden_fields = Array (
+ /*'EventId', 'Event',*/ 'Headers', /*'ReplacementTags', 'Subject', 'Body',*/
+ 'MessageType', 'Enabled', 'FrontEndOnly', 'FromUserId', /*'Module',
+ 'Description', 'Type',*/
+ );
+
+ // virtual fields to hide
+ $virtual_hidden_fields = Array (
+
+ );
+
+ // fields to make required
+ $required_fields = Array (
+ 'EventId', 'Event', /*'Headers', 'ReplacementTags',*/ 'Subject', 'Body',
+ 'MessageType', /*'Enabled', 'FrontEndOnly', 'FromUserId',*/ 'Module',
+ /*'Description',*/ 'Type',
+ );
+
+ // virtual fields to make required
+ $virtual_required_fields = Array (
+
+ );
+
+ // tabs during editing
+ $hide_edit_tabs = Array (
+
+ );
+
+ // hide columns in grids
+ $hide_columns = Array (
+// currently not in user
+// 'Default' => Array ('Subject', 'Description', 'Type', ),
+// 'Emails' => Array ('EventId', 'Subject', 'Description', 'Type', ),
+ );
\ No newline at end of file
Index: branches/5.1.x/core/install/install_data.sql
===================================================================
diff -u -r13086 -r13140
--- branches/5.1.x/core/install/install_data.sql (.../install_data.sql) (revision 13086)
+++ branches/5.1.x/core/install/install_data.sql (.../install_data.sql) (revision 13140)
@@ -239,38 +239,38 @@
INSERT INTO ItemTypes VALUES (1, 'In-Portal', 'c', 'Category', 'Name', 'CreatedById', NULL, NULL, 'la_ItemTab_Categories', 1, 'admin/category/addcategory.php', 'clsCategory', 'Category');
INSERT INTO ItemTypes VALUES (6, 'In-Portal', 'u', 'PortalUser', 'Login', 'PortalUserId', NULL, NULL, '', 0, '', 'clsPortalUser', 'User');
-INSERT INTO Events VALUES(DEFAULT, 'USER.ADD', NULL, 1, 0, NULL, 'Core:Users', 'la_event_user.add', 0);
-INSERT INTO Events VALUES(DEFAULT, 'USER.ADD', NULL, 1, 1, NULL, 'Core:Users', 'la_event_user.add', 1);
-INSERT INTO Events VALUES(DEFAULT, 'USER.APPROVE', NULL, 1, 0, NULL, 'Core:Users', 'la_event_user.approve', 0);
-INSERT INTO Events VALUES(DEFAULT, 'USER.APPROVE', NULL, 1, 1, NULL, 'Core:Users', 'la_event_user.approve', 1);
-INSERT INTO Events VALUES(DEFAULT, 'USER.VALIDATE', NULL, 1, 0, NULL, 'Core:Users', 'la_event_user.validate', 0);
-INSERT INTO Events VALUES(DEFAULT, 'USER.VALIDATE', NULL, 1, 1, NULL, 'Core:Users', 'la_event_user.validate', 1);
-INSERT INTO Events VALUES(DEFAULT, 'USER.DENY', NULL, 1, 0, NULL, 'Core:Users', 'la_event_user.deny', 0);
-INSERT INTO Events VALUES(DEFAULT, 'USER.DENY', NULL, 1, 1, NULL, 'Core:Users', 'la_event_user.deny', 1);
-INSERT INTO Events VALUES(DEFAULT, 'USER.PSWD', NULL, 1, 1, NULL, 'Core:Users', 'la_event_user.forgotpw', 1);
-INSERT INTO Events VALUES(DEFAULT, 'USER.PSWD', NULL, 1, 0, NULL, 'Core:Users', 'la_event_user.forgotpw', 0);
-INSERT INTO Events VALUES(DEFAULT, 'USER.ADD.PENDING', NULL, 1, 0, NULL, 'Core:Users', 'la_event_user.add.pending', 0);
-INSERT INTO Events VALUES(DEFAULT, 'USER.ADD.PENDING', NULL, 1, 1, NULL, 'Core:Users', 'la_event_user.add.pending', 1);
-INSERT INTO Events VALUES(DEFAULT, 'CATEGORY.ADD', NULL, 1, 0, NULL, 'Core:Category', 'la_event_category.add', 0);
-INSERT INTO Events VALUES(DEFAULT, 'CATEGORY.ADD.PENDING', NULL, 1, 0, NULL, 'Core:Category', 'la_event_category.add.pending', 0);
-INSERT INTO Events VALUES(DEFAULT, 'CATEGORY.ADD.PENDING', NULL, 1, 1, NULL, 'Core:Category', 'la_event_category.add.pending', 1);
-INSERT INTO Events VALUES(DEFAULT, 'CATEGORY.ADD', NULL, 1, 1, NULL, 'Core:Category', 'la_event_category.add', 1);
-INSERT INTO Events VALUES(DEFAULT, 'CATEGORY.APPROVE', NULL, 1, 0, NULL, 'Core:Category', 'la_event_category.approve', 0);
-INSERT INTO Events VALUES(DEFAULT, 'CATEGORY.DENY', NULL, 1, 0, NULL, 'Core:Category', 'la_event_category.deny', 0);
-INSERT INTO Events VALUES(DEFAULT, 'USER.SUBSCRIBE', NULL, 1, 0, NULL, 'Core:Users', 'la_event_user.subscribe', 0);
-INSERT INTO Events VALUES(DEFAULT, 'USER.SUBSCRIBE', NULL, 1, 1, NULL, 'Core:Users', 'la_event_user.subscribe', 1);
-INSERT INTO Events VALUES(DEFAULT, 'USER.UNSUBSCRIBE', NULL, 1, 0, NULL, 'Core:Users', 'la_event_user.unsubscribe', 0);
-INSERT INTO Events VALUES(DEFAULT, 'USER.UNSUBSCRIBE', NULL, 1, 1, NULL, 'Core:Users', 'la_event_user.unsubscribe', 1);
-INSERT INTO Events VALUES(DEFAULT, 'USER.SUGGEST', NULL, 1, 0, NULL, 'Core:Users', 'la_event_user.suggest', 0);
-INSERT INTO Events VALUES(DEFAULT, 'USER.SUGGEST', NULL, 1, 1, NULL, 'Core:Users', 'la_event_user.suggest', 1);
-INSERT INTO Events VALUES(DEFAULT, 'USER.PSWDC', NULL, 1, 0, NULL, 'Core:Users', 'la_event_user.pswd_confirm', 0);
-INSERT INTO Events VALUES(DEFAULT, 'USER.MEMBERSHIP.EXPIRED', NULL, 1, 0, NULL, 'Core:Users', 'la_event_user.membership_expired', 0);
-INSERT INTO Events VALUES(DEFAULT, 'USER.MEMBERSHIP.EXPIRED', NULL, 1, 0, NULL, 'Core:Users', 'la_event_user.membership_expired', 1);
-INSERT INTO Events VALUES(DEFAULT, 'USER.MEMBERSHIP.EXPIRATION.NOTICE', NULL, 1, 0, NULL, 'Core:Users', 'la_event_user.membership_expiration_notice', 0);
-INSERT INTO Events VALUES(DEFAULT, 'USER.MEMBERSHIP.EXPIRATION.NOTICE', NULL, 1, 0, NULL, 'Core:Users', 'la_event_user.membership_expiration_notice', 1);
-INSERT INTO Events VALUES(DEFAULT, 'COMMON.FOOTER', NULL, 1, 0, NULL, 'Core', 'la_event_common.footer', 1);
-INSERT INTO Events VALUES(DEFAULT, 'FORM.SUBMITTED', NULL, 1, 0, NULL, 'Core:Category', 'la_event_FormSubmitted', 1);
-INSERT INTO Events VALUES(DEFAULT, 'FORM.SUBMITTED', NULL, 1, 0, NULL, 'Core:Category', 'la_event_FormSubmitted', 0);
+INSERT INTO Events (EventId, Event, ReplacementTags, Enabled, FrontEndOnly, FromUserId, Module, l1_Description, Type) VALUES(DEFAULT, 'USER.ADD', NULL, 1, 0, NULL, 'Core:Users', 'Add User', 0);
+INSERT INTO Events (EventId, Event, ReplacementTags, Enabled, FrontEndOnly, FromUserId, Module, l1_Description, Type) VALUES(DEFAULT, 'USER.ADD', NULL, 1, 1, NULL, 'Core:Users', 'Add User', 1);
+INSERT INTO Events (EventId, Event, ReplacementTags, Enabled, FrontEndOnly, FromUserId, Module, l1_Description, Type) VALUES(DEFAULT, 'USER.APPROVE', NULL, 1, 0, NULL, 'Core:Users', 'Approve User', 0);
+INSERT INTO Events (EventId, Event, ReplacementTags, Enabled, FrontEndOnly, FromUserId, Module, l1_Description, Type) VALUES(DEFAULT, 'USER.APPROVE', NULL, 1, 1, NULL, 'Core:Users', 'Approve User', 1);
+INSERT INTO Events (EventId, Event, ReplacementTags, Enabled, FrontEndOnly, FromUserId, Module, l1_Description, Type) VALUES(DEFAULT, 'USER.VALIDATE', NULL, 1, 0, NULL, 'Core:Users', 'Validate User', 0);
+INSERT INTO Events (EventId, Event, ReplacementTags, Enabled, FrontEndOnly, FromUserId, Module, l1_Description, Type) VALUES(DEFAULT, 'USER.VALIDATE', NULL, 1, 1, NULL, 'Core:Users', 'Validate User', 1);
+INSERT INTO Events (EventId, Event, ReplacementTags, Enabled, FrontEndOnly, FromUserId, Module, l1_Description, Type) VALUES(DEFAULT, 'USER.DENY', NULL, 1, 0, NULL, 'Core:Users', 'Deny User', 0);
+INSERT INTO Events (EventId, Event, ReplacementTags, Enabled, FrontEndOnly, FromUserId, Module, l1_Description, Type) VALUES(DEFAULT, 'USER.DENY', NULL, 1, 1, NULL, 'Core:Users', 'Deny User', 1);
+INSERT INTO Events (EventId, Event, ReplacementTags, Enabled, FrontEndOnly, FromUserId, Module, l1_Description, Type) VALUES(DEFAULT, 'USER.PSWD', NULL, 1, 1, NULL, 'Core:Users', 'Forgot Password', 1);
+INSERT INTO Events (EventId, Event, ReplacementTags, Enabled, FrontEndOnly, FromUserId, Module, l1_Description, Type) VALUES(DEFAULT, 'USER.PSWD', NULL, 1, 0, NULL, 'Core:Users', 'Forgot Password', 0);
+INSERT INTO Events (EventId, Event, ReplacementTags, Enabled, FrontEndOnly, FromUserId, Module, l1_Description, Type) VALUES(DEFAULT, 'USER.ADD.PENDING', NULL, 1, 0, NULL, 'Core:Users', 'Add Pending User', 0);
+INSERT INTO Events (EventId, Event, ReplacementTags, Enabled, FrontEndOnly, FromUserId, Module, l1_Description, Type) VALUES(DEFAULT, 'USER.ADD.PENDING', NULL, 1, 1, NULL, 'Core:Users', 'Add Pending User', 1);
+INSERT INTO Events (EventId, Event, ReplacementTags, Enabled, FrontEndOnly, FromUserId, Module, l1_Description, Type) VALUES(DEFAULT, 'CATEGORY.ADD', NULL, 1, 0, NULL, 'Core:Category', 'Add Category', 0);
+INSERT INTO Events (EventId, Event, ReplacementTags, Enabled, FrontEndOnly, FromUserId, Module, l1_Description, Type) VALUES(DEFAULT, 'CATEGORY.ADD.PENDING', NULL, 1, 0, NULL, 'Core:Category', 'Add Pending Category', 0);
+INSERT INTO Events (EventId, Event, ReplacementTags, Enabled, FrontEndOnly, FromUserId, Module, l1_Description, Type) VALUES(DEFAULT, 'CATEGORY.ADD.PENDING', NULL, 1, 1, NULL, 'Core:Category', 'Add Pending Category', 1);
+INSERT INTO Events (EventId, Event, ReplacementTags, Enabled, FrontEndOnly, FromUserId, Module, l1_Description, Type) VALUES(DEFAULT, 'CATEGORY.ADD', NULL, 1, 1, NULL, 'Core:Category', 'Add Category', 1);
+INSERT INTO Events (EventId, Event, ReplacementTags, Enabled, FrontEndOnly, FromUserId, Module, l1_Description, Type) VALUES(DEFAULT, 'CATEGORY.APPROVE', NULL, 1, 0, NULL, 'Core:Category', 'Approve Category', 0);
+INSERT INTO Events (EventId, Event, ReplacementTags, Enabled, FrontEndOnly, FromUserId, Module, l1_Description, Type) VALUES(DEFAULT, 'CATEGORY.DENY', NULL, 1, 0, NULL, 'Core:Category', 'Deny Category', 0);
+INSERT INTO Events (EventId, Event, ReplacementTags, Enabled, FrontEndOnly, FromUserId, Module, l1_Description, Type) VALUES(DEFAULT, 'USER.SUBSCRIBE', NULL, 1, 0, NULL, 'Core:Users', 'User subscribed', 0);
+INSERT INTO Events (EventId, Event, ReplacementTags, Enabled, FrontEndOnly, FromUserId, Module, l1_Description, Type) VALUES(DEFAULT, 'USER.SUBSCRIBE', NULL, 1, 1, NULL, 'Core:Users', 'User subscribed', 1);
+INSERT INTO Events (EventId, Event, ReplacementTags, Enabled, FrontEndOnly, FromUserId, Module, l1_Description, Type) VALUES(DEFAULT, 'USER.UNSUBSCRIBE', NULL, 1, 0, NULL, 'Core:Users', 'User unsubscribed', 0);
+INSERT INTO Events (EventId, Event, ReplacementTags, Enabled, FrontEndOnly, FromUserId, Module, l1_Description, Type) VALUES(DEFAULT, 'USER.UNSUBSCRIBE', NULL, 1, 1, NULL, 'Core:Users', 'User unsubscribed', 1);
+INSERT INTO Events (EventId, Event, ReplacementTags, Enabled, FrontEndOnly, FromUserId, Module, l1_Description, Type) VALUES(DEFAULT, 'USER.SUGGEST', NULL, 1, 0, NULL, 'Core:Users', 'Suggest to a friend', 0);
+INSERT INTO Events (EventId, Event, ReplacementTags, Enabled, FrontEndOnly, FromUserId, Module, l1_Description, Type) VALUES(DEFAULT, 'USER.SUGGEST', NULL, 1, 1, NULL, 'Core:Users', 'Suggest to a friend', 1);
+INSERT INTO Events (EventId, Event, ReplacementTags, Enabled, FrontEndOnly, FromUserId, Module, l1_Description, Type) VALUES(DEFAULT, 'USER.PSWDC', NULL, 1, 0, NULL, 'Core:Users', 'Password Confirmation', 0);
+INSERT INTO Events (EventId, Event, ReplacementTags, Enabled, FrontEndOnly, FromUserId, Module, l1_Description, Type) VALUES(DEFAULT, 'USER.MEMBERSHIP.EXPIRED', NULL, 1, 0, NULL, 'Core:Users', 'Membership expired', 0);
+INSERT INTO Events (EventId, Event, ReplacementTags, Enabled, FrontEndOnly, FromUserId, Module, l1_Description, Type) VALUES(DEFAULT, 'USER.MEMBERSHIP.EXPIRED', NULL, 1, 0, NULL, 'Core:Users', 'Membership expired', 1);
+INSERT INTO Events (EventId, Event, ReplacementTags, Enabled, FrontEndOnly, FromUserId, Module, l1_Description, Type) VALUES(DEFAULT, 'USER.MEMBERSHIP.EXPIRATION.NOTICE', NULL, 1, 0, NULL, 'Core:Users', 'Membership expiration notice', 0);
+INSERT INTO Events (EventId, Event, ReplacementTags, Enabled, FrontEndOnly, FromUserId, Module, l1_Description, Type) VALUES(DEFAULT, 'USER.MEMBERSHIP.EXPIRATION.NOTICE', NULL, 1, 0, NULL, 'Core:Users', 'Membership expiration notice', 1);
+INSERT INTO Events (EventId, Event, ReplacementTags, Enabled, FrontEndOnly, FromUserId, Module, l1_Description, Type) VALUES(DEFAULT, 'COMMON.FOOTER', NULL, 1, 0, NULL, 'Core', 'Common Footer Template', 1);
+INSERT INTO Events (EventId, Event, ReplacementTags, Enabled, FrontEndOnly, FromUserId, Module, l1_Description, Type) VALUES(DEFAULT, 'FORM.SUBMITTED', NULL, 1, 0, NULL, 'Core:Category', 'This e-mail is sent to a user after filling in the Contact Us form', 1);
+INSERT INTO Events (EventId, Event, ReplacementTags, Enabled, FrontEndOnly, FromUserId, Module, l1_Description, Type) VALUES(DEFAULT, 'FORM.SUBMITTED', NULL, 1, 0, NULL, 'Core:Category', 'This e-mail is sent to a user after filling in the Contact Us form', 0);
INSERT INTO IdGenerator VALUES ('100');
@@ -637,7 +637,9 @@
INSERT INTO Permissions VALUES (DEFAULT, 'in-portal:phrases.delete', 11, 1, 1, 0);
INSERT INTO Permissions VALUES (DEFAULT, 'in-portal:configemail.view', 11, 1, 1, 0);
+INSERT INTO Permissions VALUES (DEFAULT, 'in-portal:configemail.add', 11, 1, 1, 0);
INSERT INTO Permissions VALUES (DEFAULT, 'in-portal:configemail.edit', 11, 1, 1, 0);
+INSERT INTO Permissions VALUES (DEFAULT, 'in-portal:configemail.delete', 11, 1, 1, 0);
INSERT INTO Permissions VALUES (DEFAULT, 'CATEGORY.VIEW', 11, 1, 0, 0);
INSERT INTO Permissions VALUES (DEFAULT, 'CATEGORY.ADD', 11, 1, 0, 0);
Index: branches/5.1.x/core/units/email_events/email_events_event_handler.php
===================================================================
diff -u -r13086 -r13140
--- branches/5.1.x/core/units/email_events/email_events_event_handler.php (.../email_events_event_handler.php) (revision 13086)
+++ branches/5.1.x/core/units/email_events/email_events_event_handler.php (.../email_events_event_handler.php) (revision 13140)
@@ -1,6 +1,6 @@
getObject();
+ /* @var $object kDBList */
+
if ($event->Special == 'module') {
- $object =& $event->getObject();
$module = $this->Application->GetVar('module');
$object->addFilter('module_filter', '%1$s.Module = '.$this->Conn->qstr($module));
}
+
+ if (!$event->Special && !$this->Application->isDebugMode()) {
+ // no special
+ $object->addFilter('enabled_filter', '%1$s.Enabled <> ' . STATUS_DISABLED);
+ }
}
/**
+ * Sets event id
+ *
+ * @param kEvent $event
+ */
+ function OnPreCreate(&$event)
+ {
+ parent::OnPreCreate($event);
+
+ $object =& $event->getObject();
+ /* @var $object kDBItem */
+
+ $object->SetDBField('Headers', $this->Application->ConfigValue('Smtp_DefaultHeaders'));
+ }
+
+ /**
* Sets status Front-End Only to selected email events
*
* @param kEvent $event
@@ -147,55 +168,65 @@
}
/**
- * Returns sender & recipients ids plus event_id (as parameter by reference)
+ * Returns email event object based on given kEvent object
*
* @param kEvent $event
- * @param int $event_id id of email event used
- *
- * @return mixed
+ * @return kDBItem
*/
- function GetMessageRecipients(&$event, &$event_id)
+ function &_getEmailEvent(&$event)
{
- $email_event =& $event->getObject( Array('skip_autoload' => true) );
- /* @var $email_event kDBItem */
+ $false = false;
+ $name = $event->getEventParam('EmailEventName');
+ $type = $event->getEventParam('EmailEventType');
- // get event parameters by name & type
- $load_keys = Array (
- 'Event' => $event->getEventParam('EmailEventName'),
- 'Type' => $event->getEventParam('EmailEventType'),
- );
- $email_event->Load($load_keys);
+ $object =& $event->getObject( Array('skip_autoload' => true) );
+ /* @var $object kDBItem */
- if (!$email_event->isLoaded()) {
- // event record not found
- return false;
- }
+ if (!$object->isLoaded() || (($object->GetDBField('Event') != $name) && ($object->GetDBField('Type') != $type))) {
+ // get event parameters by name & type
+ $load_keys = Array ('Event' => $name, 'Type' => $type);
+ $object->Load($load_keys);
- if ($email_event->GetDBField('Enabled') == STATUS_DISABLED) {
- return false;
- }
+ if (!$object->isLoaded() || ($object->GetDBField('Enabled') == STATUS_DISABLED)) {
+ // event record not found OR is disabled
+ return $false;
+ }
- if ($email_event->GetDBField('FrontEndOnly') && $this->Application->isAdmin) {
- return false;
+ if ($object->GetDBField('FrontEndOnly') && $this->Application->isAdmin) {
+ return $false;
+ }
}
+ return $object;
+ }
+
+ /**
+ * Returns sender & recipients ids plus event_id (as parameter by reference)
+ *
+ * @param kEvent $event
+ *
+ * @return mixed
+ */
+ function GetMessageRecipients(&$event)
+ {
+ $object =& $this->_getEmailEvent($event);
+ /* @var $object kDBItem */
+
// initial values
$to_user_id = $event->getEventParam('EmailEventToUserId');
if ( !is_numeric($to_user_id) ) {
$to_user_id = -1; // when not specified, then send to "root"
}
- $from_user_id = $email_event->GetDBField('FromUserId');
+ $from_user_id = $object->GetDBField('FromUserId');
- if ($email_event->GetDBField('Type') == EVENT_TYPE_ADMIN) {
+ if ($object->GetDBField('Type') == EVENT_TYPE_ADMIN) {
// For type "Admin" recipient is a user from field FromUserId which means From/To user in Email events list
if ($to_user_id == -1) {
$to_user_id = $from_user_id;
}
$from_user_id = -1;
}
- $event_id = $email_event->GetDBField('EventId');
-
return Array ($from_user_id, $to_user_id);
}
@@ -245,56 +276,28 @@
/**
* Returns email event message by ID (headers & body in one piece)
*
- * @param int $event_id
- * @param string $message_type contains message type = {text,html}
+ * @param kEvent $event
* @param int $language_id
*/
- function GetMessageBody($event_id, &$message_type, $language_id = null)
+ function GetMessageBody(&$event, $language_id = null)
{
if (!isset($language_id)) {
$language_id = $this->Application->GetVar('m_lang');
}
- $message =& $this->Application->recallObject('emailmessages', null, Array('skip_autoload' => true));
- /* @var $message kDBItem */
+ $object =& $this->_getEmailEvent($event);
- $message->Load( Array('EventId' => $event_id, 'LanguageId' => $language_id) );
- if (!$message->isLoaded()) {
- // event translation on required language not found
- return false;
- }
-
- $message_type = $message->GetDBField('MessageType');
-
// 1. get message body
- $message_body = $message->GetDBField('Template');
+ $message_body = $this->_formMessageBody($object, $language_id, $object->GetDBField('MessageType'));
- // 2. add footer
- $sql = 'SELECT em.Template
- FROM '.$message->TableName.' em
- LEFT JOIN '.TABLE_PREFIX.'Events e ON e.EventId = em.EventId
- WHERE em.LanguageId = '.$language_id.' AND e.Event = "COMMON.FOOTER"';
-
- list (, $footer) = explode("\n\n", $this->Conn->GetOne($sql));
- if ($message_type == 'text') {
- $esender =& $this->Application->recallObject('EmailSender');
- /* @var $esender kEmailSendingHelper */
-
- $footer = $esender->ConvertToText($footer);
- }
-
- if ($footer) {
- $message_body .= "\r\n".$footer;
- }
-
- // 3. replace tags if needed
+ // 2. replace tags if needed
$default_replacement_tags = Array (
' ' ' 'GetDBField('ReplacementTags');
+ $replacement_tags = $object->GetDBField('ReplacementTags');
$replacement_tags = $replacement_tags ? unserialize($replacement_tags) : Array ();
$replacement_tags = array_merge_recursive2($default_replacement_tags, $replacement_tags);
@@ -306,6 +309,90 @@
}
/**
+ * Prepare email message body
+ *
+ * @param kDBItem $object
+ * @param int $language_id
+ * @return string
+ */
+ function _formMessageBody(&$object, $language_id)
+ {
+ $default_language_id = $this->Application->GetDefaultLanguageId();
+
+ $fields_hash = Array (
+ 'Headers' => $object->GetDBField('Headers'),
+ );
+
+ // prepare subject
+ $subject = $object->GetDBField('l' . $language_id . '_Subject');
+
+ if (!$subject) {
+ $subject = $object->GetDBField('l' . $default_language_id . '_Subject');
+ }
+
+ $fields_hash['Subject'] = $subject;
+
+ // prepare body
+ $body = $object->GetDBField('l' . $language_id . '_Body');
+
+ if (!$body) {
+ $body = $object->GetDBField('l' . $default_language_id . '_Body');
+ }
+
+ $fields_hash['Body'] = $body;
+
+ $email_message_helper =& $this->Application->recallObject('EmailMessageHelper');
+ /* @var $email_message_helper EmailMessageHelper */
+
+ $ret = $email_message_helper->buildTemplate($fields_hash);
+
+ // add footer
+ $footer = $this->_getFooter($language_id, $object->GetDBField('MessageType'));
+
+ if ($ret && $footer) {
+ $ret .= "\r\n" . $footer;
+ }
+
+ return $ret;
+ }
+
+ /**
+ * Returns email footer
+ *
+ * @param int $language_id
+ * @param string $message_type
+ * @return string
+ */
+ function _getFooter($language_id, $message_type)
+ {
+ static $footer = null;
+
+ if (!isset($footer)) {
+ $default_language_id = $this->Application->GetDefaultLanguageId();
+
+ $sql = 'SELECT l' . $language_id . '_Body, l' . $default_language_id . '_Body
+ FROM ' . $this->Application->getUnitOption('emailevents', 'TableName') . ' em
+ WHERE Event = "COMMON.FOOTER"';
+ $footer_data = $this->Conn->GetRow($sql);
+
+ $footer = $footer_data['l' . $language_id . '_Body'];
+
+ if (!$footer) {
+ $footer = $footer_data['l' . $default_language_id . '_Body'];
+ }
+
+ if ($message_type == 'text') {
+ $esender =& $this->Application->recallObject('EmailSender');
+ /* @var $esender kEmailSendingHelper */
+
+ $footer = $esender->ConvertToText($footer);
+ }
+ }
+
+ return $footer;
+ }
+
+ /**
* Parse message template and return headers (as array) and message body part
*
* @param string $message
@@ -365,23 +452,26 @@
trigger_error('Invalid email event name '.$email_event_name.'. Use only UPPERCASE characters and dots as email event names', E_USER_ERROR);
}
+ $object =& $this->_getEmailEvent($event);
+
+ if (!is_object($object)) {
+ // email event not found OR it's won't be send under given circumstances
+ return false;
+ }
+
// additional parameters from kApplication->EmailEvent
$send_params = $event->getEventParam('DirectSendParams');
// 1. get information about message sender and recipient
- $recipients = $this->GetMessageRecipients($event, $event_id);
- if ($recipients === false) {
- // if not valid recipients found, then don't send event
- return false;
- }
+ $recipients = $this->GetMessageRecipients($event);
list ($from_id, $to_id) = $recipients;
list ($from_email, $from_name) = $this->GetRecipientInfo($from_id, 'from', $send_params);
list ($to_email, $to_name) = $this->GetRecipientInfo($to_id, 'to', $send_params);
// 2. prepare message to be sent
$message_language = $this->_getSendLanguage($send_params);
- $message_template = $this->GetMessageBody($event_id, $message_type, $message_language);
+ $message_template = $this->GetMessageBody($event, $message_language);
if (!trim($message_template)) {
trigger_error('Message template is empty', E_USER_WARNING);
return false;
@@ -405,18 +495,18 @@
if ($this->Application->isDebugMode()) {
// set special header with event name, so it will be easier to determite what's actually was received
- $message_headers['X-Event-Name'] = $email_event_name . ' - ' . ($event->getEventParam('EmailEventType') == 1 ? 'ADMIN' : 'USER');
+ $message_headers['X-Event-Name'] = $email_event_name . ' - ' . ($event->getEventParam('EmailEventType') == EVENT_TYPE_ADMIN ? 'ADMIN' : 'USER');
}
foreach ($message_headers as $header_name => $header_value) {
$esender->SetEncodedHeader($header_name, $header_value);
}
- $esender->CreateTextHtmlPart($message_body, $message_type == 'html');
+ $esender->CreateTextHtmlPart($message_body, $object->GetDBField('MessageType') == 'html');
$event->status = $esender->Deliver() ? erSUCCESS : erFAIL;
- if ($event->status == erSUCCESS){
+ if ($event->status == erSUCCESS) {
// all keys, that are not used in email sending are written to log record
$send_keys = Array ('from_email', 'from_name', 'to_email', 'to_name', 'message');
foreach ($send_keys as $send_key) {
@@ -534,4 +624,39 @@
echo ($emails_sent / $total_emails) * 100;
}
}
+
+ /**
+ * Prefills module dropdown
+ *
+ * @param kEvent $event
+ */
+ function OnAfterConfigRead(&$event)
+ {
+ parent::OnAfterConfigRead($event);
+
+ $options = Array ('Core:Users' => 'Core - Users', 'Core:Category' => 'Core - Categories');
+
+ foreach ($this->Application->ModuleInfo as $module_name => $module_info) {
+ if (($module_name == 'In-Portal') || ($module_name == 'Core')) {
+ continue;
+ }
+
+ $options[$module_name] = $module_name;
+ }
+
+ $fields = $this->Application->getUnitOption($event->Prefix, 'Fields');
+ $fields['Module']['options'] = $options;
+ $this->Application->setUnitOption($event->Prefix, 'Fields', $fields);
+
+ // make grid on "Email Events" tab in "Regional" section show columns of editable language, not admin language
+ $language_id = $this->Application->GetVar('lang_id');
+
+ if ($language_id) {
+ $grids = $this->Application->getUnitOption($event->Prefix, 'Grids');
+ // used by column picker to track column position
+ $grids['Default']['Fields']['Description']['formatter_renamed'] = true;
+ array_rename_key($grids['Default']['Fields'], 'Description', 'l' . $language_id . '_Description');
+ $this->Application->setUnitOption($event->Prefix, 'Grids', $grids);
+ }
+ }
}
\ No newline at end of file
Index: branches/5.1.x/core/units/languages/languages_config.php
===================================================================
diff -u -r13086 -r13140
--- branches/5.1.x/core/units/languages/languages_config.php (.../languages_config.php) (revision 13086)
+++ branches/5.1.x/core/units/languages/languages_config.php (.../languages_config.php) (revision 13140)
@@ -1,6 +1,6 @@
true,
'Hooks' => Array(
- Array(
- 'Mode' => hAFTER,
- 'Conditional' => false,
- 'HookToPrefix' => 'lang',
- 'HookToSpecial' => '',
- 'HookToEvent' => Array('OnSave'),
- 'DoPrefix' => '',
- 'DoSpecial' => '',
- 'DoEvent' => 'OnReflectMultiLingualFields',
- ),
+ Array(
+ 'Mode' => hAFTER,
+ 'Conditional' => false,
+ 'HookToPrefix' => 'lang',
+ 'HookToSpecial' => '*',
+ 'HookToEvent' => Array('OnSave'),
+ 'DoPrefix' => '',
+ 'DoSpecial' => '',
+ 'DoEvent' => 'OnUpdatePrimary',
+ ),
- Array(
- 'Mode' => hAFTER,
- 'Conditional' => false,
- 'HookToPrefix' => 'lang',
- 'HookToSpecial' => '',
- 'HookToEvent' => Array('OnPreSave'),
- 'DoPrefix' => '',
- 'DoSpecial' => '',
- 'DoEvent' => 'OnCopyLabels',
- ),
+ Array(
+ 'Mode' => hAFTER,
+ 'Conditional' => false,
+ 'HookToPrefix' => 'lang',
+ 'HookToSpecial' => '*',
+ 'HookToEvent' => Array('OnSave','OnMassDelete'),
+ 'DoPrefix' => '',
+ 'DoSpecial' => '',
+ 'DoEvent' => 'OnScheduleTopFrameReload',
+ ),
- Array(
- 'Mode' => hAFTER,
- 'Conditional' => false,
- 'HookToPrefix' => 'lang',
- 'HookToSpecial' => '*',
- 'HookToEvent' => Array('OnSave'),
- 'DoPrefix' => '',
- 'DoSpecial' => '',
- 'DoEvent' => 'OnUpdatePrimary',
- ),
-
- Array(
- 'Mode' => hAFTER,
- 'Conditional' => false,
- 'HookToPrefix' => 'lang',
- 'HookToSpecial' => '*',
- 'HookToEvent' => Array('OnSave','OnMassDelete'),
- 'DoPrefix' => '',
- 'DoSpecial' => '',
- 'DoEvent' => 'OnScheduleTopFrameReload',
- ),
-
- ),
+ ),
'QueryString' => Array(
1 => 'id',
2 => 'page',
@@ -116,9 +94,8 @@
'edit_status_labels' => Array('emailevents' => '!la_title_Editing_EmailEvent!'),
'format' => '#emailevents_status# - #emailevents_titlefield#'),
- 'email_messages_edit' => Array( 'prefixes' => Array('lang','emailmessages'),
- 'new_titlefield' => Array('emailmessages' => ''),
- 'format' => "#lang_status# '#lang_titlefield#' - !la_title_EditingEmailEvent! '#emailmessages_titlefield#'"),
+ 'email_messages_edit' => Array( 'prefixes' => Array('lang','emailevents'),
+ 'format' => "#lang_status# '#lang_titlefield#' - !la_title_EditingEmailEvent! '#emailevents_titlefield#'"),
// for separate language list
'languages_list_st' => Array ('prefixes' => Array ('lang_List'), 'format' => "!la_title_LanguagesManagement!"),
@@ -159,7 +136,7 @@
),
'TableName' => TABLE_PREFIX.'Language',
- 'SubItems' => Array('phrases','emailmessages'),
+ 'SubItems' => Array('phrases',/*'emailmessages'*/),
'FilterMenu' => Array(
'Groups' => Array(
Index: branches/5.1.x/core/admin_templates/users/users_list.tpl
===================================================================
diff -u -r12657 -r13140
--- branches/5.1.x/core/admin_templates/users/users_list.tpl (.../users_list.tpl) (revision 12657)
+++ branches/5.1.x/core/admin_templates/users/users_list.tpl (.../users_list.tpl) (revision 13140)
@@ -55,16 +55,6 @@
a_toolbar.AddButton( new ToolBarSeparator('sep2') );
- /*
-
- a_toolbar.AddButton( new ToolBarButton('e-mail', '', function() {
- set_hidden_field('remove_specials[u.regular]', 1);
- openSelector('emailmessages', '', 'UserEmail', null, 'OnPrepareMassRecipients');
- }
- ) );
-
- */
-
a_toolbar.AddButton(
new ToolBarButton(
Index: branches/5.1.x/core/admin_templates/config/config_email_edit.tpl
===================================================================
diff -u -r12657 -r13140
--- branches/5.1.x/core/admin_templates/config/config_email_edit.tpl (.../config_email_edit.tpl) (revision 12657)
+++ branches/5.1.x/core/admin_templates/config/config_email_edit.tpl (.../config_email_edit.tpl) (revision 13140)
@@ -71,7 +71,7 @@
-
+
Index: branches/5.1.x/core/units/email_events/email_event_tp.php
===================================================================
diff -u
--- branches/5.1.x/core/units/email_events/email_event_tp.php (revision 0)
+++ branches/5.1.x/core/units/email_events/email_event_tp.php (revision 13140)
@@ -0,0 +1,24 @@
+Application->isDebugMode()) {
+ $grids = $this->Application->getUnitOption($this->Prefix, 'Grids');
+
+ foreach ($grids as $grid_name => $grid_data) {
+ if (array_key_exists('Enabled', $grid_data['Fields'])) {
+ unset($grids[$grid_name]['Fields']['Enabled']);
+ }
+ }
+
+ $this->Application->setUnitOption($this->Prefix, 'Grids', $grids);
+ }
+ }
+ }
\ No newline at end of file
Index: branches/5.1.x/core/install/upgrades.sql
===================================================================
diff -u -r13086 -r13140
--- branches/5.1.x/core/install/upgrades.sql (.../upgrades.sql) (revision 13086)
+++ branches/5.1.x/core/install/upgrades.sql (.../upgrades.sql) (revision 13140)
@@ -1620,4 +1620,28 @@
# ===== v 5.0.2-RC1 =====
-# ===== v 5.0.2 =====
\ No newline at end of file
+# ===== v 5.0.2 =====
+
+# ===== v 5.1.0-B1 =====
+DROP TABLE EmailMessage;
+DELETE FROM PersistantSessionData WHERE VariableName = 'emailevents_columns_.';
+
+INSERT INTO Permissions (Permission, GroupId, PermissionValue, Type, CatId)
+SELECT 'in-portal:configemail.add' AS Permission, GroupId, PermissionValue, Type, CatId
+FROM <%TABLE_PREFIX%>Permissions
+WHERE Permission = 'in-portal:configemail.edit';
+
+INSERT INTO Permissions (Permission, GroupId, PermissionValue, Type, CatId)
+SELECT 'in-portal:configemail.delete' AS Permission, GroupId, PermissionValue, Type, CatId
+FROM <%TABLE_PREFIX%>Permissions
+WHERE Permission = 'in-portal:configemail.edit';
+
+UPDATE Events e
+SET e.l1_Description = (
+ SELECT p.Translation
+ FROM <%TABLE_PREFIX%>Phrase p
+ WHERE (p.Phrase = e.Description) AND (p.LanguageId = 1)
+);
+
+ALTER TABLE Events DROP Description;
+DELETE FROM Phrase WHERE Phrase LIKE 'la_event_%';
Index: branches/5.1.x/core/install/remove_schema.sql
===================================================================
diff -u -r12127 -r13140
--- branches/5.1.x/core/install/remove_schema.sql (.../remove_schema.sql) (revision 12127)
+++ branches/5.1.x/core/install/remove_schema.sql (.../remove_schema.sql) (revision 13140)
@@ -3,7 +3,6 @@
DROP TABLE CustomField;
DROP TABLE ConfigurationAdmin;
DROP TABLE ConfigurationValues;
-DROP TABLE EmailMessage;
DROP TABLE EmailQueue;
DROP TABLE EmailSubscribers;
DROP TABLE Events;
Index: branches/5.1.x/core/kernel/db/db_event_handler.php
===================================================================
diff -u -r13086 -r13140
--- branches/5.1.x/core/kernel/db/db_event_handler.php (.../db_event_handler.php) (revision 13086)
+++ branches/5.1.x/core/kernel/db/db_event_handler.php (.../db_event_handler.php) (revision 13140)
@@ -1,6 +1,6 @@
getSection();
+
if (!$this->Application->isAdmin) {
$allow_events = Array('OnSearch', 'OnSearchReset', 'OnNew');
if (in_array($event->Name, $allow_events)) {
// allow search on front
return true;
}
}
+ elseif (($event->Name == 'OnPreSaveAndChangeLanguage') && !$this->UseTempTables($event)) {
+ // allow changing language in grids, when not in editing mode
+ return $this->Application->CheckPermission($section . '.view', 1);
+ }
- $section = $event->getSection();
if (!preg_match('/^CATEGORY:(.*)/', $section)) {
// only if not category item events
if ((substr($event->Name, 0, 9) == 'OnPreSave') || ($event->Name == 'OnSave')) {
@@ -2308,17 +2313,17 @@
*/
function OnPreSaveAndChangeLanguage(&$event)
{
- $event->CallSubEvent('OnPreSave');
+ if ($this->UseTempTables($event)) {
+ $event->CallSubEvent('OnPreSave');
+ }
if ($event->status == erSUCCESS) {
$this->Application->SetVar('m_lang', $this->Application->GetVar('language'));
- $pass_vars = Array ('st_id', 'cms_id');
- foreach ($pass_vars as $pass_var) {
- $data = $this->Application->GetVar($pass_var);
- if ($data) {
- $event->SetRedirectParam($pass_var, $data);
- }
+ $data = $this->Application->GetVar('st_id');
+
+ if ($data) {
+ $event->SetRedirectParam('st_id', $data);
}
}
}
Index: branches/5.1.x/core/admin_templates/incs/grid_blocks.tpl
===================================================================
diff -u -r13086 -r13140
--- branches/5.1.x/core/admin_templates/incs/grid_blocks.tpl (.../grid_blocks.tpl) (revision 13086)
+++ branches/5.1.x/core/admin_templates/incs/grid_blocks.tpl (.../grid_blocks.tpl) (revision 13140)
@@ -885,4 +885,21 @@
$ViewMenus = new Array('');
+
+
+
+
+ :
+ >
+
+
+
+
+
+
+
+
+
\ No newline at end of file
Fisheye: Tag 13140 refers to a dead (removed) revision in file `branches/5.1.x/core/units/email_messages/email_messages_config.php'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 13140 refers to a dead (removed) revision in file `branches/5.1.x/core/units/email_messages/email_messages_event_handler.php'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 13140 refers to a dead (removed) revision in file `branches/5.1.x/core/units/email_messages/email_message_tp.php'.
Fisheye: No comparison available. Pass `N' to diff?
Index: branches/5.1.x/core/admin_templates/mailing_lists/send_queue.tpl
===================================================================
diff -u -r12127 -r13140
--- branches/5.1.x/core/admin_templates/mailing_lists/send_queue.tpl (.../emails/send_queue.tpl) (revision 12127)
+++ branches/5.1.x/core/admin_templates/mailing_lists/send_queue.tpl (.../mailing_lists/send_queue.tpl) (revision 13140)
@@ -6,10 +6,10 @@
\ No newline at end of file