Merge pull request #6293 from JoeMurray/patch-1
[civicrm-core.git] / CRM / Member / Form / Search.php
index 26a1cddde3bdca1b95ddb9bdd13b6d110e99e549..4d7129a98827cd3a1256be0f7edcda46d80dfc4c 100644 (file)
@@ -3,7 +3,7 @@
  +--------------------------------------------------------------------+
  | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2014                                |
+ | Copyright CiviCRM LLC (c) 2004-2015                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -28,7 +28,7 @@
 /**
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2014
+ * @copyright CiviCRM LLC (c) 2004-2015
  * $Id$
  *
  */
 class CRM_Member_Form_Search extends CRM_Core_Form_Search {
 
   /**
-   * The params that are sent to the query
+   * The params that are sent to the query.
    *
    * @var array
    */
   protected $_queryParams;
 
   /**
-   * Are we restricting ourselves to a single contact
+   * Are we restricting ourselves to a single contact.
    *
    * @var boolean
    */
   protected $_single = FALSE;
 
   /**
-   * Are we restricting ourselves to a single contact
+   * Are we restricting ourselves to a single contact.
    *
    * @var boolean
    */
   protected $_limit = NULL;
 
-  protected $_defaults;
-
   /**
-   * Prefix for the controller
+   * Prefix for the controller.
    */
   protected $_prefix = "member_";
 
   /**
-   * Processing needed for buildForm and later
+   * Processing needed for buildForm and later.
    *
    * @return void
    */
@@ -153,7 +151,7 @@ class CRM_Member_Form_Search extends CRM_Core_Form_Search {
   }
 
   /**
-   * Build the form object
+   * Build the form object.
    *
    *
    * @return void
@@ -209,7 +207,18 @@ class CRM_Member_Form_Search extends CRM_Core_Form_Search {
       $this->_formValues["member_test"] = 0;
     }
 
-    CRM_Core_BAO_CustomValue::fixFieldValueOfTypeMemo($this->_formValues);
+    $specialParams = array(
+      'membership_status_id',
+      'membership_type_id',
+    );
+    foreach ($specialParams as $element) {
+      $value = CRM_Utils_Array::value($element, $this->_formValues);
+      if (!empty($value) && is_array($value)) {
+        $this->_formValues[$element] = array('IN' => $value);
+      }
+    }
+
+    CRM_Core_BAO_CustomValue::fixCustomFieldValue($this->_formValues);
 
     $this->_queryParams = CRM_Contact_BAO_Query::convertFormValues($this->_formValues);
 
@@ -282,12 +291,7 @@ class CRM_Member_Form_Search extends CRM_Core_Form_Search {
     );
     if ($status) {
       $status = explode(',', $status);
-      $tempStatus = array();
-      foreach ($status as $value) {
-        $tempStatus[$value] = 1;
-      }
-      $this->_formValues['member_status_id'] = $tempStatus;
-      $this->_defaults['member_status_id'] = $tempStatus;
+      $this->_formValues['status_id'] = $this->_defaults['status_id'] = (array) $status;
     }
 
     $membershipType = CRM_Utils_Request::retrieve('type', 'String',
@@ -295,8 +299,8 @@ class CRM_Member_Form_Search extends CRM_Core_Form_Search {
     );
 
     if ($membershipType) {
-      $this->_formValues['member_membership_type_id'] = array($membershipType => 1);
-      $this->_defaults['member_membership_type_id'] = array($membershipType => 1);
+      $this->_formValues['membership_type_id'] = array($membershipType);
+      $this->_defaults['membership_type_id'] = array($membershipType);
     }
 
     $cid = CRM_Utils_Request::retrieve('cid', 'Positive',