From f3d529fc6bcc6f1e0f8e05d833ac628396670874 Mon Sep 17 00:00:00 2001 From: Pradeep Nayak Date: Sun, 21 May 2017 05:04:22 +0530 Subject: [PATCH] CRM-20614 Don't download export file until asked ---------------------------------------- * CRM-20614: Donot Download Export file for Financial Batch https://issues.civicrm.org/jira/browse/CRM-20614 --- CRM/Batch/BAO/Batch.php | 5 ++++- CRM/Financial/BAO/ExportFormat.php | 3 +++ CRM/Financial/Form/Export.php | 7 ++++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CRM/Batch/BAO/Batch.php b/CRM/Batch/BAO/Batch.php index 163a32abdf..c6974f3bea 100644 --- a/CRM/Batch/BAO/Batch.php +++ b/CRM/Batch/BAO/Batch.php @@ -576,8 +576,10 @@ class CRM_Batch_BAO_Batch extends CRM_Batch_DAO_Batch { * Associated array of batch ids. * @param string $exportFormat * Export format. + * @param bool $downloadFile + * Download export file?. */ - public static function exportFinancialBatch($batchIds, $exportFormat) { + public static function exportFinancialBatch($batchIds, $exportFormat, $downloadFile) { if (empty($batchIds)) { CRM_Core_Error::fatal(ts('No batches were selected.')); return; @@ -597,6 +599,7 @@ class CRM_Batch_BAO_Batch extends CRM_Batch_DAO_Batch { CRM_Core_Error::fatal("Could not locate exporter: $exporterClass"); } $export = array(); + $exporter->_isDownloadFile = $downloadFile; foreach ($batchIds as $batchId) { // export only batches whose status is set to Exported. $result = civicrm_api3('Batch', 'getcount', array( diff --git a/CRM/Financial/BAO/ExportFormat.php b/CRM/Financial/BAO/ExportFormat.php index 438efb682f..5b67e48631 100644 --- a/CRM/Financial/BAO/ExportFormat.php +++ b/CRM/Financial/BAO/ExportFormat.php @@ -141,6 +141,9 @@ abstract class CRM_Financial_BAO_ExportFormat { } public function initiateDownload() { + if (!$this->_isDownloadFile) { + return NULL; + } $config = CRM_Core_Config::singleton(); // zip files if more than one. if (count($this->_downloadFile) > 1) { diff --git a/CRM/Financial/Form/Export.php b/CRM/Financial/Form/Export.php index 46034b1708..e5d19dd499 100644 --- a/CRM/Financial/Form/Export.php +++ b/CRM/Financial/Form/Export.php @@ -60,6 +60,11 @@ class CRM_Financial_Form_Export extends CRM_Core_Form { */ protected $_exportFormat; + /** + * Download export File. + */ + protected $_downloadFile = TRUE; + /** * Build all the data structures needed to build the form. */ @@ -175,7 +180,7 @@ class CRM_Financial_Form_Export extends CRM_Core_Form { CRM_Batch_BAO_Batch::create($batchParams); } - CRM_Batch_BAO_Batch::exportFinancialBatch($batchIds, $this->_exportFormat); + CRM_Batch_BAO_Batch::exportFinancialBatch($batchIds, $this->_exportFormat, $this->_downloadFile); } } -- 2.25.1