From f7478d23d979c543c0687d681c226287e0ab0cca Mon Sep 17 00:00:00 2001 From: kurund Date: Thu, 1 May 2014 15:46:17 -0700 Subject: [PATCH] clean and fixes for CRM-14563 ---------------------------------------- * CRM-14563: Search builder IN operator on a custom field https://issues.civicrm.org/jira/browse/CRM-14563 --- CRM/Core/BAO/Mapping.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/CRM/Core/BAO/Mapping.php b/CRM/Core/BAO/Mapping.php index a9b5c9a991..b992cb8431 100644 --- a/CRM/Core/BAO/Mapping.php +++ b/CRM/Core/BAO/Mapping.php @@ -1020,6 +1020,29 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping { } } + // CRM-14563: we store checkbox, multi-select and adv-multi select custom field using separator, hence it + // needs special handling. + if ($cfID = CRM_Core_BAO_CustomField::getKeyID($v[1])) { + $customFieldType = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomField', $cfID, 'html_type'); + $specialHTMLType = array( + 'CheckBox', + 'Multi-Select', + 'AdvMulti-Select', + 'Multi-Select State/Province', + 'Multi-Select Country' + ); + + // override the operator to handle separator ( note: this might have some performance issues ) + if (in_array($customFieldType, $specialHTMLType)) { + // FIX ME: != and few other operators are not handled + $specialOperators = array('=', 'IN', 'LIKE'); + + if (in_array($params['operator'][$key][$k], $specialOperators)) { + $params['operator'][$key][$k] = 'RLIKE'; + } + } + } + if ($row) { $fields[] = array( $fldName, -- 2.25.1