$this->_formValues["activity_test"] = 0;
}
- CRM_Core_BAO_CustomValue::fixFieldValueOfTypeMemo($this->_formValues);
+ CRM_Core_BAO_CustomValue::fixCustomFieldValue($this->_formValues);
$this->_queryParams = CRM_Contact_BAO_Query::convertFormValues($this->_formValues);
if (empty($this->_formValues['case_deleted'])) {
$this->_formValues['case_deleted'] = 0;
}
- CRM_Core_BAO_CustomValue::fixFieldValueOfTypeMemo($this->_formValues);
+ CRM_Core_BAO_CustomValue::fixCustomFieldValue($this->_formValues);
$this->_queryParams = CRM_Contact_BAO_Query::convertFormValues($this->_formValues);
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
-s | under the terms of the GNU Affero General Public License |
+ | under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| CiviCRM is distributed in the hope that it will be useful, but |
$this->_sortByCharacter = NULL;
}
- CRM_Core_BAO_CustomValue::fixFieldValueOfTypeMemo($this->_formValues);
+ CRM_Core_BAO_CustomValue::fixCustomFieldValue($this->_formValues);
$this->_params = CRM_Contact_BAO_Query::convertFormValues($this->_formValues);
$this->_returnProperties = &$this->returnProperties();
'status_id',
'activity_subject',
);
- $specialParams += preg_grep('/^custom_/', array_keys($this->_formValues));
foreach ($specialParams as $element) {
$value = CRM_Utils_Array::value($element, $this->_formValues);
if ($value) {
}
if ($this->_ssID && empty($_POST)) {
- $fields = array('contact_type', 'group', 'contact_tags');
+ $specialFields = array('contact_type', 'group', 'contact_tags');
- foreach ($fields as $field) {
- $fieldValues = CRM_Utils_Array::value($field, $defaults);
- if ($fieldValues && is_array($fieldValues)) {
- $defaults[$field] = array_keys($fieldValues);
+ foreach ($defaults as $element => $value) {
+ if (!empty($value) && is_array($value)) {
+ if (in_array($element, $specialFields)) {
+ $defaults[$element] = array_keys($value);
+ }
+ // As per the OK (Operator as Key) value format, value array may contain key
+ // as an operator so to ensure the default is always set actual value
+ elseif (in_array(key($value), CRM_Core_DAO::acceptedSQLOperators(), TRUE)) {
+ $defaults[$element] = CRM_Utils_Array::value(key($value), $value);
+ if (is_string($defaults[$element])) {
+ $defaults[$element] = str_replace("%", '', $defaults[$element]);
+ }
+ }
}
}
}
);
}
- $this->_queryParams = CRM_Contact_BAO_Query::convertFormValues($this->_formValues, 1);
+ $this->_queryParams = CRM_Contact_BAO_Query::convertFormValues($this->_formValues);
$selector = new CRM_Contribute_Selector_Search($this->_queryParams,
$this->_action,
NULL,
}
}
- CRM_Core_BAO_CustomValue::fixFieldValueOfTypeMemo($this->_formValues);
+ CRM_Core_BAO_CustomValue::fixCustomFieldValue($this->_formValues);
$this->_queryParams = CRM_Contact_BAO_Query::convertFormValues($this->_formValues);
}
$v = array();
- $p = array();
foreach ($checkedData as $key => $val) {
- if ($html_type == 'CheckBox') {
- if ($val) {
- $p[] = $key;
- $v[] = CRM_Utils_Array::value($key, $option);
- }
- }
- else {
- $p[] = $val;
- $v[] = CRM_Utils_Array::value($val, $option);
- }
+ $v[] = CRM_Utils_Array::value($val, $option);
}
if (!empty($v)) {
$display = implode(', ', $v);
$op = key($value);
$qillValue = CRM_Core_BAO_CustomField::getDisplayValue($value[$op], $id, $this->_options);
}
+ else {
+ $qillValue = CRM_Core_BAO_CustomField::getDisplayValue($value, $id, $this->_options);
+ $value = array('IN' => $value);
+ }
$qillOp = CRM_Utils_Array::value($op, CRM_Core_SelectValues::getSearchBuilderOperators(), $op);
if (!is_array($value)) {
$value = CRM_Utils_Type::escape($strtolower($value), 'String');
}
- elseif ($isSerialized && strstr($op, 'IN')) {
+ elseif ($isSerialized) {
+ if (in_array(key($value), CRM_Core_DAO::acceptedSQLOperators(), TRUE)) {
+ $op = key($value);
+ $value = $value[$op];
+ }
$value = implode(',', $value);
}
// CRM-14563,CRM-16575 : Special handling of multi-select custom fields
- if (!empty($value)) {
- if ($isSerialized) {
- if (strstr($op, 'IN')) {
- $value = str_replace(array('(', ')'), '', str_replace(",", "[[:cntrl:]]|[[:cntrl:]]", $value));
- }
- $op = (strstr($op, '!') || strstr($op, 'NOT')) ? 'NOT RLIKE' : 'RLIKE';
- $value = "[[:cntrl:]]" . $value . "[[:cntrl:]]";
+ if ($isSerialized && !empty($value)) {
+ if (strstr($op, 'IN')) {
+ $value = str_replace(array('(', ')'), '', str_replace(",", "[[:cntrl:]]|[[:cntrl:]]", $value));
}
- elseif ($wildcard) {
- $value = "[[:cntrl:]]%$value%[[:cntrl:]]";
- $op = 'LIKE';
+ $op = (strstr($op, '!') || strstr($op, 'NOT')) ? 'NOT RLIKE' : 'RLIKE';
+ $value = "[[:cntrl:]]" . $value . "[[:cntrl:]]";
+ if (!$wildcard) {
+ $value = str_replace("[[:cntrl:]]|", '', $value);
}
}
* @param array $formValues
* @return null
*/
- public static function fixFieldValueOfTypeMemo(&$formValues) {
+ public static function fixCustomFieldValue(&$formValues) {
if (empty($formValues)) {
return NULL;
}
$htmlType = CRM_Core_DAO::getFieldValue('CRM_Core_BAO_CustomField',
substr($key, 7), 'html_type'
);
- if (($htmlType == 'TextArea') &&
+ $dataType = CRM_Core_DAO::getFieldValue('CRM_Core_BAO_CustomField',
+ substr($key, 7), 'data_type'
+ );
+
+ if (is_array($formValues[$key])) {
+ if (!in_array(key($formValues[$key]), CRM_Core_DAO::acceptedSQLOperators(), TRUE)) {
+ $formValues[$key] = array('IN' => $formValues[$key]);
+ }
+ }
+ elseif (($htmlType == 'TextArea' ||
+ ($htmlType == 'Text' && $dataType == 'String')
+ ) &&
!((substr($formValues[$key], 0, 1) == '%') ||
(substr($formValues[$key], -1, 1) == '%')
)
) {
- $formValues[$key] = '%' . $formValues[$key] . '%';
+ $formValues[$key] = array('LIKE' => '%' . $formValues[$key] . '%');
}
-
}
}
$this->_formValues["participant_test"] = 0;
}
- CRM_Core_BAO_CustomValue::fixFieldValueOfTypeMemo($this->_formValues);
+ CRM_Core_BAO_CustomValue::fixCustomFieldValue($this->_formValues);
$this->_queryParams = CRM_Contact_BAO_Query::convertFormValues($this->_formValues);
}
}
- CRM_Core_BAO_CustomValue::fixFieldValueOfTypeMemo($this->_formValues);
+ CRM_Core_BAO_CustomValue::fixCustomFieldValue($this->_formValues);
$this->_queryParams = CRM_Contact_BAO_Query::convertFormValues($this->_formValues);
$this->_formValues = CRM_Contact_BAO_SavedSearch::getFormValues($this->_ssID);
}
- CRM_Core_BAO_CustomValue::fixFieldValueOfTypeMemo($this->_formValues);
+ CRM_Core_BAO_CustomValue::fixCustomFieldValue($this->_formValues);
$this->_queryParams = CRM_Contact_BAO_Query::convertFormValues($this->_formValues);