<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.7 |
+ | CiviCRM version 5 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2018 |
+--------------------------------------------------------------------+
* Generate select clause.
*/
public function select() {
+ // @todo remove this in favour of just using parent.
$select = array();
$this->_columnHeaders = array();
foreach ($this->_columns as $tableName => $table) {
if (!empty($field['required']) ||
!empty($this->_params['fields'][$fieldName])
) {
- // to include optional columns address and email, only if checked
- if ($tableName == 'civicrm_address') {
- $this->_addressField = TRUE;
- $this->_emailField = TRUE;
- }
- elseif ($tableName == 'civicrm_email') {
- $this->_emailField = TRUE;
- }
$select[] = "{$field['dbAlias']} as {$tableName}_{$fieldName}";
$this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = $field['type'];
$this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = $field['title'];
LEFT JOIN civicrm_contribution {$this->_aliases['civicrm_contribution']}
ON {$this->_aliases['civicrm_membership']}.contact_id = {$this->_aliases['civicrm_contribution']}.contact_id
";
- // Include address table if address column is to be included.
- if ($this->_addressField) {
- $this->_from .= "LEFT JOIN civicrm_address {$this->_aliases['civicrm_address']} ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_address']}.contact_id AND {$this->_aliases['civicrm_address']}.is_primary = 1\n";
- }
-
- // Include email table if email column is to be included.
- if ($this->_emailField) {
- $this->_from .= "LEFT JOIN civicrm_email {$this->_aliases['civicrm_email']} ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_email']}.contact_id AND {$this->_aliases['civicrm_email']}.is_primary = 1\n";
- }
+ $this->joinAddressFromContact();
+ $this->joinEmailFromContact();
}
/**
$entryFound = TRUE;
}
- // handle state province
- if (array_key_exists('civicrm_address_state_province_id', $row)) {
- if ($value = $row['civicrm_address_state_province_id']) {
- $rows[$rowNum]['civicrm_address_state_province_id'] = CRM_Core_PseudoConstant::stateProvinceAbbreviation($value, FALSE);
- }
- $entryFound = TRUE;
- }
-
- // handle country
- if (array_key_exists('civicrm_address_country_id', $row)) {
- if ($value = $row['civicrm_address_country_id']) {
- $rows[$rowNum]['civicrm_address_country_id'] = CRM_Core_PseudoConstant::country($value, FALSE);
- }
- $entryFound = TRUE;
- }
-
// convert display name to links
if (array_key_exists('civicrm_contact_sort_name', $row) &&
array_key_exists('civicrm_contact_id', $row)
$entryFound = TRUE;
}
+ $entryFound = $this->alterDisplayAddressFields($row, $rows, $rowNum, NULL, NULL) ? TRUE : $entryFound;
// skip looking further in rows, if first row itself doesn't
// have the column we need
if (!$entryFound) {