*/
public static $_openedPanes = array();
+ /**
+ * For search builder - which custom fields are location-dependent
+ * @var array
+ */
+ public $_locationSpecificCustomFields = array();
+
/**
* The tables which have a dependency on location and/or address
*
CRM_Contact_BAO_Query_Hook::singleton()->alterSearchQuery($this, 'select');
if (!empty($this->_cfIDs)) {
- $this->_customQuery = new CRM_Core_BAO_CustomQuery($this->_cfIDs, TRUE);
+ $this->_customQuery = new CRM_Core_BAO_CustomQuery($this->_cfIDs, TRUE, $this->_locationSpecificCustomFields);
$this->_customQuery->query();
$this->_select = array_merge($this->_select, $this->_customQuery->_select);
$this->_element = array_merge($this->_element, $this->_customQuery->_element);
}
if (!empty($addressCustomFieldIds)) {
- $cfIDs = $addressCustomFieldIds;
- $customQuery = new CRM_Core_BAO_CustomQuery($cfIDs);
+ $customQuery = new CRM_Core_BAO_CustomQuery($addressCustomFieldIds);
foreach ($addressCustomFieldIds as $cfID => $locTypeName) {
foreach ($locTypeName as $name => $dnc) {
+ $this->_locationSpecificCustomFields[$cfID] = array($name, array_search($name, $locationTypes));
$fieldName = "$name-custom_{$cfID}";
$tName = "$name-address-custom-{$cfID}";
$aName = "`$name-address-custom-{$cfID}`";
if ($returnQuery) {
return $query;
}
-
if ($count) {
return CRM_Core_DAO::singleValueQuery($query);
}