Merge branch 4.5 into 4.6
[civicrm-core.git] / CRM / Mailing / Page / Report.php
index 018616ad0813041133734fab3c930bbb167362d7..c7a639bd7c28f706d22c4dda3fe84ef672aac924 100644 (file)
@@ -41,7 +41,7 @@ class CRM_Mailing_Page_Report extends CRM_Core_Page_Basic {
   public $_mailing_id;
 
   /**
-   * Get BAO Name
+   * Get BAO Name.
    *
    * @return string
    *   Classname of BAO
@@ -97,7 +97,11 @@ class CRM_Mailing_Page_Report extends CRM_Core_Page_Basic {
    */
   public function run() {
     $this->_mailing_id = CRM_Utils_Request::retrieve('mid', 'Positive', $this);
-
+    //CRM-15979 - check if abtest exist for mailing then redirect accordingly
+    $abtest = CRM_Mailing_BAO_MailingAB::getABTest($this->_mailing_id);
+    if (!empty($abtest) && !empty($abtest->id)) {
+      CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/a/', NULL, TRUE, '/abtest/' . $abtest->id));
+    }
     // check that the user has permission to access mailing id
     CRM_Mailing_BAO_Mailing::checkPermission($this->_mailing_id);