CRM-17175 - Support passing of custom field value in force mode to Activity Search.
authorDave Greenberg <dave@civicrm.org>
Mon, 5 Oct 2015 17:58:23 +0000 (10:58 -0700)
committerDave Greenberg <dave@civicrm.org>
Mon, 5 Oct 2015 17:58:23 +0000 (10:58 -0700)
----------------------------------------
* CRM-17175: Enable search activity by custom fields in force mode
  https://issues.civicrm.org/jira/browse/CRM-17175

CRM/Activity/Form/Search.php

index 1836d3197eade285d80a262e6cfaef5bebc26a77..38127d39369e893f6521b3e901f76af03a8e87c3 100644 (file)
@@ -378,6 +378,22 @@ class CRM_Activity_Form_Search extends CRM_Core_Form_Search {
       $this->_formValues['activity_date_high'] = $dateHigh;
       $this->_defaults['activity_date_high'] = $dateHigh;
     }
+    
+    // Enable search activity by custom value
+    $requestParams = CRM_Utils_Request::exportValues();
+    foreach (array_keys($requestParams) as $key) {
+      if (substr($key, 0, 7) != 'custom_') {
+        continue;
+      }
+      elseif (empty($requestParams[$key])) {
+        continue;
+      }
+      $customValue = CRM_Utils_Request::retrieve($key, 'String', $this);
+      if ($customValue) {
+        $this->_formValues[$key] = $customValue;
+        $this->_defaults[$key] = $customValue;
+      }
+    }
 
     if (!empty($this->_defaults)) {
       $this->setDefaults($this->_defaults);