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