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 pledge form task actions.
20 * FIXME: This needs refactoring to properly inherit from CRM_Core_Form_Task and share more functions.
22 class CRM_Pledge_Form_Task
extends CRM_Core_Form_Task
{
25 * The array that holds all the pledge ids.
29 protected $_pledgeIds;
32 * Build all the data structures needed to build the form.
34 public function preProcess() {
35 self
::preProcessCommon($this);
39 * Common pre-processing.
41 * @param CRM_Pledge_Form_Task $form
43 public static function preProcessCommon(&$form) {
44 $form->_pledgeIds
= [];
46 $values = $form->controller
->exportValues('Search');
48 $form->_task
= $values['task'];
50 $ids = $form->getSelectedIDs($values);
53 $queryParams = $form->get('queryParams');
55 if ($form->get(CRM_Utils_Sort
::SORT_ORDER
)) {
56 $sortOrder = $form->get(CRM_Utils_Sort
::SORT_ORDER
);
58 $query = new CRM_Contact_BAO_Query($queryParams, NULL, NULL, FALSE, FALSE,
59 CRM_Contact_BAO_Query
::MODE_PLEDGE
61 $query->_distinctComponentClause
= ' civicrm_pledge.id';
62 $query->_groupByComponentClause
= ' GROUP BY civicrm_pledge.id ';
64 $result = $query->searchQuery(0, 0, $sortOrder);
65 while ($result->fetch()) {
66 $ids[] = $result->pledge_id
;
71 $form->_componentClause
= ' civicrm_pledge.id IN ( ' . implode(',', $ids) . ' ) ';
72 $form->assign('totalSelectedPledges', count($ids));
75 $form->_pledgeIds
= $form->_componentIds
= $ids;
76 $form->setNextUrl('pledge');
80 * Given the signer id, compute the contact id
81 * since its used for things like send email
83 public function setContactIDs() {
84 $this->_contactIds
= CRM_Core_DAO
::getContactIDsFromComponent($this->_pledgeIds
,
90 * Simple shell that derived classes can call to add buttons to
91 * the form with a customized title for the main Submit
93 * @param string $title
94 * Title of the main button.
95 * @param string $nextType
96 * @param string $backType
97 * @param bool $submitOnce
99 public function addDefaultButtons($title, $nextType = 'next', $backType = 'back', $submitOnce = FALSE) {
108 'name' => ts('Cancel'),