From: monishdeb Date: Tue, 4 Aug 2015 14:48:31 +0000 (+0530) Subject: CRM-16961 fix - 4.6.5 search regression on custom fields where option values have... X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=fccb6a0f687573f5a2216cce6e845eb9b49f176d;p=civicrm-core.git CRM-16961 fix - 4.6.5 search regression on custom fields where option values have brackets https://issues.civicrm.org/jira/browse/CRM-16961 --- diff --git a/CRM/Contact/Form/Search/Builder.php b/CRM/Contact/Form/Search/Builder.php index 033114b650..7a702587be 100644 --- a/CRM/Contact/Form/Search/Builder.php +++ b/CRM/Contact/Form/Search/Builder.php @@ -255,12 +255,12 @@ class CRM_Contact_Form_Search_Builder extends CRM_Contact_Form_Search { $inVal = trim($v[2]); //checking for format to avoid db errors if ($type == 'Int') { - if (!preg_match('/^[(]([A-Za-z0-9\,]+)[)]$/', $inVal)) { + if (!preg_match('/^[A-Za-z0-9\,]+$/', $inVal)) { $errorMsg["value[$v[3]][$v[4]]"] = ts("Please enter correct Data (in valid format)."); } } else { - if (!(substr($inVal, 0, 1) == '(' && substr($inVal, -1, 1) == ')') && !preg_match('/^[(]([A-Za-z0-9åäöÅÄÖüÜœŒæÆøØ\,\s]+)[)]$/', $inVal)) { + if (!preg_match('/^[A-Za-z0-9åäöÅÄÖüÜœŒæÆøØ()\,\s]+$/', $inVal)) { $errorMsg["value[$v[3]][$v[4]]"] = ts("Please enter correct Data (in valid format)."); } } diff --git a/CRM/Core/BAO/CustomField.php b/CRM/Core/BAO/CustomField.php index dd5529d470..e2dbf50ce4 100644 --- a/CRM/Core/BAO/CustomField.php +++ b/CRM/Core/BAO/CustomField.php @@ -1233,7 +1233,8 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField { if ($html_type == 'CheckBox') { $newData = array(); foreach ($checkedData as $v) { - $newData[$v] = 1; + $v = str_replace(CRM_Core_DAO::VALUE_SEPARATOR, '', $v); + $newData[] = $v; } $checkedData = $newData; } diff --git a/CRM/Core/BAO/CustomQuery.php b/CRM/Core/BAO/CustomQuery.php index 37b00ab57c..7514a13573 100644 --- a/CRM/Core/BAO/CustomQuery.php +++ b/CRM/Core/BAO/CustomQuery.php @@ -424,12 +424,12 @@ SELECT label, value // CRM-14563,CRM-16575 : Special handling of multi-select custom fields if ($isSerialized && !empty($value)) { if (strstr($op, 'IN')) { - $value = str_replace(array('(', ')'), '', str_replace(",", "[[:cntrl:]]|[[:cntrl:]]", $value)); + $value = str_replace(",", "[[:cntrl:]]*|[[:cntrl:]]*", $value); } $op = (strstr($op, '!') || strstr($op, 'NOT')) ? 'NOT RLIKE' : 'RLIKE'; - $value = "[[:cntrl:]]" . $value . "[[:cntrl:]]"; + $value = "[[:cntrl:]]*" . $value . "[[:cntrl:]]*"; if (!$wildcard) { - $value = str_replace("[[:cntrl:]]|", '', $value); + $value = str_replace("[[:cntrl:]]*|", '', $value); } } diff --git a/CRM/Core/BAO/Mapping.php b/CRM/Core/BAO/Mapping.php index 607fabf8c8..17a6924536 100644 --- a/CRM/Core/BAO/Mapping.php +++ b/CRM/Core/BAO/Mapping.php @@ -1018,8 +1018,6 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping { $value = $params['value'][$key][$k]; if ($fldName == 'group' || $fldName == 'tag') { $value = trim($value); - $value = str_replace('(', '', $value); - $value = str_replace(')', '', $value); $v = explode(',', $value); $value = array(); @@ -1037,8 +1035,8 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping { } // CRM-14983: verify if values are comma separated convert to array - if (!is_array($value) && (strpos($value, ',') !== FALSE || strstr($value, '(')) && substr($fldName, 0, 7) != 'custom_' && $params['operator'][$key][$k] == 'IN') { - $value = explode(',', trim($value, "(..)")); + if (!is_array($value) && strstr($params['operator'][$key][$k], 'IN')) { + $value = explode(',', $value); $value = array($params['operator'][$key][$k] => $value); } diff --git a/templates/CRM/Contact/Form/Search/Builder.js b/templates/CRM/Contact/Form/Search/Builder.js index 4a0da51621..af058944f9 100644 --- a/templates/CRM/Contact/Form/Search/Builder.js +++ b/templates/CRM/Contact/Form/Search/Builder.js @@ -234,7 +234,7 @@ .on('change', '.crm-search-value select', function() { var value = $(this).val() || ''; if ($(this).attr('multiple') == 'multiple' && value.length) { - value = '(' + value.join(',') + ')'; + value = value.join(','); } $(this).siblings('input').val(value); })