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