CRM-14263 further fix for CRM-14263 fix phone in search profile situation
authorEileen McNaughton <eileen@fuzion.co.nz>
Fri, 20 Jun 2014 05:26:51 +0000 (17:26 +1200)
committerEileen McNaughton <eileen@fuzion.co.nz>
Fri, 20 Jun 2014 05:30:07 +0000 (17:30 +1200)
CRM/Contact/BAO/Query.php

index 7e659c7cec1490a86318e713b5f2cc89b7c6cf2e..00ced63b9ef90ae1f9957011cbd153b19c2abab7 100644 (file)
@@ -2547,11 +2547,18 @@ class CRM_Contact_BAO_Query {
           continue;
 
         default:
+          $locationTypeName = '';
           if (strpos($name, '-address') != 0) {
-            //we have a join on an address table - possibly in conjunction with search builder - CRM-14263
+            $locationTypeName = 'address';
+          }
+          elseif (strpos($name, '-phone') != 0) {
+            $locationTypeName = 'phone';
+          }
+          if($locationTypeName) {
+            //we have a join on an location table - possibly in conjunction with search builder - CRM-14263
             $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 `{$name}`.location_type_id = $locationID ";
+            $from .= " $side JOIN civicrm_{$locationTypeName} `{$name}` ON ( contact_a.id = `{$name}`.contact_id ) and `{$name}`.location_type_id = $locationID ";
           }
           else {
             $from .= CRM_Core_Component::from($name, $mode, $side);