diff --git a/CRM/Activity/BAO/Query.php b/CRM/Activity/BAO/Query.php index 3f2758b83836..d9397a5cd9b6 100644 --- a/CRM/Activity/BAO/Query.php +++ b/CRM/Activity/BAO/Query.php @@ -457,6 +457,9 @@ public static function getSearchFieldMetadata() { 'title' => ts('Activity Text'), 'type' => CRM_Utils_Type::T_STRING, 'is_pseudofield' => TRUE, + 'html' => [ + 'type' => 'Text', + ], ]; return $metadata; } diff --git a/CRM/Activity/Form/Search.php b/CRM/Activity/Form/Search.php index 5724ba411958..7239fca7fb64 100644 --- a/CRM/Activity/Form/Search.php +++ b/CRM/Activity/Form/Search.php @@ -39,13 +39,13 @@ class CRM_Activity_Form_Search extends CRM_Core_Form_Search { * * @var bool */ - protected $_limit = NULL; + protected $_limit; /** * Prefix for the controller. * @var string */ - protected $_prefix = "activity_"; + protected $_prefix = 'activity_'; /** * The saved search ID retrieved from the GET vars. @@ -63,6 +63,9 @@ public function getDefaultEntity() { /** * Processing needed for buildForm and later. + * + * @throws \CRM_Core_Exception + * @throws \CiviCRM_API3_Exception */ public function preProcess() { $this->set('searchFormName', 'Search'); @@ -73,25 +76,7 @@ public function preProcess() { $this->_done = FALSE; - $this->loadStandardSearchOptionsFromUrl(); - - // get user submitted values - // get it from controller only if form has been submitted, else preProcess has set this - if (!empty($_POST) && !$this->controller->isModal()) { - $this->_formValues = $this->controller->exportValues($this->_name); - } - else { - $this->_formValues = $this->get('formValues'); - - if ($this->_force) { - // If we force the search then merge form values with url values - // and set submit values to form values. - // @todo this is not good security practice. Instead define the fields in metadata & use - // getEntityDefaults. - $this->_formValues = array_merge((array) $this->_formValues, CRM_Utils_Request::exportValues()); - $this->_submitValues = $this->_formValues; - } - } + parent::preProcess(); if (empty($this->_formValues)) { if (isset($this->_ssID)) { @@ -99,11 +84,6 @@ public function preProcess() { } } - if ($this->_force) { - $this->postProcess(); - $this->set('force', 0); - } - $sortID = NULL; if ($this->get(CRM_Utils_Sort::SORT_ID)) { $sortID = CRM_Utils_Sort::sortIDValue($this->get(CRM_Utils_Sort::SORT_ID), @@ -143,6 +123,9 @@ public function preProcess() { /** * Build the form object. + * + * @throws \CRM_Core_Exception + * @throws \CiviCRM_API3_Exception */ public function buildQuickForm() { parent::buildQuickForm(); @@ -210,7 +193,6 @@ public function postProcess() { $this->_queryParams = CRM_Contact_BAO_Query::convertFormValues($this->_formValues); - $this->set('formValues', $this->_formValues); $this->set('queryParams', $this->_queryParams); $buttonName = $this->controller->getButtonName(); @@ -242,7 +224,7 @@ public function postProcess() { $selector->setKey($this->controller->_key); $prefix = NULL; - if ($this->_context == 'basic' || $this->_context == 'user') { + if ($this->_context === 'basic' || $this->_context === 'user') { $prefix = $this->_prefix; } @@ -257,12 +239,17 @@ public function postProcess() { $controller->setEmbedded(TRUE); $query = &$selector->getQuery(); - if ($this->_context == 'user') { + if ($this->_context === 'user') { $query->setSkipPermission(TRUE); } $controller->run(); } + /** + * Probably more hackery than anything else. + * + * @throws \CRM_Core_Exception + */ public function fixFormValues() { if (!$this->_force) { return; @@ -337,6 +324,13 @@ public function getTitle() { return ts('Find Activities'); } + /** + * Get metadata for the entity fields. + * + * @return array + * + * @throws \CiviCRM_API3_Exception + */ protected function getEntityMetadata() { return CRM_Activity_BAO_Query::getSearchFieldMetadata(); }