From 8b06123b0b1776714f989f4de294a5603eda0302 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Mon, 16 Feb 2015 13:33:12 -0800 Subject: [PATCH] CRM-15970 - Add MailingAB fields, "created_id" and "created_date" --- .../Incremental/sql/4.6.alpha7.mysql.tpl | 7 ++++++ api/v3/MailingAB.php | 9 +++++++ tests/phpunit/api/v3/MailingABTest.php | 1 + xml/schema/Mailing/MailingAB.xml | 25 ++++++++++++++++++- 4 files changed, 41 insertions(+), 1 deletion(-) diff --git a/CRM/Upgrade/Incremental/sql/4.6.alpha7.mysql.tpl b/CRM/Upgrade/Incremental/sql/4.6.alpha7.mysql.tpl index d27ff06717..3109a25886 100644 --- a/CRM/Upgrade/Incremental/sql/4.6.alpha7.mysql.tpl +++ b/CRM/Upgrade/Incremental/sql/4.6.alpha7.mysql.tpl @@ -2,3 +2,10 @@ -- 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 CONSTRAINT FK_civicrm_mailing_abtest_created_id FOREIGN KEY (`created_id`) REFERENCES `civicrm_contact`(`id`) ON DELETE SET NULL; diff --git a/api/v3/MailingAB.php b/api/v3/MailingAB.php index 937de0e630..4328ec7db7 100755 --- a/api/v3/MailingAB.php +++ b/api/v3/MailingAB.php @@ -32,6 +32,15 @@ * @package CiviCRM_APIv3 */ +/** + * @param array $spec + */ +function _civicrm_api3_mailing_a_b_create_spec(&$spec) { + $spec['created_date']['api.default'] = 'now'; + $spec['created_id']['api.required'] = 1; + $spec['created_id']['api.default'] = 'user_contact_id'; +} + /** * Handle a create mailing ab testing. * diff --git a/tests/phpunit/api/v3/MailingABTest.php b/tests/phpunit/api/v3/MailingABTest.php index b7602f2750..e317b60e47 100755 --- a/tests/phpunit/api/v3/MailingABTest.php +++ b/tests/phpunit/api/v3/MailingABTest.php @@ -43,6 +43,7 @@ class api_v3_MailingABTest extends CiviUnitTestCase { public function setUp() { parent::setUp(); $this->useTransaction(TRUE); + $this->createLoggedInUser(); $this->_mailingID_A = $this->createMailing(); $this->_mailingID_B = $this->createMailing(); $this->_mailingID_C = $this->createMailing(); diff --git a/xml/schema/Mailing/MailingAB.xml b/xml/schema/Mailing/MailingAB.xml index 671c9c1d14..e965535603 100644 --- a/xml/schema/Mailing/MailingAB.xml +++ b/xml/schema/Mailing/MailingAB.xml @@ -103,5 +103,28 @@ Group Percentage 4.6 - + + created_id + AB Test Created By + int unsigned + FK to Contact ID + 4.6 + + + created_id + civicrm_contact
+ id + 4.6 + SET NULL +
+ + created_date + AB Test Created Date + datetime + When was this item created + 4.6 + + Select Date + + -- 2.25.1