Proposed fix for searching similar multi select values CRM-16575
authorunknown <ajc275@LT010247.internal.admin.cam.ac.uk>
Wed, 27 May 2015 13:36:06 +0000 (14:36 +0100)
committermonishdeb <monish.deb@webaccessglobal.com>
Thu, 18 Jun 2015 10:44:19 +0000 (16:14 +0530)
CRM/Core/BAO/CustomQuery.php
CRM/Report/Form.php

index 512b7595c4d85899d70025da6a330e9981648dce..717c50fe37bceb118f2fbe960ce41a4764cf3470 100644 (file)
@@ -400,9 +400,20 @@ SELECT label, value
             else {
               $val = CRM_Utils_Type::escape($strtolower(trim($value)), 'String');
 
-              if ($wildcard) {
-                $val = $strtolower(CRM_Core_DAO::escapeString($val));
-                $val = "%$val%";
+              $specialHTMLType = array(
+                'CheckBox',
+                'Multi-Select',
+                'AdvMulti-Select',
+                'Multi-Select State/Province',
+                'Multi-Select Country',
+              );
+               
+              if (in_array($field['html_type'], $specialHTMLType)) {
+                $val = "[[:cntrl:]]".$val."[[:cntrl:]]";
+                $op  = 'RLIKE';
+
+              } elseif ($wildcard) {
+                               $val = "[[:cntrl:]]%$val%[[:cntrl:]]";
                 $op = 'LIKE';
               }
 
index fa6ee910f8408d497a84122b16d064a82ce34c91..8f252b32643331761d33f045481b3c09b2743cd3 100644 (file)
@@ -1739,8 +1739,8 @@ class CRM_Report_Form extends CRM_Core_Form {
         if ($value !== NULL && count($value) > 0) {
           $sqlOP = $this->getSQLOperator($op);
           $clause
-            = "{$field['dbAlias']} REGEXP '[[:<:]]" . implode('|', $value) .
-            "[[:>:]]'";
+            = "{$field['dbAlias']} REGEXP '[[:cntrl:]]" . implode('|', $value) .
+            "[[:cntrl:]]'";
         }
         break;
 
@@ -1749,8 +1749,8 @@ class CRM_Report_Form extends CRM_Core_Form {
         if ($value !== NULL && count($value) > 0) {
           $sqlOP = $this->getSQLOperator($op);
           $clause
-            = "( {$field['dbAlias']} NOT REGEXP '[[:<:]]" . implode('|', $value) .
-            "[[:>:]]' OR {$field['dbAlias']} IS NULL )";
+            = "( {$field['dbAlias']} NOT REGEXP '[[:cntrl:]]" . implode('|', $value) .
+            "[[:cntrl:]]' OR {$field['dbAlias']} IS NULL )";
         }
         break;