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
21 * This class provides the functionality for batch profile update for event participations
23 class CRM_Event_Form_Task_PickProfile
extends CRM_Event_Form_Task
{
26 * The title of the group.
33 * Maximum event participations that should be allowed to update.
36 protected $_maxParticipations = 100;
39 * Variable to store redirect path.
42 protected $_userContext;
45 * Build all the data structures needed to build the form.
49 public function preProcess() {
50 // initialize the task and row fields
53 $session = CRM_Core_Session
::singleton();
54 $this->_userContext
= $session->readUserContext();
56 CRM_Utils_System
::setTitle(ts('Update multiple participants'));
60 if (count($this->_participantIds
) > $this->_maxParticipations
) {
61 CRM_Core_Session
::setStatus("The maximum number of records you can select for Update multiple participants is {$this->_maxParticipations}. You have selected " . count($this->_participantIds
) . ". Please select fewer participantions from your search results and try again.");
67 CRM_Utils_System
::redirect($this->_userContext
);
72 * Build the form object.
77 public function buildQuickForm() {
78 $types = ['Participant'];
79 $profiles = CRM_Core_BAO_UFGroup
::getProfiles($types, TRUE);
81 if (empty($profiles)) {
82 CRM_Core_Session
::setStatus("To use Update multiple participants, you need to configure a profile containing only Participant fields (e.g. Participant Status, Participant Role, etc.). Configure a profile at 'Administer CiviCRM >> Customize >> CiviCRM Profile'.");
83 CRM_Utils_System
::redirect($this->_userContext
);
86 $ufGroupElement = $this->add('select', 'uf_group_id', ts('Select Profile'),
88 '' => ts('- select profile -'),
91 $this->addDefaultButtons(ts('Continue'));
95 * Add local and global form rules.
100 public function addRules() {
101 $this->addFormRule(['CRM_Event_Form_Task_PickProfile', 'formRule']);
105 * Global validation rules for the form.
107 * @param array $fields
108 * Posted values of the form.
111 * list of errors to be posted back to the form
113 public static function formRule($fields) {
118 * Process the form after the input has been submitted and validated.
123 public function postProcess() {
124 $params = $this->exportValues();
126 $this->set('ufGroupId', $params['uf_group_id']);
128 // also reset the batch page so it gets new values from the db
129 $this->controller
->resetPage('Batch');