switch ($field) {
case 'city':
case 'postal_code':
- $this->_whereTables["civicrm_address"] = 1;
+ $this->_tables["civicrm_address"] = $this->_whereTables["civicrm_address"] = 1;
$order = str_replace($field, "civicrm_address.{$field}", $order);
break;
case 'country':
case 'state_province':
- $this->_whereTables["civicrm_{$field}"] = 1;
+ $this->_tables["civicrm_{$field}"] = $this->_whereTables["civicrm_{$field}"] = 1;
+ if (is_array($this->_returnProperties) && empty($this->_returnProperties)) {
+ $additionalFromClause .= " LEFT JOIN civicrm_{$field} ON civicrm_{$field}.id = civicrm_address.{$field}_id";
+ }
$order = str_replace($field, "civicrm_{$field}.name", $order);
break;
case 'email':
- $this->_whereTables["civicrm_email"] = 1;
+ $this->_tables["civicrm_email"] = $this->_whereTables["civicrm_email"] = 1;
$order = str_replace($field, "civicrm_email.{$field}", $order);
break;
public function contactIDQuery($params, $action, $sortID, $displayRelationshipType = NULL, $queryOperator = 'AND') {
$sortOrder = &$this->getSortOrder($this->_action);
$sort = new CRM_Utils_Sort($sortOrder, $sortID);
- $includeOrderByClause = Civi::settings()->get('includeOrderByClause');
- $returnProperties = CRM_Contact_BAO_Query::NO_RETURN_PROPERTIES;
- if ($includeOrderByClause) {
- $returnProperties = $this->_returnProperties;
- }
// rectify params to what proximity search expects if there is a value for prox_distance
// CRM-7021 CRM-7905
if (!$displayRelationshipType) {
$query = new CRM_Contact_BAO_Query($params,
- $returnProperties,
+ CRM_Contact_BAO_Query::NO_RETURN_PROPERTIES,
NULL, FALSE, FALSE, 1,
FALSE, TRUE, TRUE, NULL,
$queryOperator
}
else {
$query = new CRM_Contact_BAO_Query($params,
- $returnProperties,
+ CRM_Contact_BAO_Query::NO_RETURN_PROPERTIES,
NULL, FALSE, FALSE, 1,
FALSE, TRUE, TRUE, $displayRelationshipType,
$queryOperator