Merge pull request #15617 from eileenmcnaughton/even_clen
[civicrm-core.git] / CRM / Contact / Form / Search.php
index a9d929a48d55b19637a56f54af68c492d01ee377..a225db12254f19d231da25f4858ffce7a8248ee2 100644 (file)
@@ -302,7 +302,8 @@ class CRM_Contact_Form_Search extends CRM_Core_Form_Search {
     }
 
     self::setModeValues();
-    if (!array_key_exists($mode, self::$_modeValues)) {
+    // Note $mode might === FALSE because array_search above failed, e.g. for searchPane='location'
+    if (empty(self::$_modeValues[$mode])) {
       $mode = CRM_Contact_BAO_Query::MODE_CONTACTS;
     }
 
@@ -652,6 +653,9 @@ class CRM_Contact_Form_Search extends CRM_Core_Form_Search {
           'mailing_unsubscribe',
           'mailing_date_low',
           'mailing_date_high',
+          'mailing_job_start_date_low',
+          'mailing_job_start_date_high',
+          'mailing_job_start_date_relative',
         ] as $mailingFilter) {
           $type = 'String';
           if ($mailingFilter == 'mailing_id' &&
@@ -731,7 +735,7 @@ class CRM_Contact_Form_Search extends CRM_Core_Form_Search {
     $controller->setDynamicAction($setDynamic);
 
     if ($this->_force) {
-
+      $this->loadMetadata();
       $this->postProcess();
 
       /*
@@ -757,13 +761,6 @@ class CRM_Contact_Form_Search extends CRM_Core_Form_Search {
     $controller->moveFromSessionToTemplate();
   }
 
-  /**
-   * @return array
-   */
-  public function &getFormValues() {
-    return $this->_formValues;
-  }
-
   /**
    * Common post processing.
    */
@@ -909,4 +906,16 @@ class CRM_Contact_Form_Search extends CRM_Core_Form_Search {
     return ts('Search');
   }
 
+  /**
+   * Load metadata for fields on the form.
+   *
+   * @throws \CiviCRM_API3_Exception
+   */
+  protected function loadMetadata() {
+    // @todo - check what happens if the person does not have 'access civicontribute' - make sure they
+    // can't by pass acls by passing search criteria in the url.
+    $this->addSearchFieldMetadata(['Contribution' => CRM_Contribute_BAO_Query::getSearchFieldMetadata()]);
+    $this->addSearchFieldMetadata(['ContributionRecur' => CRM_Contribute_BAO_ContributionRecur::getContributionRecurSearchFieldMetadata()]);
+  }
+
 }