Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
fee14197 | 4 | | CiviCRM version 5 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
6b83d5bd | 6 | | Copyright CiviCRM LLC (c) 2004-2019 | |
6a488035 TO |
7 | +--------------------------------------------------------------------+ |
8 | | This file is a part of CiviCRM. | | |
9 | | | | |
10 | | CiviCRM is free software; you can copy, modify, and distribute it | | |
11 | | under the terms of the GNU Affero General Public License | | |
12 | | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | | |
13 | | | | |
14 | | CiviCRM is distributed in the hope that it will be useful, but | | |
15 | | WITHOUT ANY WARRANTY; without even the implied warranty of | | |
16 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | | |
17 | | See the GNU Affero General Public License for more details. | | |
18 | | | | |
19 | | You should have received a copy of the GNU Affero General Public | | |
20 | | License and the CiviCRM Licensing Exception along | | |
21 | | with this program; if not, contact CiviCRM LLC | | |
22 | | at info[AT]civicrm[DOT]org. If you have questions about the | | |
23 | | GNU Affero General Public License or the licensing of CiviCRM, | | |
24 | | see the CiviCRM license FAQ at http://civicrm.org/licensing | | |
25 | +--------------------------------------------------------------------+ | |
d25dd0ee | 26 | */ |
6a488035 TO |
27 | |
28 | /** | |
29 | * | |
30 | * @package CRM | |
6b83d5bd | 31 | * @copyright CiviCRM LLC (c) 2004-2019 |
6a488035 TO |
32 | * $Id$ |
33 | * | |
34 | */ | |
35 | ||
36 | /** | |
37 | * State machine for managing different states of the EventWizard process. | |
38 | * | |
39 | */ | |
40 | class CRM_Event_StateMachine_Registration extends CRM_Core_StateMachine { | |
41 | ||
42 | /** | |
fe482240 | 43 | * Class constructor. |
6a488035 | 44 | * |
77b97be7 EM |
45 | * @param object $controller |
46 | * @param \const|int $action | |
6a488035 | 47 | * |
77b97be7 | 48 | * @return \CRM_Event_StateMachine_Registration CRM_Event_StateMachine |
6a488035 | 49 | */ |
00be9182 | 50 | public function __construct($controller, $action = CRM_Core_Action::NONE) { |
6a488035 TO |
51 | parent::__construct($controller, $action); |
52 | $id = CRM_Utils_Request::retrieve('id', 'Positive', $controller, TRUE); | |
53 | $is_monetary = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $id, 'is_monetary'); | |
1909126f | 54 | $is_confirm_enabled = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $id, 'is_confirm_enabled'); |
6a488035 | 55 | |
be2fb01f | 56 | $pages = ['CRM_Event_Form_Registration_Register' => NULL]; |
6a488035 TO |
57 | |
58 | //handle additional participant scenario, where we need to insert participant pages on runtime | |
59 | $additionalParticipant = NULL; | |
60 | ||
61 | // check that the controller has some data, hence we dont send the form name | |
62 | // which results in an invalid argument error | |
63 | $values = $controller->exportValues(); | |
64 | //first check POST value then QF | |
65 | if (isset($_POST['additional_participants']) && CRM_Utils_Rule::positiveInteger($_POST['additional_participants'])) { | |
66 | // we need to use $_POST since the QF framework has not yet been called | |
67 | // and the additional participants page is the next one, so need to set this up | |
68 | // now | |
69 | $additionalParticipant = $_POST['additional_participants']; | |
70 | } | |
71 | elseif (isset($values['additional_participants']) && CRM_Utils_Rule::positiveInteger($values['additional_participants'])) { | |
72 | $additionalParticipant = $values['additional_participants']; | |
73 | } | |
74 | ||
75 | if ($additionalParticipant) { | |
76 | $additionalParticipant = CRM_Utils_Type::escape($additionalParticipant, 'Integer'); | |
77 | $controller->set('addParticipant', $additionalParticipant); | |
78 | } | |
79 | ||
80 | //to add instances of Additional Participant page, only if user has entered any additional participants | |
81 | if ($additionalParticipant) { | |
82 | $extraPages = CRM_Event_Form_Registration_AdditionalParticipant::getPages($additionalParticipant); | |
83 | $pages = array_merge($pages, $extraPages); | |
84 | } | |
85 | ||
be2fb01f | 86 | $additionalPages = [ |
6a488035 TO |
87 | 'CRM_Event_Form_Registration_Confirm' => NULL, |
88 | 'CRM_Event_Form_Registration_ThankYou' => NULL, | |
be2fb01f | 89 | ]; |
6a488035 TO |
90 | |
91 | $pages = array_merge($pages, $additionalPages); | |
77b97be7 | 92 | |
1909126f | 93 | // CRM-11182 - Optional confirmation screen |
353ffa53 | 94 | if (!$is_confirm_enabled && !$is_monetary) { |
6a488035 TO |
95 | unset($pages['CRM_Event_Form_Registration_Confirm']); |
96 | } | |
97 | ||
98 | $this->addSequentialPages($pages, $action); | |
99 | } | |
96025800 | 100 | |
6a488035 | 101 | } |