Skip to content

Commit

Permalink
Merge pull request #15297 from eileenmcnaughton/517e
Browse files Browse the repository at this point in the history
Fix for core#1247 - export hook doesn't work
  • Loading branch information
seamuslee001 authored Sep 13, 2019
2 parents a2f957b + 766bd14 commit 9793978
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
1 change: 1 addition & 0 deletions CRM/Export/BAO/Export.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ public static function exportComponents(
}
$processor->setComponentTable($componentTable);
$processor->setComponentClause($componentClause);
$processor->setIds($ids);

list($query, $queryString) = $processor->runQuery($params, $order);

Expand Down
30 changes: 29 additions & 1 deletion CRM/Export/BAO/ExportProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,13 @@ class CRM_Export_BAO_ExportProcessor {
*/
protected $contactGreetingFields = [];

/**
* An array of primary IDs of the entity being exported.
*
* @var array
*/
protected $ids = [];

/**
* Get additional non-visible fields for address merge purposes.
*
Expand Down Expand Up @@ -585,6 +592,20 @@ public function setQueryOperator($queryOperator) {
$this->queryOperator = $queryOperator;
}

/**
* @return array
*/
public function getIds() {
return $this->ids;
}

/**
* @param array $ids
*/
public function setIds($ids) {
$this->ids = $ids;
}

/**
* @return array
*/
Expand Down Expand Up @@ -2326,7 +2347,14 @@ public function writeCSVFromTable() {
// call export hook
$headerRows = $this->getHeaderRows();
$exportTempTable = $this->getTemporaryTable();
$exportMode = $this->getExportMode();
$sqlColumns = $this->getSQLColumns();
$componentTable = $this->getComponentTable();
$ids = $this->getIds();
CRM_Utils_Hook::export($exportTempTable, $headerRows, $sqlColumns, $exportMode, $componentTable, $ids);
if ($exportMode !== $this->getExportMode() || $componentTable !== $this->getComponentTable()) {
CRM_Core_Error::deprecatedFunctionWarning('altering the export mode and/or component table in the hook is no longer supported.');
}
if ($exportTempTable !== $this->getTemporaryTable()) {
CRM_Core_Error::deprecatedFunctionWarning('altering the export table in the hook is deprecated (in some flows the table itself will be)');
$this->setTemporaryTable($exportTempTable);
Expand Down Expand Up @@ -2355,7 +2383,7 @@ public function writeCSVFromTable() {
while ($dao->fetch()) {
$row = [];

foreach (array_keys($this->getSQLColumns()) as $column) {
foreach (array_keys($sqlColumns) as $column) {
$row[$column] = $dao->$column;
}
$componentDetails[] = $row;
Expand Down

0 comments on commit 9793978

Please sign in to comment.