diff --git a/library/Icinga/Web/Controller/ActionController.php b/library/Icinga/Web/Controller/ActionController.php index 3761cfa8a..c744fe0f8 100644 --- a/library/Icinga/Web/Controller/ActionController.php +++ b/library/Icinga/Web/Controller/ActionController.php @@ -370,13 +370,19 @@ class ActionController extends Zend_Controller_Action **/ public function redirectNow($url) { - if ($url instanceof Url) { - $url = $url->getRelativeUrl(); - } else { - $url = Url::fromPath($url)->getRelativeUrl(); + if (! $url instanceof Url) { + $url = Url::fromPath($url); } - $this->_helper->Redirector->gotoUrlAndExit(preg_replace('~&~', '&', $url)); - $this->isRedirect = true; + $url = preg_replace('~&~', '&', $url); + if ($this->_request->isXmlHttpRequest()) { + header('X-Icinga-Redirect: ' . rawurlencode($url)); + // $this->getResponse()->sendHeaders() ?? + // Session shutdown + exit; // Really? + } else { + $this->_helper->Redirector->gotoUrlAndExit($url); + } + $this->isRedirect = true; // pretty useless right now } /** diff --git a/public/js/icinga/loader.js b/public/js/icinga/loader.js index c659a91e7..39ed77b1e 100644 --- a/public/js/icinga/loader.js +++ b/public/js/icinga/loader.js @@ -244,6 +244,15 @@ this.icinga.logger.debug( 'Got response for ', req.$target, ', URL was ' + url ); + var redirect = req.getResponseHeader('X-Icinga-Redirect'); + if (redirect) { + this.icinga.logger.debug( + 'Got redirect for ', req.$target, ', URL was ' + redirect + ); + redirect = decodeURIComponent(redirect); + this.loadUrl(redirect, req.$target); + return; + } // div helps getting an XML tree var $resp = $('