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 +--------------------------------------------------------------------+
13 * State machine for managing different states of the EventWizard process.
15 class CRM_Event_StateMachine_Registration
extends CRM_Core_StateMachine
{
20 * @param object $controller
23 * @throws \CRM_Core_Exception
25 public function __construct($controller, $action = CRM_Core_Action
::NONE
) {
26 parent
::__construct($controller, $action);
27 $id = CRM_Utils_Request
::retrieve('id', 'Positive', $controller, TRUE);
28 $is_monetary = CRM_Core_DAO
::getFieldValue('CRM_Event_DAO_Event', $id, 'is_monetary');
29 $is_confirm_enabled = CRM_Core_DAO
::getFieldValue('CRM_Event_DAO_Event', $id, 'is_confirm_enabled');
31 $pages = ['CRM_Event_Form_Registration_Register' => NULL];
33 //handle additional participant scenario, where we need to insert participant pages on runtime
34 $additionalParticipant = NULL;
36 // check that the controller has some data, hence we dont send the form name
37 // which results in an invalid argument error
38 $values = $controller->exportValues();
39 //first check POST value then QF
40 if (isset($_POST['additional_participants']) && CRM_Utils_Rule
::positiveInteger($_POST['additional_participants'])) {
41 // we need to use $_POST since the QF framework has not yet been called
42 // and the additional participants page is the next one, so need to set this up
44 $additionalParticipant = $_POST['additional_participants'];
46 elseif (isset($values['additional_participants']) && CRM_Utils_Rule
::positiveInteger($values['additional_participants'])) {
47 $additionalParticipant = $values['additional_participants'];
50 if ($additionalParticipant) {
51 $additionalParticipant = CRM_Utils_Type
::escape($additionalParticipant, 'Integer');
52 $controller->set('addParticipant', $additionalParticipant);
55 //to add instances of Additional Participant page, only if user has entered any additional participants
56 if ($additionalParticipant) {
57 $extraPages = CRM_Event_Form_Registration_AdditionalParticipant
::getPages($additionalParticipant);
58 $pages = array_merge($pages, $extraPages);
62 'CRM_Event_Form_Registration_Confirm' => NULL,
63 'CRM_Event_Form_Registration_ThankYou' => NULL,
66 $pages = array_merge($pages, $additionalPages);
68 // CRM-11182 - Optional confirmation screen
69 if (!$is_confirm_enabled && !$is_monetary) {
70 unset($pages['CRM_Event_Form_Registration_Confirm']);
73 $this->addSequentialPages($pages, $action);