From 11ac6a2b9911b768cd1322db2d6ad20cd894ae9f Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Fri, 22 Nov 2019 07:40:39 +1100 Subject: [PATCH] dev/core#1410 Fix E-notice when doin a force case search with a predefined case subject field --- CRM/Case/BAO/Query.php | 7 +++---- CRM/Case/Form/Search.php | 44 ++++++---------------------------------- 2 files changed, 9 insertions(+), 42 deletions(-) diff --git a/CRM/Case/BAO/Query.php b/CRM/Case/BAO/Query.php index 0e18cf5927..078679588c 100644 --- a/CRM/Case/BAO/Query.php +++ b/CRM/Case/BAO/Query.php @@ -252,6 +252,8 @@ class CRM_Case_BAO_Query extends CRM_Core_BAO_Query { return; } list($name, $op, $value, $grouping, $wildcard) = $values; + $fields = CRM_Case_BAO_Case::fields(); + $fieldSpec = $fields[$values[0]] ?? []; $val = $names = []; switch ($name) { @@ -315,10 +317,7 @@ class CRM_Case_BAO_Query extends CRM_Core_BAO_Query { return; case 'case_subject': - $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("civicrm_case.subject", $op, $value, 'String'); - $query->_qill[$grouping][] = CRM_Contact_BAO_Query::getQillValue('CRM_Case_DAO_Case', $name, $value, $op, 'Case Subject'); - $query->_tables['civicrm_case'] = $query->_whereTables['civicrm_case'] = 1; - $query->_tables['civicrm_case_contact'] = $query->_whereTables['civicrm_case_contact'] = 1; + $query->handleWhereFromMetadata($fieldSpec, $name, $value, $op); return; case 'case_source_contact_id': diff --git a/CRM/Case/Form/Search.php b/CRM/Case/Form/Search.php index e1b31328dc..ffad397c9f 100644 --- a/CRM/Case/Form/Search.php +++ b/CRM/Case/Form/Search.php @@ -80,12 +80,7 @@ class CRM_Case_Form_Search extends CRM_Core_Form_Search { $this->_done = FALSE; - $this->loadStandardSearchOptionsFromUrl(); - $this->loadFormValues(); - - if ($this->_force) { - $this->handleForcedSearch(); - } + parent::preProcess(); $this->_queryParams = CRM_Contact_BAO_Query::convertFormValues($this->_formValues); $selector = new CRM_Case_Selector_Search($this->_queryParams, @@ -188,6 +183,7 @@ class CRM_Case_Form_Search extends CRM_Core_Form_Search { $this->_done = TRUE; $this->setFormValues(); + // @todo - stop changing formValues - respect submitted form values, change a working array. $this->fixFormValues(); if (isset($this->_ssID) && empty($_POST)) { // if we are editing / running a saved search and the form has not been posted @@ -196,19 +192,22 @@ class CRM_Case_Form_Search extends CRM_Core_Form_Search { //search for civicase if (!$this->_force) { + // @todo - stop changing formValues - respect submitted form values, change a working array. if (array_key_exists('case_owner', $this->_formValues) && !$this->_formValues['case_owner']) { $this->_formValues['case_owner'] = 0; } } + // @todo - stop changing formValues - respect submitted form values, change a working array. if (empty($this->_formValues['case_deleted'])) { $this->_formValues['case_deleted'] = 0; } + // @todo - stop changing formValues - respect submitted form values, change a working array. CRM_Core_BAO_CustomValue::fixCustomFieldValue($this->_formValues); + // @todo - stop changing formValues - respect submitted form values, change a working array. $this->_queryParams = CRM_Contact_BAO_Query::convertFormValues($this->_formValues); - $this->set('formValues', $this->_formValues); $this->set('queryParams', $this->_queryParams); $buttonName = $this->controller->getButtonName(); @@ -258,37 +257,6 @@ class CRM_Case_Form_Search extends CRM_Core_Form_Search { $controller->run(); } - /** - * Add the rules (mainly global rules) for form. - * - * All local rules are added near the element - * - * @see valid_date - */ - public function addRules() { - $this->addFormRule(['CRM_Case_Form_Search', 'formRule']); - } - - /** - * Global validation rules for the form. - * - * @param array $fields - * Posted values of the form. - * @param array $files - * @param object $form - * - * @return array|bool - */ - public static function formRule($fields, $files, $form) { - $errors = []; - - if (!empty($errors)) { - return $errors; - } - - return TRUE; - } - public function fixFormValues() { if (!$this->_force) { return; -- 2.25.1