Skip to content

Commit

Permalink
CRM-21130 - Search builder throws error if location type has space (#…
Browse files Browse the repository at this point in the history
…10928)

* CRM-21130 - Search builder throws error if location type has space

* minor fixes
  • Loading branch information
yashodha authored and eileenmcnaughton committed Sep 1, 2017
1 parent 29d72d9 commit 140e25e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 6 additions & 1 deletion CRM/Contact/BAO/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -2791,7 +2791,12 @@ public static function fromClause(&$tables, $inner = NULL, $right = NULL, $prima
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])));
$locationTypes = CRM_Core_BAO_Address::buildOptions('location_type_id', 'get');
foreach ($locationTypes as $locationTypeID => $locationType) {
if ($parts[0] == str_replace(' ', '_', $locationType)) {
$locationID = $locationTypeID;
}
}
$from .= " $side JOIN civicrm_{$locationTypeName} `{$name}` ON ( contact_a.id = `{$name}`.contact_id ) and `{$name}`.location_type_id = $locationID ";
}
else {
Expand Down
1 change: 1 addition & 0 deletions CRM/Contact/Selector.php
Original file line number Diff line number Diff line change
Expand Up @@ -1248,6 +1248,7 @@ public function &makeProperties(&$returnProperties) {
foreach ($value as $n => $v) {
foreach ($v as $n1 => $v1) {
if (!strpos('_id', $n1) && $n1 != 'location_type') {
$n = str_replace(' ', '_', $n);
$properties[] = "{$n}-{$n1}";
}
}
Expand Down

0 comments on commit 140e25e

Please sign in to comment.