Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
bc77d7c0 | 4 | | Copyright CiviCRM LLC. All rights reserved. | |
6a488035 | 5 | | | |
bc77d7c0 TO |
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 | | |
6a488035 | 9 | +--------------------------------------------------------------------+ |
d25dd0ee | 10 | */ |
6a488035 TO |
11 | |
12 | /** | |
13 | * Redefine the submit action. | |
14 | * | |
15 | * @package CRM | |
ca5cec67 | 16 | * @copyright CiviCRM LLC https://civicrm.org/licensing |
6a488035 TO |
17 | * $Id$ |
18 | * | |
19 | */ | |
20 | class CRM_Core_QuickForm_Action_Submit extends CRM_Core_QuickForm_Action { | |
21 | ||
22 | /** | |
d09edf64 | 23 | * Class constructor. |
6a488035 | 24 | * |
6a0b768e TO |
25 | * @param object $stateMachine |
26 | * Reference to state machine object. | |
6a488035 | 27 | * |
77b97be7 | 28 | * @return \CRM_Core_QuickForm_Action_Submit |
6a488035 | 29 | */ |
00be9182 | 30 | public function __construct(&$stateMachine) { |
6a488035 TO |
31 | parent::__construct($stateMachine); |
32 | } | |
33 | ||
34 | /** | |
35 | * Processes the request. | |
36 | * | |
6a0b768e TO |
37 | * @param CRM_Core_Form $page |
38 | * CRM_Core_Form the current form-page. | |
39 | * @param string $actionName | |
40 | * Current action name, as one Action object can serve multiple actions. | |
6a488035 TO |
41 | * |
42 | * @return void | |
6a488035 | 43 | */ |
00be9182 | 44 | public function perform(&$page, $actionName) { |
6a488035 TO |
45 | $page->isFormBuilt() or $page->buildForm(); |
46 | ||
47 | $pageName = $page->getAttribute('name'); | |
48 | $data = &$page->controller->container(); | |
49 | $data['values'][$pageName] = $page->exportValues(); | |
50 | $data['valid'][$pageName] = $page->validate(); | |
51 | ||
52 | // Modal form and page is invalid: don't go further | |
53 | if ($page->controller->isModal() && !$data['valid'][$pageName]) { | |
54 | return $page->handle('display'); | |
55 | } | |
56 | ||
57 | // the page is valid, process it before we jump to the next state | |
58 | $page->mainProcess(); | |
59 | ||
60 | // check if destination is set, if so goto destination | |
61 | $destination = $this->_stateMachine->getDestination(); | |
62 | if ($destination) { | |
63 | $destination = urldecode($destination); | |
64 | CRM_Utils_System::redirect($destination); | |
65 | } | |
66 | else { | |
67 | return $page->handle('display'); | |
68 | } | |
69 | } | |
96025800 | 70 | |
6a488035 | 71 | } |