Merge branch 4.5 into 4.6
[civicrm-core.git] / CRM / Mailing / Page / Report.php
index 324a9728165e720a851d5a1302f353a30e06a179..c7a639bd7c28f706d22c4dda3fe84ef672aac924 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.5                                                |
+ | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
@@ -23,7 +23,7 @@
  | GNU Affero General Public License or the licensing of CiviCRM,     |
  | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
  +--------------------------------------------------------------------+
-*/
+ */
 
 /**
  *
@@ -41,32 +41,33 @@ class CRM_Mailing_Page_Report extends CRM_Core_Page_Basic {
   public $_mailing_id;
 
   /**
-   * Get BAO Name
+   * Get BAO Name.
    *
-   * @return string Classname of BAO
+   * @return string
+   *   Classname of BAO
    */
-  function getBAOName() {
+  public function getBAOName() {
     return 'CRM_Mailing_BAO_Mailing';
   }
 
   /**
    * @return null
    */
-  function &links() {
+  public function &links() {
     return CRM_Core_DAO::$_nullObject;
   }
 
   /**
    * @return null
    */
-  function editForm() {
+  public function editForm() {
     return NULL;
   }
 
   /**
    * @return string
    */
-  function editName() {
+  public function editName() {
     return 'CiviMail Report';
   }
 
@@ -75,9 +76,10 @@ class CRM_Mailing_Page_Report extends CRM_Core_Page_Basic {
    *
    * @param null $mode
    *
-   * @return string user context.
+   * @return string
+   *   user context.
    */
-  function userContext($mode = NULL) {
+  public function userContext($mode = NULL) {
     return 'civicrm/mailing/report';
   }
 
@@ -86,16 +88,20 @@ class CRM_Mailing_Page_Report extends CRM_Core_Page_Basic {
    *
    * @return string
    */
-  function userContextParams($mode = NULL) {
+  public function userContextParams($mode = NULL) {
     return 'reset=1&mid=' . $this->_mailing_id;
   }
 
   /**
    * @return string
    */
-  function run() {
+  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);
 
@@ -134,10 +140,10 @@ class CRM_Mailing_Page_Report extends CRM_Core_Page_Basic {
 
     $this->assign('report', $report);
     CRM_Utils_System::setTitle(ts('CiviMail Report: %1',
-        array(1 => $report['mailing']['name'])
-      ));
+      array(1 => $report['mailing']['name'])
+    ));
 
     return CRM_Core_Page::run();
   }
-}
 
+}