*/
class CRM_Mailing_PseudoConstant extends CRM_Core_PseudoConstant {
+ /**
+ * Status options for A/B tests.
+ * @var array
+ */
+ private static $abStatus;
+
+ /**
+ * Test criteria for A/B tests.
+ * @var array
+ */
+ private static $abTestCriteria;
+
+ /**
+ * Winner criteria for A/B tests.
+ * @var array
+ */
+ private static $abWinnerCriteria;
+
/**
* Mailing templates
* @var array
*/
private static $defaultComponent;
+ /**
+ * @return array
+ */
+ public static function abStatus() {
+ if (!is_array(self::$abStatus)) {
+ self::$abStatus = array(
+ 'Draft' => ts('Draft'),
+ 'Testing' => ts('Testing'),
+ 'Final' => ts('Final'),
+ );
+ }
+ return self::$abStatus;
+ }
+
+ /**
+ * @return array
+ */
+ public static function abTestCriteria() {
+ if (!is_array(self::$abTestCriteria)) {
+ self::$abTestCriteria = array(
+ 'subject' => ts('Test different "Subject" lines'),
+ 'from' => ts('Test different "From" lines'),
+ 'full_email' => ts('Test entirely different emails'),
+ );
+ }
+ return self::$abTestCriteria;
+ }
+
+ /**
+ * @return array
+ */
+ public static function abWinnerCriteria() {
+ if (!is_array(self::$abWinnerCriteria)) {
+ self::$abWinnerCriteria = array(
+ 'open' => ts('Open'),
+ 'unique_click' => ts('Total Unique Clicks'),
+ 'link_click' => ts('Total Clicks on a particular link'),
+ );
+ }
+ return self::$abWinnerCriteria;
+ }
+
/**
* Get all the mailing components of a particular type.
*
-- location_type_id should have default NULL, not invalid id 0
ALTER TABLE civicrm_mailing CHANGE `location_type_id` `location_type_id` int(10) unsigned DEFAULT NULL COMMENT 'With email_selection_method, determines which email address to use';
-
-- CRM-15970 - Track authorship of of A/B tests
ALTER TABLE civicrm_mailing_abtest
ADD COLUMN `created_id` int unsigned COMMENT 'FK to Contact ID',
ADD COLUMN `created_date` datetime COMMENT 'When was this item created',
+ ADD COLUMN `testing_criteria` varchar(32) COLLATE utf8_unicode_ci DEFAULT NULL,
+ ADD COLUMN `winner_criteria` varchar(32) COLLATE utf8_unicode_ci DEFAULT NULL,
ADD CONSTRAINT FK_civicrm_mailing_abtest_created_id FOREIGN KEY (`created_id`) REFERENCES `civicrm_contact`(`id`) ON DELETE SET NULL;
+
+-- Move A/B test option-values into code
+DELETE FROM civicrm_option_group WHERE name IN ('mailing_ab_status', 'mailing_ab_testing_criteria', 'mailing_ab_winner_criteria');
+UPDATE civicrm_mailing_abtest SET testing_criteria = 'subject' WHERE testing_criteria_id = 1;
+UPDATE civicrm_mailing_abtest SET testing_criteria = 'from' WHERE testing_criteria_id = 2;
+UPDATE civicrm_mailing_abtest SET testing_criteria = 'full_email' WHERE testing_criteria_id = 3;
+UPDATE civicrm_mailing_abtest SET winner_criteria = 'open' WHERE winner_criteria_id = 1;
+UPDATE civicrm_mailing_abtest SET winner_criteria = 'unique_click' WHERE winner_criteria_id = 2;
+UPDATE civicrm_mailing_abtest SET winner_criteria = 'link_click' WHERE winner_criteria_id = 3;
+
+ALTER TABLE civicrm_mailing_abtest
+ DROP COLUMN `testing_criteria_id`,
+ DROP COLUMN `winner_criteria_id`;
('name_badge' , '{ts escape="sql"}Name Badge Format{/ts}' , 1, 1, 0),
('communication_style' , '{ts escape="sql"}Communication Style{/ts}' , 1, 1, 0),
('msg_mode' , '{ts escape="sql"}Message Mode{/ts}' , 1, 1, 0),
- ('contact_date_reminder_options' , '{ts escape="sql"}Contact Date Reminder Options{/ts}' , 1, 1, 1),
- ('mailing_ab_status' , '{ts escape="sql"}Mailing A/B Status{/ts}' , 1, 1, 1),
- ('mailing_ab_testing_criteria' , '{ts escape="sql"}Mailing A/B Testing Criteria{/ts}' , 1, 1, 1),
- ('mailing_ab_winner_criteria' , '{ts escape="sql"}Mailing A/B Testing Winner Criteria{/ts}', 1, 1, 1);
+ ('contact_date_reminder_options' , '{ts escape="sql"}Contact Date Reminder Options{/ts}' , 1, 1, 1);
SELECT @option_group_id_pcm := max(id) from civicrm_option_group where name = 'preferred_communication_method';
SELECT @option_group_id_act := max(id) from civicrm_option_group where name = 'activity_type';
SELECT @option_group_id_communication_style := max(id) from civicrm_option_group where name = 'communication_style';
SELECT @option_group_id_msg_mode := max(id) from civicrm_option_group where name = 'msg_mode';
SELECT @option_group_id_contactDateMode := max(id) from civicrm_option_group where name = 'contact_date_reminder_options';
-SELECT @option_group_id_mailingABStatus := max(id) from civicrm_option_group where name = 'mailing_ab_status';
-SELECT @option_group_id_mailingABCriteria := max(id) from civicrm_option_group where name = 'mailing_ab_testing_criteria';
-SELECT @option_group_id_mailingABWinnerCriteria := max(id) from civicrm_option_group where name = 'mailing_ab_winner_criteria';
SELECT @contributeCompId := max(id) FROM civicrm_component where name = 'CiviContribute';
SELECT @eventCompId := max(id) FROM civicrm_component where name = 'CiviEvent';
-- Reminder Options for Contact Date Fields
(@option_group_id_contactDateMode, '{ts escape="sql"}Actual date only{/ts}', '1', 'Actual date only', NULL, NULL, 0, 1, NULL, 0, 1, 1, NULL, NULL),
-(@option_group_id_contactDateMode, '{ts escape="sql"}Each anniversary{/ts}', '2', 'Each anniversary', NULL, NULL, 0, 2, NULL, 0, 1, 1, NULL, NULL),
-
--- Mailing A/B Status
-(@option_group_id_mailingABStatus, '{ts escape="sql"}Draft{/ts}', '1', 'Draft', NULL, NULL, 0, 1, NULL, 0, 1, 1, NULL, NULL),
-(@option_group_id_mailingABStatus, '{ts escape="sql"}Testing{/ts}', '2', 'Testing', NULL, NULL, 0, 1, NULL, 0, 1, 1, NULL, NULL),
-(@option_group_id_mailingABStatus, '{ts escape="sql"}Final{/ts}', '3', 'Final', NULL, NULL, 0, 1, NULL, 0, 1, 1, NULL, NULL),
-
--- Mailing A/B Testing Winner Criteria
-(@option_group_id_mailingABWinnerCriteria, '{ts escape="sql"}Open{/ts}', '1', 'Open', NULL, NULL, 0, 1, NULL, 0, 1, 1, NULL, NULL),
-(@option_group_id_mailingABWinnerCriteria, '{ts escape="sql"}Total Unique Clicks{/ts}', '2', 'Total Unique Clicks', NULL, NULL, 0, 2, NULL, 0, 1, 1, NULL, NULL),
-(@option_group_id_mailingABWinnerCriteria, '{ts escape="sql"}Total Clicks on a particular link{/ts}', '3', 'Total Clicks on a particular link', NULL, NULL, 0, 3, NULL, 0, 1, 1, NULL, NULL),
-
--- Mailing A/B Testing Criteria
-(@option_group_id_mailingABCriteria, '{ts escape="sql"}Subject Lines {/ts}', '1', 'Subject Lines', NULL, NULL, 0, 1, NULL, 0, 1, 1, NULL, NULL),
-(@option_group_id_mailingABCriteria, '{ts escape="sql"}From Names {/ts}', '2', 'From Names', NULL, NULL, 0, 2, NULL, 0, 1, 1, NULL, NULL),
-(@option_group_id_mailingABCriteria, '{ts escape="sql"}Two different Emails {/ts}', '3', 'Two different Emails ', NULL, NULL, 0, 3, NULL, 0, 1, 1, NULL, NULL);
+(@option_group_id_contactDateMode, '{ts escape="sql"}Each anniversary{/ts}', '2', 'Each anniversary', NULL, NULL, 0, 2, NULL, 0, 1, 1, NULL, NULL);
-- financial accounts
SELECT @opval := value FROM civicrm_option_value WHERE name = 'Revenue' and option_group_id = @option_group_id_fat;