From e9fd1f48cbf6d1416301641e07d52aada953bcbf Mon Sep 17 00:00:00 2001 From: monishdeb Date: Fri, 6 Nov 2015 11:54:50 +0530 Subject: [PATCH] CRM-17518 fix - "IN" operator doesn't work on the contact_sub_type field for api.Contact.get https://issues.civicrm.org/jira/browse/CRM-17518 --- CRM/Contact/BAO/Query.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CRM/Contact/BAO/Query.php b/CRM/Contact/BAO/Query.php index 756a633c5f..de7b0f9ca8 100644 --- a/CRM/Contact/BAO/Query.php +++ b/CRM/Contact/BAO/Query.php @@ -2818,6 +2818,11 @@ class CRM_Contact_BAO_Query { */ public function includeContactSubTypes($value, $grouping, $op = 'LIKE') { + if (is_array($value) && in_array(key($value), CRM_Core_DAO::acceptedSQLOperators(), TRUE)) { + $op = key($value); + $value = $value[$op]; + } + $clause = array(); $alias = "contact_a.contact_sub_type"; $qillOperators = CRM_Core_SelectValues::getSearchBuilderOperators(); @@ -2832,7 +2837,7 @@ class CRM_Contact_BAO_Query { elseif (is_array($value)) { foreach ($value as $k => $v) { if (!empty($k)) { - $clause[$k] = "($alias $op '%" . CRM_Core_DAO::VALUE_SEPARATOR . CRM_Utils_Type::escape($k, 'String') . CRM_Core_DAO::VALUE_SEPARATOR . "%')"; + $clause[$k] = "($alias $op '%" . CRM_Core_DAO::VALUE_SEPARATOR . CRM_Utils_Type::escape($v, 'String') . CRM_Core_DAO::VALUE_SEPARATOR . "%')"; } } } -- 2.25.1