From a6caa0afc9c1fece0da0a2a5ba4622fee75c263c Mon Sep 17 00:00:00 2001 From: eileen Date: Thu, 25 Mar 2021 20:18:56 +1300 Subject: [PATCH] Move handling for soft credits to the only form that uses it --- CRM/Contribute/Form/Task.php | 11 ----------- CRM/Contribute/Form/Task/PDFLetterCommon.php | 9 +++++++-- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/CRM/Contribute/Form/Task.php b/CRM/Contribute/Form/Task.php index f73b7c0934c7..53df76a8b507 100644 --- a/CRM/Contribute/Form/Task.php +++ b/CRM/Contribute/Form/Task.php @@ -30,13 +30,6 @@ class CRM_Contribute_Form_Task extends CRM_Core_Form_Task { */ protected $_contributionIds; - /** - * The array that holds all the mapping contribution and contact ids. - * - * @var array - */ - protected $_contributionContactIds = []; - /** * Build all the data structures needed to build the form. */ @@ -61,10 +54,6 @@ public static function preProcessCommon(&$form): void { $result = $form->getSearchQueryResults(); while ($result->fetch()) { $ids[] = $result->contribution_id; - if ($form->isQueryIncludesSoftCredits()) { - $form->_contactIds[$result->contact_id] = $result->contact_id; - $form->_contributionContactIds["{$result->contact_id}-{$result->contribution_id}"] = $result->contribution_id; - } } $form->assign('totalSelectedContributions', $form->get('rowCount')); } diff --git a/CRM/Contribute/Form/Task/PDFLetterCommon.php b/CRM/Contribute/Form/Task/PDFLetterCommon.php index af0b20f90c24..338baccad53f 100644 --- a/CRM/Contribute/Form/Task/PDFLetterCommon.php +++ b/CRM/Contribute/Form/Task/PDFLetterCommon.php @@ -25,6 +25,8 @@ public static function buildQuickForm(&$form) { * * @param \CRM_Contribute_Form_Task_PDFLetter $form * @param array $formValues + * + * @throws \CRM_Core_Exception */ public static function postProcess(&$form, $formValues = NULL) { if (empty($formValues)) { @@ -79,8 +81,11 @@ public static function postProcess(&$form, $formValues = NULL) { $skipDeceased = $form->skipDeceased ?? TRUE; $contributionIDs = $form->getVar('_contributionIds'); if ($form->isQueryIncludesSoftCredits()) { - //@todo - comment on what is stored there - $contributionIDs = $form->getVar('_contributionContactIds'); + $contributionIDs = []; + foreach ($form->getSearchQueryResults() as $result) { + $form->_contactIds[$result->contact_id] = $result->contact_id; + $contributionIDs["{$result->contact_id}-{$result->contribution_id}"] = $result->contribution_id; + } } [$contributions, $contacts] = self::buildContributionArray($groupBy, $contributionIDs, $returnProperties, $skipOnHold, $skipDeceased, $messageToken, $task, $separator, $form->isQueryIncludesSoftCredits()); $html = [];