From 40aa45c926a1016ea6b26cce906b17d141d77dcf Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Sun, 16 Sep 2007 15:34:05 +0000 Subject: [PATCH] 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 --- core/control/Director.php | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/core/control/Director.php b/core/control/Director.php index 8748314b6..a78d7d18f 100644 --- a/core/control/Director.php +++ b/core/control/Director.php @@ -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); }