mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
mlanthaler: Director::redirectBack() redirects now to the base URL if neither the referer nor the _REDIRECT_BACK_URL is set.
(merged from branches/gsoc) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@42093 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
e9d323b0d8
commit
40aa45c926
@ -207,13 +207,25 @@ class Director {
|
||||
Controller::curr()->redirectedTo();
|
||||
}
|
||||
|
||||
/**
|
||||
* Uses either the HTTP_REFERER or a manually set request-variable called _REDIRECT_BACK_URL.
|
||||
* This variable is needed in scenarios where not HTTP-Referer is sent (e.g when calling a page
|
||||
* by location.href in IE).
|
||||
*/
|
||||
/*
|
||||
* Redirect back
|
||||
*
|
||||
* Uses either the HTTP_REFERER or a manually set request-variable called
|
||||
* _REDIRECT_BACK_URL.
|
||||
* This variable is needed in scenarios where not HTTP-Referer is sent (
|
||||
* e.g when calling a page by location.href in IE).
|
||||
* If none of the two variables is available, it will redirect to the base
|
||||
* URL (see {@link baseURL()}).
|
||||
*/
|
||||
static function redirectBack() {
|
||||
$url = (isset($_REQUEST['_REDIRECT_BACK_URL'])) ? $_REQUEST['_REDIRECT_BACK_URL'] : $_SERVER['HTTP_REFERER'];
|
||||
$url = self::baseURL();
|
||||
|
||||
if(isset($_REQUEST['_REDIRECT_BACK_URL'])) {
|
||||
$url = $_REQUEST['_REDIRECT_BACK_URL'];
|
||||
} else if(isset($_SERVER['HTTP_REFERER'])) {
|
||||
$_SERVER['HTTP_REFERER'];
|
||||
}
|
||||
|
||||
Director::redirect($url);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user