CRM-10808: Campaign filter not available for Mailings in Adv Search but is on Schedul...
authoryashodha <yashodha.chaku@webaccessglobal.com>
Tue, 18 Aug 2015 13:12:59 +0000 (18:42 +0530)
committeryashodha <yashodha.chaku@webaccessglobal.com>
Tue, 18 Aug 2015 13:12:59 +0000 (18:42 +0530)
----------------------------------------
* CRM-10808: Campaign filter not available for Mailings in Adv Search but is on Scheduled Mailings etc
  https://issues.civicrm.org/jira/browse/CRM-10808

CRM/Mailing/BAO/Query.php
CRM/Mailing/Form/Schedule.php
templates/CRM/Mailing/Form/Search/Common.tpl

index 7b8e0cd0c2b1bd453d9f4fb4aa6fbe695dcc81a9..8305322a5b869843e383abf3dac7a36e16e40ad0 100644 (file)
@@ -123,6 +123,12 @@ class CRM_Mailing_BAO_Query {
         $query->_element['mailing_recipients_id'] = 1;
       }
     }
+
+    if (CRM_Utils_Array::value('mailing_campaign_id', $query->_returnProperties)) {
+      $query->_select['mailing_campaign_id'] = 'civicrm_mailing.campaign_id as mailing_campaign_id';
+      $query->_element['mailing_campaign_id'] = 1;
+      $query->_tables['civicrm_campaign'] = 1;
+    }
   }
 
   /**
@@ -207,6 +213,7 @@ class CRM_Mailing_BAO_Query {
     if ($mode & CRM_Contact_BAO_Query::MODE_MAILING) {
       $properties = array(
         'mailing_id' => 1,
+        'mailing_campaign_id' => 1,
         'mailing_name' => 1,
         'sort_name' => 1,
         'email' => 1,
@@ -375,6 +382,17 @@ class CRM_Mailing_BAO_Query {
           $query->_qill[$grouping][] = "Mailing Job Status IS \"$value\"";
         }
         return;
+
+      case 'mailing_campaign_id':
+        $campParams = array(
+          'op' => $op,
+          'campaign' => $value,
+          'grouping' => $grouping,
+          'tableName' => 'civicrm_mailing',
+        );
+        CRM_Campaign_BAO_Query::componentSearchClause($campParams, $query);
+        $query->_tables['civicrm_mailing_recipients'] = $query->_whereTables['civicrm_mailing_recipients'] = 1;
+        return;
     }
   }
 
@@ -423,6 +441,9 @@ class CRM_Mailing_BAO_Query {
     $form->add('checkbox', 'mailing_unsubscribe', ts('Unsubscribe Requests'));
     $form->add('checkbox', 'mailing_optout', ts('Opt-out Requests'));
     $form->add('checkbox', 'mailing_forward', ts('Forwards'));
+    
+    // Campaign select field
+    CRM_Campaign_BAO_Campaign::addCampaignInComponentSearch($form, 'mailing_campaign_id');
 
     $form->assign('validCiviMailing', TRUE);
   }
index bed7590956f42172b91837427e723d8950c88c9c..5d83daa6741d14a1c64ac01fc170bff518ffa728 100644 (file)
@@ -279,6 +279,8 @@ class CRM_Mailing_Form_Schedule extends CRM_Core_Form {
       $params[$parameter] = $this->controller->exportValue($this->_name, $parameter);
     }
 
+    dpm($this->controller->exportValues(), 'values');
+
     // Previously, we checked if $mailing->is_template, and did *not*
     // schedule if it was set. Discussed with Lobo, removed that check
     // as it appeared to prevent mails being scheduled if they were
index cb24ac6180159b8a0da94ee4464a609e1dc0bd66..a309a36c1bb8cf0c85a76c24720f33573a2cbde4 100644 (file)
@@ -65,3 +65,9 @@
     </table>
   </td>
 </tr>
+<tr>
+  <td>{* campaign in Advance search *}
+      {include file="CRM/Campaign/Form/addCampaignToComponent.tpl" campaignContext="componentSearch"
+       campaignTrClass='crmCampaign' campaignTdClass='crmCampaignContainer'}
+  </td>
+</tr>