CRM-14887 smart group search regression on location
authorEileen McNaughton <eileen@fuzion.co.nz>
Fri, 20 Jun 2014 03:33:30 +0000 (15:33 +1200)
committerEileen McNaughton <eileen@fuzion.co.nz>
Fri, 20 Jun 2014 03:40:57 +0000 (15:40 +1200)
CRM/Contact/BAO/Query.php

index 25b1aa86ad3c63de17c8381f46c8cb4b0a2bbfc5..42389ce8e2a7b4bd6a7b8116e929282fa8093432 100644 (file)
@@ -2213,7 +2213,7 @@ class CRM_Contact_BAO_Query {
           )
         )) {
         //fix for search by profile with address fields.
-        $tName = "{$locationType[$locType[1]]}_address";
+        $tName = "{$locationType[$locType[1]]}-address";
       }
       elseif ($locType[0] == 'on_hold') {
         $tName = "{$locationType[$locType[1]]}-email";
@@ -2544,11 +2544,11 @@ class CRM_Contact_BAO_Query {
           continue;
 
         default:
-          if (strpos($name, '_address') != 0) {
+          if (strpos($name, '-address') != 0) {
             //we have a join on an address table - possibly in conjunction with search builder - CRM-14263
-            $parts = explode('_', $name);
+            $parts = explode('-', $name);
             $locationID = array_search($parts[0], CRM_Core_BAO_Address::buildOptions('location_type_id', 'get', array('name' => $parts[0])));
-            $from .= " $side JOIN civicrm_address $name ON ( contact_a.id = {$name}.contact_id ) and location_type_id = $locationID ";
+            $from .= " $side JOIN civicrm_address `{$name}` ON ( contact_a.id = `{$name}`.contact_id ) and location_type_id = $locationID ";
           }
           else {
             $from .= CRM_Core_Component::from($name, $mode, $side);