3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
19 * Class for contribute form task actions.
20 * FIXME: This needs refactoring to properly inherit from CRM_Core_Form_Task and share more functions.
22 class CRM_Contribute_Form_Task
extends CRM_Core_Form_Task
{
24 use CRM_Contribute_Form_Task_TaskTrait
;
27 * The array that holds all the contribution ids.
31 protected $_contributionIds;
34 * Build all the data structures needed to build the form.
36 public function preProcess() {
37 self
::preProcessCommon($this);
41 * @param \CRM_Contribute_Form_Task $form
43 * @throws \CRM_Core_Exception
45 public static function preProcessCommon(&$form): void
{
46 $form->_contributionIds
= [];
48 $values = $form->getSearchFormValues();
50 $form->_task
= $values['task'] ??
NULL;
52 $ids = $form->getIDs();
53 $form->_componentClause
= $form->getComponentClause();
54 $form->assign('totalSelectedContributions', count($ids));
55 $form->_contributionIds
= $form->_componentIds
= $ids;
56 $form->set('contributionIds', $form->_contributionIds
);
57 $form->setNextUrl('contribute');
61 * Sets contribution Ids for unit test.
63 * @param array $contributionIds
65 public function setContributionIds(array $contributionIds): void
{
66 $this->ids
= $contributionIds;
70 * Given the contribution id, compute the contact id
71 * since its used for things like send email
73 public function setContactIDs(): void
{
74 if (!$this->isQueryIncludesSoftCredits()) {
75 $this->_contactIds
= CRM_Core_DAO
::getContactIDsFromComponent(
76 $this->_contributionIds
,
77 'civicrm_contribution'
83 * Simple shell that derived classes can call to add buttons to
84 * the form with a customized title for the main Submit
86 * @param string $title
87 * Title of the main button.
88 * @param string $nextType
89 * Button type for the form after processing.
90 * @param string $backType
91 * @param bool $submitOnce
93 public function addDefaultButtons($title, $nextType = 'next', $backType = 'back', $submitOnce = FALSE) {
102 'name' => ts('Cancel'),