X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FReport%2FForm.php;h=506b13d39bf6bdc3eab0ec75101b663eb8edda13;hb=9eab4fddbeaf95513c29986f88aed802db62eda3;hp=5fddee12f0e3d42f7b6779fb9cdc5947f587829a;hpb=d161de0691dfd7d6f8cf36e6ceca7db771427a50;p=civicrm-core.git diff --git a/CRM/Report/Form.php b/CRM/Report/Form.php index 5fddee12f0..506b13d39b 100644 --- a/CRM/Report/Form.php +++ b/CRM/Report/Form.php @@ -135,6 +135,7 @@ class CRM_Report_Form extends CRM_Core_Form { * @var null */ protected $_customGroupExtends = NULL; + protected $_customGroupExtendsJoin = array(); protected $_customGroupFilters = TRUE; protected $_customGroupGroupBy = FALSE; protected $_customGroupJoin = 'LEFT JOIN'; @@ -2879,10 +2880,11 @@ ORDER BY cg.weight, cf.weight"; if (!$this->isFieldSelected($prop)) { continue; } + $baseJoin = CRM_Utils_Array::value($prop['extends'], $this->_customGroupExtendsJoin, "{$this->_aliases[$extendsTable]}.id"); $customJoin = is_array($this->_customGroupJoin) ? $this->_customGroupJoin[$table] : $this->_customGroupJoin; $this->_from .= " -{$customJoin} {$table} {$this->_aliases[$table]} ON {$this->_aliases[$table]}.entity_id = {$this->_aliases[$extendsTable]}.id"; +{$customJoin} {$table} {$this->_aliases[$table]} ON {$this->_aliases[$table]}.entity_id = {$baseJoin}"; // handle for ContactReference if (array_key_exists('fields', $prop)) { foreach ($prop['fields'] as $fieldName => $field) {