CRM-15979 changes as suggested by totten
authoratif-shaikh <shaikh388@gmail.com>
Thu, 5 Mar 2015 11:05:08 +0000 (16:35 +0530)
committeratif-shaikh <shaikh388@gmail.com>
Thu, 5 Mar 2015 11:05:08 +0000 (16:35 +0530)
----------------------------------------
* CRM-15979: Differentiate standalone mailings from A/B test mailings
  https://issues.civicrm.org/jira/browse/CRM-15979

CRM/Mailing/BAO/MailingAB.php
CRM/Upgrade/Incremental/sql/4.6.beta2.mysql.tpl
CRM/Upgrade/Incremental/sql/4.6.beta3.mysql.tpl
api/v3/Mailing.php
js/angular-crmMailingAB/services.js

index 339fea942ce5548e20e6f21fd3f2bad6bd285557..02aff67e8843c4bd79553fd71e3cd41036058292 100644 (file)
@@ -170,7 +170,7 @@ class CRM_Mailing_BAO_MailingAB extends CRM_Mailing_DAO_MailingAB {
    * @param int $mailingID
    *   Mailing ID.
    *
-   * @return int
+   * @return object
    */
   public static function getABTest($mailingID) {
     $query = "SELECT * FROM `civicrm_mailing_abtest` ab
index f2f51394645949a461cdc3bfdf8cfccea3e138cf..6f02f6dbac242eb024816a6c068a1cf43329de00 100644 (file)
@@ -5,18 +5,4 @@ ALTER TABLE  `civicrm_membership_block` CHANGE  `membership_types`  `membership_
 -- CRM-15578 Require access CiviMail permission for A/B Testing feature
 UPDATE civicrm_navigation
 SET permission = 'access CivMail', permission_operator = ''
-WHERE name = 'New A/B Test' OR name = 'Manage A/B Tests'
-{*--CRM-15979 - differentiate between standalone mailings, A/B tests, and A/B final-winner *}
-ALTER TABLE  `civicrm_mailing` ADD mailing_type varchar(32) CHARACTER SET utf8 COLLATE utf8_unicode_ci COMMENT  'differentiate between standalone mailings, A/B tests, and A/B final-winner';
-
-UPDATE `civicrm_mailing`cm
-LEFT JOIN civicrm_mailing_abtest ab
-ON cm.id = ab.mailing_id_a
-  OR cm.id = ab.mailing_id_b
-  OR cm.id = ab.mailing_id_c
-  SET `mailing_type` = CASE
-    WHEN cm.id IN (ab.mailing_id_a,ab.mailing_id_b) THEN 'experiment'
-    WHEN cm.id IN (ab.mailing_id_c) THEN 'winner'
-    ELSE 'standalone'
-  END
-WHERE cm.id IS NOT NULL
+WHERE name = 'New A/B Test' OR name = 'Manage A/B Tests';
index c86560ea777921d0883bdb7978ea66ebe6319d14..58200164e993fbd0a5eabe6b92048d5d7dfddf3d 100644 (file)
@@ -1 +1,16 @@
 {* file to handle db changes in 4.6.beta3 during upgrade *}
+
+{*--CRM-15979 - differentiate between standalone mailings, A/B tests, and A/B final-winner *}
+ALTER TABLE  `civicrm_mailing` ADD mailing_type varchar(32) CHARACTER SET utf8 COLLATE utf8_unicode_ci COMMENT  'differentiate between standalone mailings, A/B tests, and A/B final-winner';
+
+UPDATE `civicrm_mailing`cm
+LEFT JOIN civicrm_mailing_abtest ab
+ON cm.id = ab.mailing_id_a
+  OR cm.id = ab.mailing_id_b
+  OR cm.id = ab.mailing_id_c
+  SET `mailing_type` = CASE
+    WHEN cm.id IN (ab.mailing_id_a,ab.mailing_id_b) THEN 'experiment'
+    WHEN cm.id IN (ab.mailing_id_c) THEN 'winner'
+    ELSE 'standalone'
+  END
+WHERE cm.id IS NOT NULL;
index 3656a159489226625e67b1aa02f1d4c114354a3e..a81accc03598c18b26dd1e786b18e46774a25455 100755 (executable)
@@ -64,9 +64,6 @@ function civicrm_api3_mailing_create($params) {
     $safeParams = $params;
   }
   $safeParams['_evil_bao_validator_'] = 'CRM_Mailing_BAO_Mailing::checkSendable';
-  if (empty($params['mailing_type'])) {
-    $params['mailing_type'] = 'standalone';
-  }
   return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $safeParams);
 
 }
@@ -154,7 +151,7 @@ function _civicrm_api3_mailing_create_spec(&$params) {
   $params['reply_id']['api.default'] = CRM_Mailing_PseudoConstant::defaultComponent('Reply', '');
   $params['resubscribe_id']['api.default'] = CRM_Mailing_PseudoConstant::defaultComponent('Resubscribe', '');
   $params['unsubscribe_id']['api.default'] = CRM_Mailing_PseudoConstant::defaultComponent('Unsubscribe', '');
-
+  $params['mailing_type']['api.default'] = 'standalone';
   $defaultAddress = CRM_Core_OptionGroup::values('from_email_address', NULL, NULL, NULL, ' AND is_default = 1');
   foreach ($defaultAddress as $id => $value) {
     if (preg_match('/"(.*)" <(.*)>/', $value, $match)) {
index 67345291dae4c9e624c2f57d04fb6fa39d65a0e6..bc91d6968a60aab8c11dc270e8d5e9d38592e7e2 100644 (file)
@@ -81,7 +81,7 @@
             // want to force-enable tracking.
             open_tracking: "1",
             url_tracking: "1",
-            mailing_type:"experiment",
+            mailing_type:"experiment"
           };
           crmMailingAB.mailings.a = crmMailingMgr.create(mailingDefaults);
           crmMailingAB.mailings.b = crmMailingMgr.create(mailingDefaults);