Merge pull request #17310 from agh1/autorenew-active-icon
[civicrm-core.git] / CRM / Member / Form / Search.php
index 1d9234f5437c10b9c46af70190642612d2a911c8..b8bb22b8be266074238cb9c78a92cda5163d8cb1 100644 (file)
@@ -80,7 +80,7 @@ class CRM_Member_Form_Search extends CRM_Core_Form_Search {
       $this->_context
     );
     $prefix = NULL;
-    if ($this->_context == 'basic') {
+    if ($this->_context === 'basic') {
       $prefix = $this->_prefix;
     }
 
@@ -177,6 +177,22 @@ class CRM_Member_Form_Search extends CRM_Core_Form_Search {
     return ts('Member Contact Type');
   }
 
+  /**
+   * Set defaults.
+   *
+   * @return array
+   * @throws \Exception
+   */
+  public function setDefaultValues() {
+    $this->_defaults = parent::setDefaultValues();
+    //LCD also allow restrictions to membership owner via GET
+    $owner = CRM_Utils_Request::retrieve('owner', 'String');
+    if (in_array($owner, ['0', '1'])) {
+      $this->_defaults['member_is_primary'] = $owner;
+    }
+    return $this->_defaults;
+  }
+
   /**
    * The post processing of the form gets done here.
    *
@@ -188,6 +204,8 @@ class CRM_Member_Form_Search extends CRM_Core_Form_Search {
    *        done.
    * The processing consists of using a Selector / Controller framework for getting the
    * search results.
+   *
+   * @throws \CRM_Core_Exception
    */
   public function postProcess() {
     if ($this->_done) {
@@ -233,7 +251,7 @@ class CRM_Member_Form_Search extends CRM_Core_Form_Search {
     $selector->setKey($this->controller->_key);
 
     $prefix = NULL;
-    if ($this->_context == 'basic') {
+    if ($this->_context === 'basic') {
       $prefix = $this->_prefix;
     }
 
@@ -246,8 +264,6 @@ class CRM_Member_Form_Search extends CRM_Core_Form_Search {
       $prefix
     );
     $controller->setEmbedded(TRUE);
-
-    $query = &$selector->getQuery();
     $controller->run();
   }
 
@@ -255,13 +271,16 @@ class CRM_Member_Form_Search extends CRM_Core_Form_Search {
    * If this search has been forced then see if there are any get values, and if so over-ride the post values.
    *
    * Note that this means that GET over-rides POST :) & that force with no parameters can be very destructive.
+   *
+   * @throws \CRM_Core_Exception
    */
   public function fixFormValues() {
     if (!$this->_force) {
       return;
     }
 
-    $status = CRM_Utils_Request::retrieve('status', 'String');
+    // @todo Most of the  below is likely no longer required.
+    $status = CRM_Utils_Request::retrieve('membership_status_id', 'String');
     if ($status) {
       $status = explode(',', $status);
       $this->_formValues['membership_status_id'] = $this->_defaults['membership_status_id'] = (array) $status;
@@ -315,12 +334,6 @@ class CRM_Member_Form_Search extends CRM_Core_Form_Search {
     $this->_limit = CRM_Utils_Request::retrieve('limit', 'Positive',
       $this
     );
-
-    //LCD also allow restrictions to membership owner via GET
-    $owner = CRM_Utils_Request::retrieve('owner', 'String');
-    if (in_array($owner, ['0', '1'])) {
-      $this->_formValues['member_is_primary'] = $this->_defaults['member_is_primary'] = $owner;
-    }
   }
 
   /**