CRM-14478 - Split CRM_Core_EntityReference into different classes
[civicrm-core.git] / CRM / Core / Controller.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
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 +--------------------------------------------------------------------+
26 */
27
28 /**
29 * This class acts as our base controller class and adds additional
30 * functionality and smarts to the base QFC. Specifically we create
31 * our own action classes and handle the transitions ourselves by
32 * simulating a state machine. We also create direct jump links to any
33 * page that can be used universally.
34 *
35 * This concept has been discussed on the PEAR list and the QFC FAQ
36 * goes into a few details. Please check
37 * http://pear.php.net/manual/en/package.html.html-quickform-controller.faq.php
38 * for other useful tips and suggestions
39 *
40 * @package CRM
41 * @copyright CiviCRM LLC (c) 2004-2014
42 * $Id$
43 *
44 */
45
46 require_once 'HTML/QuickForm/Controller.php';
47 require_once 'HTML/QuickForm/Action/Direct.php';
48
49 class CRM_Core_Controller extends HTML_QuickForm_Controller {
50
51 /**
52 * the title associated with this controller
53 *
54 * @var string
55 */
56 protected $_title;
57
58 /**
59 * The key associated with this controller
60 *
61 * @var string
62 */
63 public $_key;
64
65 /**
66 * the name of the session scope where values are stored
67 *
68 * @var object
69 */
70 protected $_scope;
71
72 /**
73 * the state machine associated with this controller
74 *
75 * @var object
76 */
77 protected $_stateMachine;
78
79 /**
80 * Is this object being embedded in another object. If
81 * so the display routine needs to not do any work. (The
82 * parent object takes care of the display)
83 *
84 * @var boolean
85 */
86 protected $_embedded = FALSE;
87
88 /**
89 * After entire form execution complete,
90 * do we want to skip control redirection.
91 * Default - It get redirect to user context.
92 *
93 * Useful when we run form in non civicrm context
94 * and we need to transfer control back.(eg. drupal)
95 *
96 * @var boolean
97 */
98 protected $_skipRedirection = FALSE;
99
100 /**
101 * Are we in print mode? if so we need to modify the display
102 * functionality to do a minimal display :)
103 *
104 * @var boolean
105 */
106 public $_print = 0;
107
108 /**
109 * Should we generate a qfKey, true by default
110 *
111 * @var boolean
112 */
113 public $_generateQFKey = TRUE;
114
115 /**
116 * QF response type
117 */
118 public $_QFResponseType = 'html';
119
120 /**
121 * cache the smarty template for efficiency reasons
122 *
123 * @var CRM_Core_Smarty
124 */
125 static protected $_template;
126
127 /**
128 * cache the session for efficiency reasons
129 *
130 * @var CRM_Core_Session
131 */
132 static protected $_session;
133
134 /**
135 * The parent of this form if embedded
136 *
137 * @var object
138 */
139 protected $_parent = NULL;
140
141 /**
142 * The destination if set will override the destination the code wants to send it to
143 *
144 * @var string;
145 */
146 public $_destination = NULL;
147
148 /**
149 * The entry url for a top level form or wizard. Typically the URL with a reset=1
150 * used to redirect back to when we land into some session wierdness
151 *
152 * @var string
153 */
154 public $_entryURL = NULL;
155
156 /**
157 * All CRM single or multi page pages should inherit from this class.
158 *
159 * @param null $title
160 * @param bool $modal
161 * @param null $mode
162 * @param null $scope
163 * @param bool $addSequence
164 * @param bool $ignoreKey
165 *
166 * @internal param \title $string descriptive title of the controller
167 * @internal param \whether $boolean controller is modal
168 * @internal param \scope $string name of session if we want unique scope, used only by Controller_Simple
169 * @internal param \addSequence $boolean should we add a unique sequence number to the end of the key
170 * @internal param \ignoreKey $boolean should we not set a qfKey for this controller (for standalone forms)
171 *
172 * @access public
173 *
174 * @return \CRM_Core_Controller
175 */
176 function __construct(
177 $title = NULL,
178 $modal = TRUE,
179 $mode = NULL,
180 $scope = NULL,
181 $addSequence = FALSE,
182 $ignoreKey = FALSE
183 ) {
184 // this has to true for multiple tab session fix
185 $addSequence = TRUE;
186
187 // let the constructor initialize this, should happen only once
188 if (!isset(self::$_template)) {
189 self::$_template = CRM_Core_Smarty::singleton();
190 self::$_session = CRM_Core_Session::singleton();
191 }
192
193 // lets try to get it from the session and/or the request vars
194 // we do this early on in case there is a fatal error in retrieving the
195 // key and/or session
196 $this->_entryURL =
197 CRM_Utils_Request::retrieve('entryURL', 'String', $this);
198
199 // add a unique validable key to the name
200 $name = CRM_Utils_System::getClassName($this);
201 if ($name == 'CRM_Core_Controller_Simple' && !empty($scope)) {
202 // use form name if we have, since its a lot better and
203 // definitely different for different forms
204 $name = $scope;
205 }
206 $name = $name . '_' . $this->key($name, $addSequence, $ignoreKey);
207 $this->_title = $title;
208 if ($scope) {
209 $this->_scope = $scope;
210 }
211 else {
212 $this->_scope = CRM_Utils_System::getClassName($this);
213 }
214 $this->_scope = $this->_scope . '_' . $this->_key;
215
216 // only use the civicrm cache if we have a valid key
217 // else we clash with other users CRM-7059
218 if (!empty($this->_key)) {
219 CRM_Core_Session::registerAndRetrieveSessionObjects(array(
220 "_{$name}_container",
221 array('CiviCRM', $this->_scope),
222 ));
223 }
224
225 $this->HTML_QuickForm_Controller($name, $modal);
226
227 $snippet = CRM_Utils_Array::value('snippet', $_REQUEST);
228 if ($snippet) {
229 if ($snippet == 3) {
230 $this->_print = CRM_Core_Smarty::PRINT_PDF;
231 }
232 elseif ($snippet == 4) {
233 // this is used to embed fragments of a form
234 $this->_print = CRM_Core_Smarty::PRINT_NOFORM;
235 self::$_template->assign('suppressForm', TRUE);
236 $this->_generateQFKey = FALSE;
237 }
238 elseif ($snippet == 5) {
239 // this is used for popups and inlined ajax forms
240 // also used for the various tabs via TabHeader
241 $this->_print = CRM_Core_Smarty::PRINT_NOFORM;
242 }
243 // Respond with JSON if in AJAX context (also support legacy value '6')
244 elseif (in_array($snippet, array(CRM_Core_Smarty::PRINT_JSON, 6))) {
245 $this->_print = CRM_Core_Smarty::PRINT_JSON;
246 $this->_QFResponseType = 'json';
247 }
248 else {
249 $this->_print = CRM_Core_Smarty::PRINT_SNIPPET;
250 }
251 }
252
253 // if the request has a reset value, initialize the controller session
254 if (!empty($_GET['reset'])) {
255 $this->reset();
256
257 // in this case we'll also cache the url as a hidden form variable, this allows us to
258 // redirect in case the session has disappeared on us
259 $this->_entryURL = CRM_Utils_System::makeURL(NULL, TRUE, FALSE, NULL, TRUE);
260 $this->set('entryURL', $this->_entryURL);
261 }
262
263 // set the key in the session
264 // do this at the end so we have initialized the object
265 // and created the scope etc
266 $this->set('qfKey', $this->_key);
267
268
269 // also retrieve and store destination in session
270 $this->_destination = CRM_Utils_Request::retrieve(
271 'civicrmDestination',
272 'String',
273 $this,
274 FALSE,
275 NULL,
276 $_REQUEST
277 );
278 }
279
280 function fini() {
281 CRM_Core_BAO_Cache::storeSessionToCache(array(
282 "_{$this->_name}_container",
283 array('CiviCRM', $this->_scope),
284 ),
285 TRUE
286 );
287 }
288
289 function key($name, $addSequence = FALSE, $ignoreKey = FALSE) {
290 $config = CRM_Core_Config::singleton();
291
292 if (
293 $ignoreKey ||
294 (isset($config->keyDisable) && $config->keyDisable)
295 ) {
296 return NULL;
297 }
298
299 $key = CRM_Utils_Array::value('qfKey', $_REQUEST, NULL);
300 if (!$key && $_SERVER['REQUEST_METHOD'] === 'GET') {
301 $key = CRM_Core_Key::get($name, $addSequence);
302 }
303 else {
304 $key = CRM_Core_Key::validate($key, $name, $addSequence);
305 }
306
307 if (!$key) {
308 $this->invalidKey();
309 }
310
311 $this->_key = $key;
312
313 return $key;
314 }
315
316 /**
317 * Process the request, overrides the default QFC run method
318 * This routine actually checks if the QFC is modal and if it
319 * is the first invalid page, if so it call the requested action
320 * if not, it calls the display action on the first invalid page
321 * avoids the issue of users hitting the back button and getting
322 * a broken page
323 *
324 * This run is basically a composition of the original run and the
325 * jump action
326 *
327 */
328 function run() {
329 // the names of the action and page should be saved
330 // note that this is split into two, because some versions of
331 // php 5.x core dump on the triple assignment :)
332 $this->_actionName = $this->getActionName();
333 list($pageName, $action) = $this->_actionName;
334
335 if ($this->isModal()) {
336 if (!$this->isValid($pageName)) {
337 $pageName = $this->findInvalid();
338 $action = 'display';
339 }
340 }
341
342 // note that based on action, control might not come back!!
343 // e.g. if action is a valid JUMP, u basically do a redirect
344 // to the appropriate place
345 $this->wizardHeader($pageName);
346 return $this->_pages[$pageName]->handle($action);
347 }
348
349 function validate() {
350 $this->_actionName = $this->getActionName();
351 list($pageName, $action) = $this->_actionName;
352
353 $page = &$this->_pages[$pageName];
354
355 $data = &$this->container();
356 $this->applyDefaults($pageName);
357 $page->isFormBuilt() or $page->buildForm();
358 // We use defaults and constants as if they were submitted
359 $data['values'][$pageName] = $page->exportValues();
360 $page->loadValues($data['values'][$pageName]);
361 // Is the page now valid?
362 if (TRUE === ($data['valid'][$pageName] = $page->validate())) {
363 return TRUE;
364 }
365 return $page->_errors;
366 }
367
368 /**
369 * Helper function to add all the needed default actions. Note that the framework
370 * redefines all of the default QFC actions
371 *
372 * @param string directory to store all the uploaded files
373 * @param array names for the various upload buttons (note u can have more than 1 upload)
374 *
375 * @access private
376 *
377 * @return void
378 *
379 */
380 function addActions($uploadDirectory = NULL, $uploadNames = NULL) {
381 $names = array(
382 'display' => 'CRM_Core_QuickForm_Action_Display',
383 'next' => 'CRM_Core_QuickForm_Action_Next',
384 'back' => 'CRM_Core_QuickForm_Action_Back',
385 'process' => 'CRM_Core_QuickForm_Action_Process',
386 'cancel' => 'CRM_Core_QuickForm_Action_Cancel',
387 'refresh' => 'CRM_Core_QuickForm_Action_Refresh',
388 'reload' => 'CRM_Core_QuickForm_Action_Reload',
389 'done' => 'CRM_Core_QuickForm_Action_Done',
390 'jump' => 'CRM_Core_QuickForm_Action_Jump',
391 'submit' => 'CRM_Core_QuickForm_Action_Submit',
392 );
393
394 foreach ($names as $name => $classPath) {
395 $action = new $classPath($this->_stateMachine);
396 $this->addAction($name, $action);
397 }
398
399 $this->addUploadAction($uploadDirectory, $uploadNames);
400 }
401
402 /**
403 * getter method for stateMachine
404 *
405 * @return object
406 * @access public
407 */
408 function getStateMachine() {
409 return $this->_stateMachine;
410 }
411
412 /**
413 * setter method for stateMachine
414 *
415 * @param object a stateMachineObject
416 *
417 * @return void
418 * @access public
419 */
420 function setStateMachine($stateMachine) {
421 $this->_stateMachine = $stateMachine;
422 }
423
424 /**
425 * add pages to the controller. Note that the controller does not really care
426 * the order in which the pages are added
427 *
428 * @param object $stateMachine the state machine object
429 * @param \const|int $action the mode in which the state machine is operating
430 * typicaly this will be add/view/edit
431 *
432 * @return void
433 * @access public
434 */
435 function addPages(&$stateMachine, $action = CRM_Core_Action::NONE) {
436 $pages = $stateMachine->getPages();
437 foreach ($pages as $name => $value) {
438 $className = CRM_Utils_Array::value('className', $value, $name);
439 $title = CRM_Utils_Array::value('title', $value);
440 $options = CRM_Utils_Array::value('options', $value);
441 $stateName = CRM_Utils_String::getClassName($className);
442 if (!empty($value['className'])) {
443 $formName = $name;
444 }
445 else {
446 $formName = CRM_Utils_String::getClassName($name);
447 }
448
449 $ext = CRM_Extension_System::singleton()->getMapper();
450 if ($ext->isExtensionClass($className)) {
451 require_once ($ext->classToPath($className));
452 }
453 else {
454 require_once (str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php');
455 }
456 $$stateName = new $className($stateMachine->find($className), $action, 'post', $formName);
457 if ($title) {
458 $$stateName->setTitle($title);
459 }
460 if ($options) {
461 $$stateName->setOptions($options);
462 }
463 if (property_exists($$stateName, 'urlPath') && isset($_GET[CRM_Core_Config::singleton()->userFrameworkURLVar])) {
464 $$stateName->urlPath = explode('/', $_GET[CRM_Core_Config::singleton()->userFrameworkURLVar]);
465 }
466 $this->addPage($$stateName);
467 $this->addAction($stateName, new HTML_QuickForm_Action_Direct());
468
469 //CRM-6342 -we need kill the reference here,
470 //as we have deprecated reference object creation.
471 unset($$stateName);
472 }
473 }
474
475 /**
476 * QFC does not provide native support to have different 'submit' buttons.
477 * We introduce this notion to QFC by using button specific data. Thus if
478 * we have two submit buttons, we could have one displayed as a button and
479 * the other as an image, both are of type 'submit'.
480 *
481 * @return string the name of the button that has been pressed by the user
482 * @access public
483 */
484 function getButtonName() {
485 $data = &$this->container();
486 return CRM_Utils_Array::value('_qf_button_name', $data);
487 }
488
489 /**
490 * function to destroy all the session state of the controller.
491 *
492 * @access public
493 *
494 * @return void
495 */
496 function reset() {
497 $this->container(TRUE);
498 self::$_session->resetScope($this->_scope);
499 }
500
501 /**
502 * virtual function to do any processing of data.
503 * Sometimes it is useful for the controller to actually process data.
504 * This is typically used when we need the controller to figure out
505 * what pages are potentially involved in this wizard. (this is dynamic
506 * and can change based on the arguments
507 *
508 * @return void
509 * @access public
510 */
511 function process() {}
512
513 /**
514 * Store the variable with the value in the form scope
515 *
516 * @param string|array $name name of the variable or an assoc array of name/value pairs
517 * @param mixed $value value of the variable if string
518 *
519 * @access public
520 *
521 * @return void
522 *
523 */
524 function set($name, $value = NULL) {
525 self::$_session->set($name, $value, $this->_scope);
526 }
527
528 /**
529 * Get the variable from the form scope
530 *
531 * @param string name : name of the variable
532 *
533 * @access public
534
535 *
536 * @return mixed
537 *
538 */
539 function get($name) {
540 return self::$_session->get($name, $this->_scope);
541 }
542
543 /**
544 * Create the header for the wizard from the list of pages
545 * Store the created header in smarty
546 *
547 * @param string $currentPageName name of the page being displayed
548 *
549 * @return array
550 * @access public
551 */
552 function wizardHeader($currentPageName) {
553 $wizard = array();
554 $wizard['steps'] = array();
555 $count = 0;
556 foreach ($this->_pages as $name => $page) {
557 $count++;
558 $wizard['steps'][] = array(
559 'name' => $name,
560 'title' => $page->getTitle(),
561 //'link' => $page->getLink ( ),
562 'link' => NULL,
563 'step' => TRUE,
564 'valid' => TRUE,
565 'stepNumber' => $count,
566 'collapsed' => FALSE,
567 );
568
569 if ($name == $currentPageName) {
570 $wizard['currentStepNumber'] = $count;
571 $wizard['currentStepName'] = $name;
572 $wizard['currentStepTitle'] = $page->getTitle();
573 }
574 }
575
576 $wizard['stepCount'] = $count;
577
578 $this->addWizardStyle($wizard);
579
580 $this->assign('wizard', $wizard);
581 return $wizard;
582 }
583
584 function addWizardStyle(&$wizard) {
585 $wizard['style'] = array(
586 'barClass' => '',
587 'stepPrefixCurrent' => '&raquo;',
588 'stepPrefixPast' => '&radic;',
589 'stepPrefixFuture' => ' ',
590 'subStepPrefixCurrent' => '&nbsp;&nbsp;',
591 'subStepPrefixPast' => '&nbsp;&nbsp;',
592 'subStepPrefixFuture' => '&nbsp;&nbsp;',
593 'showTitle' => 1,
594 );
595 }
596
597 /**
598 * assign value to name in template
599 *
600 * @param $var
601 * @param mixed $value value of varaible
602 *
603 * @internal param array|string $name name of variable
604 * @return void
605 * @access public
606 */
607 function assign($var, $value = NULL) {
608 self::$_template->assign($var, $value);
609 }
610
611 /**
612 * assign value to name in template by reference
613 *
614 * @param $var
615 * @param mixed $value (reference) value of varaible
616 *
617 * @internal param array|string $name name of variable
618 * @return void
619 * @access public
620 */
621 function assign_by_ref($var, &$value) {
622 self::$_template->assign_by_ref($var, $value);
623 }
624
625 /**
626 * appends values to template variables
627 *
628 * @param array|string $tpl_var the template variable name(s)
629 * @param mixed $value the value to append
630 * @param bool $merge
631 */
632 function append($tpl_var, $value=NULL, $merge=FALSE) {
633 self::$_template->append($tpl_var, $value, $merge);
634 }
635
636 /**
637 * Returns an array containing template variables
638 *
639 * @param string $name
640 *
641 * @internal param string $type
642 * @return array
643 */
644 function get_template_vars($name=null) {
645 return self::$_template->get_template_vars($name);
646 }
647
648 /**
649 * setter for embedded
650 *
651 * @param boolean $embedded
652 *
653 * @return void
654 * @access public
655 */
656 function setEmbedded($embedded) {
657 $this->_embedded = $embedded;
658 }
659
660 /**
661 * getter for embedded
662 *
663 * @return boolean return the embedded value
664 * @access public
665 */
666 function getEmbedded() {
667 return $this->_embedded;
668 }
669
670 /**
671 * setter for skipRedirection
672 *
673 * @param boolean $skipRedirection
674 *
675 * @return void
676 * @access public
677 */
678 function setSkipRedirection($skipRedirection) {
679 $this->_skipRedirection = $skipRedirection;
680 }
681
682 /**
683 * getter for skipRedirection
684 *
685 * @return boolean return the skipRedirection value
686 * @access public
687 */
688 function getSkipRedirection() {
689 return $this->_skipRedirection;
690 }
691
692 function setWord($fileName = NULL) {
693 //Mark as a CSV file.
694 header('Content-Type: application/vnd.ms-word');
695
696 //Force a download and name the file using the current timestamp.
697 if (!$fileName) {
698 $fileName = 'Contacts_' . $_SERVER['REQUEST_TIME'] . '.doc';
699 }
700 header("Content-Disposition: attachment; filename=Contacts_$fileName");
701 }
702
703 function setExcel($fileName = NULL) {
704 //Mark as an excel file.
705 header('Content-Type: application/vnd.ms-excel');
706
707 //Force a download and name the file using the current timestamp.
708 if (!$fileName) {
709 $fileName = 'Contacts_' . $_SERVER['REQUEST_TIME'] . '.xls';
710 }
711
712 header("Content-Disposition: attachment; filename=Contacts_$fileName");
713 }
714
715 /**
716 * setter for print
717 *
718 * @param boolean $print
719 *
720 * @return void
721 * @access public
722 */
723 function setPrint($print) {
724 if ($print == "xls") {
725 $this->setExcel();
726 }
727 elseif ($print == "doc") {
728 $this->setWord();
729 }
730 $this->_print = $print;
731 }
732
733 /**
734 * getter for print
735 *
736 * @return boolean return the print value
737 * @access public
738 */
739 function getPrint() {
740 return $this->_print;
741 }
742
743 function getTemplateFile() {
744 if ($this->_print) {
745 if ($this->_print == CRM_Core_Smarty::PRINT_PAGE) {
746 return 'CRM/common/print.tpl';
747 }
748 elseif ($this->_print == 'xls' || $this->_print == 'doc') {
749 return 'CRM/Contact/Form/Task/Excel.tpl';
750 }
751 else {
752 return 'CRM/common/snippet.tpl';
753 }
754 }
755 else {
756 $config = CRM_Core_Config::singleton();
757 return 'CRM/common/' . strtolower($config->userFramework) . '.tpl';
758 }
759 }
760
761 public function addUploadAction($uploadDir, $uploadNames) {
762 if (empty($uploadDir)) {
763 $config = CRM_Core_Config::singleton();
764 $uploadDir = $config->uploadDir;
765 }
766
767 if (empty($uploadNames)) {
768 $uploadNames = $this->get('uploadNames');
769 if (!empty($uploadNames)) {
770 $uploadNames = array_merge($uploadNames,
771 CRM_Core_BAO_File::uploadNames()
772 );
773 }
774 else {
775 $uploadNames = CRM_Core_BAO_File::uploadNames();
776 }
777 }
778
779 $action = new CRM_Core_QuickForm_Action_Upload($this->_stateMachine,
780 $uploadDir,
781 $uploadNames
782 );
783 $this->addAction('upload', $action);
784 }
785
786 public function setParent($parent) {
787 $this->_parent = $parent;
788 }
789
790 public function getParent() {
791 return $this->_parent;
792 }
793
794 public function getDestination() {
795 return $this->_destination;
796 }
797
798 public function setDestination($url = NULL, $setToReferer = FALSE) {
799 if (empty($url)) {
800 if ($setToReferer) {
801 $url = $_SERVER['HTTP_REFERER'];
802 }
803 else {
804 $config = CRM_Core_Config::singleton();
805 $url = $config->userFrameworkBaseURL;
806 }
807 }
808
809 $this->_destination = $url;
810 $this->set('civicrmDestination', $this->_destination);
811 }
812
813 public function cancelAction() {
814 $actionName = $this->getActionName();
815 list($pageName, $action) = $actionName;
816 return $this->_pages[$pageName]->cancelAction();
817 }
818
819 /**
820 * Write a simple fatal error message. Other controllers can decide to do something else
821 * and present the user a better message and/or redirect to the same page with a reset url
822 *
823 * @return void
824 *
825 */
826 public function invalidKey() {
827 self::invalidKeyCommon();
828 }
829
830 public function invalidKeyCommon() {
831 $msg = ts('We can\'t load the requested web page. This page requires cookies to be enabled in your browser settings. Please check this setting and enable cookies (if they are not enabled). Then try again. If this error persists, contact the site adminstrator for assistance.') . '<br /><br />' . ts('Site Administrators: This error may indicate that users are accessing this page using a domain or URL other than the configured Base URL. EXAMPLE: Base URL is http://example.org, but some users are accessing the page via http://www.example.org or a domain alias like http://myotherexample.org.') . '<br /><br />' . ts('Error type: Could not find a valid session key.');
832 CRM_Core_Error::fatal($msg);
833 }
834
835 /**
836 * Instead of outputting a fatal error message, we'll just redirect to the entryURL if present
837 *
838 * @return void
839 */
840 public function invalidKeyRedirect() {
841 if ($this->_entryURL) {
842 CRM_Core_Session::setStatus(ts('Your browser session has expired and we are unable to complete your form submission. We have returned you to the initial step so you can complete and resubmit the form. If you experience continued difficulties, please contact us for assistance.'));
843 return CRM_Utils_System::redirect($this->_entryURL);
844 }
845 else {
846 self::invalidKeyCommon();
847 }
848 }
849
850 }