From 4b20f7df2a727ef49e1994cbc843036c2d8fea94 Mon Sep 17 00:00:00 2001 From: Pratik Joshi <pratik.joshi@webaccess.co.in> Date: Mon, 30 Dec 2013 18:05:45 +0530 Subject: [PATCH] CRM-14010 fix : some operators handling was missing for prefered method where clause logic --- CRM/Contact/BAO/Query.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/CRM/Contact/BAO/Query.php b/CRM/Contact/BAO/Query.php index 6b981e6f41..22297656bc 100644 --- a/CRM/Contact/BAO/Query.php +++ b/CRM/Contact/BAO/Query.php @@ -3744,7 +3744,10 @@ WHERE id IN ( $groupIDs ) list($name, $op, $value, $grouping, $wildcard) = $values; $pref = array(); - if (!is_array($value)) { + if (in_array($op, array( 'IS NULL', 'IS NOT NULL', 'IS EMPTY', 'IS NOT EMPTY'))) { + $value = NULL; + } + elseif (!is_array($value)) { $v = array(); $value = trim($value, ' ()'); if (strpos($value, CRM_Core_DAO::VALUE_SEPARATOR) !== FALSE) { @@ -3771,10 +3774,16 @@ WHERE id IN ( $groupIDs ) $commPref = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'preferred_communication_method'); $sqlValue = array(); + $showValue = array(); $sql = "contact_a.preferred_communication_method"; - foreach ($pref as $val) { - $sqlValue[] = "( $sql like '%" . CRM_Core_DAO::VALUE_SEPARATOR . $val . CRM_Core_DAO::VALUE_SEPARATOR . "%' ) "; - $showValue[] = $commPref[$val]; + if (in_array($op, array('IS NULL', 'IS NOT NULL', 'IS EMPTY', 'IS NOT EMPTY'))) { + $sqlValue[] = "{$sql} {$op}"; + } + else { + foreach ($pref as $val) { + $sqlValue[] = "( $sql like '%" . CRM_Core_DAO::VALUE_SEPARATOR . $val . CRM_Core_DAO::VALUE_SEPARATOR . "%' ) "; + $showValue[] = $commPref[$val]; + } } $this->_where[$grouping][] = "( " . implode(' OR ', $sqlValue) . " )"; $this->_qill[$grouping][] = ts('Preferred Communication Method') . " $op " . implode(' ' . ts('or') . ' ', $showValue); -- GitLab