3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
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. |
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. |
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 +--------------------------------------------------------------------+
31 * @copyright CiviCRM LLC (c) 2004-2014
37 * State machine for managing different states of the EventWizard process.
40 class CRM_Event_StateMachine_Registration
extends CRM_Core_StateMachine
{
45 * @param object $controller
46 * @param \const|int $action
48 * @return \CRM_Event_StateMachine_Registration CRM_Event_StateMachine
50 public function __construct($controller, $action = CRM_Core_Action
::NONE
) {
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');
54 $is_confirm_enabled = CRM_Core_DAO
::getFieldValue('CRM_Event_DAO_Event', $id, 'is_confirm_enabled');
56 $pages = array('CRM_Event_Form_Registration_Register' => NULL);
58 //handle additional participant scenario, where we need to insert participant pages on runtime
59 $additionalParticipant = NULL;
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
69 $additionalParticipant = $_POST['additional_participants'];
71 elseif (isset($values['additional_participants']) && CRM_Utils_Rule
::positiveInteger($values['additional_participants'])) {
72 $additionalParticipant = $values['additional_participants'];
75 if ($additionalParticipant) {
76 $additionalParticipant = CRM_Utils_Type
::escape($additionalParticipant, 'Integer');
77 $controller->set('addParticipant', $additionalParticipant);
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);
86 $additionalPages = array(
87 'CRM_Event_Form_Registration_Confirm' => NULL,
88 'CRM_Event_Form_Registration_ThankYou' => NULL,
91 $pages = array_merge($pages, $additionalPages);
93 // CRM-11182 - Optional confirmation screen
94 if (!$is_confirm_enabled && !$is_monetary) {
95 unset($pages['CRM_Event_Form_Registration_Confirm']);
98 $this->addSequentialPages($pages, $action);