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 * State machine for managing different states of the EventWizard process.
24 class CRM_Event_StateMachine_Registration
extends CRM_Core_StateMachine
{
29 * @param object $controller
30 * @param \const|int $action
32 * @return \CRM_Event_StateMachine_Registration CRM_Event_StateMachine
34 public function __construct($controller, $action = CRM_Core_Action
::NONE
) {
35 parent
::__construct($controller, $action);
36 $id = CRM_Utils_Request
::retrieve('id', 'Positive', $controller, TRUE);
37 $is_monetary = CRM_Core_DAO
::getFieldValue('CRM_Event_DAO_Event', $id, 'is_monetary');
38 $is_confirm_enabled = CRM_Core_DAO
::getFieldValue('CRM_Event_DAO_Event', $id, 'is_confirm_enabled');
40 $pages = ['CRM_Event_Form_Registration_Register' => NULL];
42 //handle additional participant scenario, where we need to insert participant pages on runtime
43 $additionalParticipant = NULL;
45 // check that the controller has some data, hence we dont send the form name
46 // which results in an invalid argument error
47 $values = $controller->exportValues();
48 //first check POST value then QF
49 if (isset($_POST['additional_participants']) && CRM_Utils_Rule
::positiveInteger($_POST['additional_participants'])) {
50 // we need to use $_POST since the QF framework has not yet been called
51 // and the additional participants page is the next one, so need to set this up
53 $additionalParticipant = $_POST['additional_participants'];
55 elseif (isset($values['additional_participants']) && CRM_Utils_Rule
::positiveInteger($values['additional_participants'])) {
56 $additionalParticipant = $values['additional_participants'];
59 if ($additionalParticipant) {
60 $additionalParticipant = CRM_Utils_Type
::escape($additionalParticipant, 'Integer');
61 $controller->set('addParticipant', $additionalParticipant);
64 //to add instances of Additional Participant page, only if user has entered any additional participants
65 if ($additionalParticipant) {
66 $extraPages = CRM_Event_Form_Registration_AdditionalParticipant
::getPages($additionalParticipant);
67 $pages = array_merge($pages, $extraPages);
71 'CRM_Event_Form_Registration_Confirm' => NULL,
72 'CRM_Event_Form_Registration_ThankYou' => NULL,
75 $pages = array_merge($pages, $additionalPages);
77 // CRM-11182 - Optional confirmation screen
78 if (!$is_confirm_enabled && !$is_monetary) {
79 unset($pages['CRM_Event_Form_Registration_Confirm']);
82 $this->addSequentialPages($pages, $action);