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 event form task actions.
20 * FIXME: This needs refactoring to properly inherit from CRM_Core_Form_Task and share more functions.
22 class CRM_Event_Form_Task
extends CRM_Core_Form_Task
{
25 * The array that holds all the participant ids.
29 protected $_participantIds;
32 * Build all the data structures needed to build the form.
38 public function preProcess() {
39 self
::preProcessCommon($this);
43 * @param CRM_Core_Form_Task $form
45 public static function preProcessCommon(&$form) {
46 $form->_participantIds
= [];
48 $values = $form->getSearchFormValues();
50 $form->_task
= $values['task'];
51 $tasks = CRM_Event_Task
::permissionedTaskTitles(CRM_Core_Permission
::getPermission());
52 if (!array_key_exists($form->_task
, $tasks)) {
53 CRM_Core_Error
::statusBounce(ts('You do not have permission to access this page.'));
57 if ($values['radio_ts'] == 'ts_sel') {
58 foreach ($values as $name => $value) {
59 if (substr($name, 0, CRM_Core_Form
::CB_PREFIX_LEN
) == CRM_Core_Form
::CB_PREFIX
) {
60 $ids[] = substr($name, CRM_Core_Form
::CB_PREFIX_LEN
);
65 $queryParams = $form->get('queryParams');
67 if ($form->get(CRM_Utils_Sort
::SORT_ORDER
)) {
68 $sortOrder = $form->get(CRM_Utils_Sort
::SORT_ORDER
);
71 $query = new CRM_Contact_BAO_Query($queryParams, NULL, NULL, FALSE, FALSE,
72 CRM_Contact_BAO_Query
::MODE_EVENT
74 $query->_distinctComponentClause
= "civicrm_participant.id";
75 $query->_groupByComponentClause
= " GROUP BY civicrm_participant.id ";
76 $result = $query->searchQuery(0, 0, $sortOrder);
77 while ($result->fetch()) {
78 $ids[] = $result->participant_id
;
83 $form->_componentClause
= ' civicrm_participant.id IN ( ' . implode(',', $ids) . ' ) ';
84 $form->assign('totalSelectedParticipants', count($ids));
87 $form->_participantIds
= $form->_componentIds
= $ids;
89 $form->setNextUrl('event');
93 * Given the participant id, compute the contact id
94 * since its used for things like send email
96 public function setContactIDs() {
97 $this->_contactIds
= CRM_Core_DAO
::getContactIDsFromComponent($this->_participantIds
,
103 * Simple shell that derived classes can call to add buttons to.
104 * the form with a customized title for the main Submit
106 * @param string $title
107 * Title of the main button.
108 * @param string $nextType
109 * @param string $backType
110 * @param bool $submitOnce
114 public function addDefaultButtons($title, $nextType = 'next', $backType = 'back', $submitOnce = FALSE) {
123 'name' => ts('Cancel'),