2014-06-22 13:49:21 +02:00
|
|
|
<?php
|
2015-02-04 10:46:36 +01:00
|
|
|
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
2014-06-22 13:49:21 +02:00
|
|
|
|
|
|
|
namespace Icinga\Web;
|
|
|
|
|
|
|
|
use Zend_Controller_Response_Http;
|
2014-07-04 12:35:33 +02:00
|
|
|
use Icinga\Application\Icinga;
|
2014-06-22 13:49:21 +02:00
|
|
|
|
|
|
|
class Response extends Zend_Controller_Response_Http
|
|
|
|
{
|
2015-07-29 14:20:39 +02:00
|
|
|
/**
|
|
|
|
* Request
|
|
|
|
*
|
|
|
|
* @var Request
|
|
|
|
*/
|
|
|
|
protected $request;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the request
|
|
|
|
*
|
|
|
|
* @return Request
|
|
|
|
*/
|
|
|
|
public function getRequest()
|
|
|
|
{
|
|
|
|
if ($this->request === null) {
|
|
|
|
$this->request = Icinga::app()->getFrontController()->getRequest();
|
|
|
|
}
|
|
|
|
return $this->request;
|
|
|
|
}
|
|
|
|
|
2014-07-04 12:35:33 +02:00
|
|
|
public function redirectAndExit($url)
|
|
|
|
{
|
|
|
|
if (! $url instanceof Url) {
|
|
|
|
$url = Url::fromPath($url);
|
|
|
|
}
|
|
|
|
$url->getParams()->setSeparator('&');
|
|
|
|
|
2015-07-29 14:20:39 +02:00
|
|
|
if ($this->getRequest()->isXmlHttpRequest()) {
|
2014-09-12 09:14:13 +02:00
|
|
|
$this->setHeader('X-Icinga-Redirect', rawurlencode($url->getAbsoluteUrl()));
|
2014-07-04 12:35:33 +02:00
|
|
|
} else {
|
|
|
|
$this->setRedirect($url->getAbsoluteUrl());
|
|
|
|
}
|
2014-09-17 10:42:56 +02:00
|
|
|
|
|
|
|
$session = Session::getSession();
|
|
|
|
if ($session->hasChanged()) {
|
|
|
|
$session->write();
|
|
|
|
}
|
|
|
|
|
2014-07-04 12:35:33 +02:00
|
|
|
$this->sendHeaders();
|
|
|
|
exit;
|
|
|
|
}
|
2014-06-22 13:49:21 +02:00
|
|
|
}
|