CRM-15970 - Add MailingAB fields, "created_id" and "created_date"
authorTim Otten <totten@civicrm.org>
Mon, 16 Feb 2015 21:33:12 +0000 (13:33 -0800)
committerTim Otten <totten@civicrm.org>
Wed, 18 Feb 2015 03:13:13 +0000 (19:13 -0800)
CRM/Upgrade/Incremental/sql/4.6.alpha7.mysql.tpl
api/v3/MailingAB.php
tests/phpunit/api/v3/MailingABTest.php
xml/schema/Mailing/MailingAB.xml

index d27ff06717d63cb00435cc7b839860160e68499a..3109a258861a444fafbc299db334e8bcc8f992ae 100644 (file)
@@ -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;
index 937de0e63000ce91bd649e76b5c9f2c1744ce5d3..4328ec7db7ae1198f7376ab2e83600f7e449b829 100755 (executable)
  * @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.
  *
index b7602f2750fb87fc50c6ebdc073e46dd54b5534e..e317b60e47cf16bc0b394113d95e09a8e79beb63 100755 (executable)
@@ -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();
index 671c9c1d1438d2b87a082c2ad2c74e7bcf0270db..e965535603aaeabb3e2171da40048e103c2c3cf3 100644 (file)
     <title>Group Percentage</title>
     <add>4.6</add>
   </field>
-
+  <field>
+    <name>created_id</name>
+    <title>AB Test Created By</title>
+    <type>int unsigned</type>
+    <comment>FK to Contact ID</comment>
+    <add>4.6</add>
+  </field>
+  <foreignKey>
+    <name>created_id</name>
+    <table>civicrm_contact</table>
+    <key>id</key>
+    <add>4.6</add>
+    <onDelete>SET NULL</onDelete>
+  </foreignKey>
+  <field>
+    <name>created_date</name>
+    <title>AB Test Created Date</title>
+    <type>datetime</type>
+    <comment>When was this item created</comment>
+    <add>4.6</add>
+    <html>
+      <type>Select Date</type>
+    </html>
+  </field>
 </table>