return;
}
list($name, $op, $value, $grouping, $wildcard) = $values;
+ $fields = CRM_Case_BAO_Case::fields();
+ $fieldSpec = $fields[$values[0]] ?? [];
$val = $names = [];
switch ($name) {
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':
$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,
$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
//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();
$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;