Merge pull request #8615 from bsilvern/crm-18805
[civicrm-core.git] / CRM / Report / Form / Mailing / Summary.php
index 2b11ca592cbfc7787eb5e314aca205ca03ab6d5f..2706d4721dd635618d3b2e1e029f3230a0330824 100644 (file)
@@ -3,7 +3,7 @@
  +--------------------------------------------------------------------+
  | CiviCRM version 4.7                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2015                                |
+ | Copyright CiviCRM LLC (c) 2004-2016                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -28,7 +28,7 @@
 /**
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2015
+ * @copyright CiviCRM LLC (c) 2004-2016
  * $Id$
  *
  */
@@ -258,6 +258,17 @@ class CRM_Report_Form_Mailing_Summary extends CRM_Report_Form {
         ),
       ),
     );
+    $this->_columns['civicrm_mailing_group'] = array(
+      'dao' => 'CRM_Mailing_DAO_MailingGroup',
+      'filters' => array(
+        'entity_id' => array(
+          'title' => ts('Groups Included in Mailing'),
+          'operatorType' => CRM_Report_Form::OP_MULTISELECT,
+          'type' => CRM_Utils_Type::T_INT,
+          'options' => CRM_Core_PseudoConstant::group(),
+        ),
+      ),
+    );
     $config = CRM_Core_Config::singleton();
     $this->campaignEnabled = in_array("CiviCampaign", $config->enableComponents);
     if ($this->campaignEnabled) {
@@ -377,6 +388,11 @@ class CRM_Report_Form_Mailing_Summary extends CRM_Report_Form {
       LEFT JOIN civicrm_mailing_event_unsubscribe mailing_event_optout_civireport
         ON mailing_event_optout_civireport.event_queue_id = {$this->_aliases['civicrm_mailing_event_queue']}.id AND mailing_event_optout_civireport.org_unsubscribe = 1";
 
+    if ($this->isTableSelected('civicrm_mailing_group')) {
+      $this->_from .= "
+        LEFT JOIN civicrm_mailing_group {$this->_aliases['civicrm_mailing_group']}
+         ON {$this->_aliases['civicrm_mailing_group']}.mailing_id = {$this->_aliases['civicrm_mailing']}.id";
+    }
     if ($this->campaignEnabled) {
       $this->_from .= "
         LEFT JOIN civicrm_campaign {$this->_aliases['civicrm_campaign']}