parent
2bf9b96aab
commit
1b5b26c2bb
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var base_url = '<?= $this->baseUrl() ?>';
|
var base_url = '<?= $this->baseUrl() ?>';
|
||||||
|
var request_id = '<?= $this->requestId(); ?>';
|
||||||
ICINGA_DEBUG = true;
|
ICINGA_DEBUG = true;
|
||||||
</script>
|
</script>
|
||||||
<? if (isset($_GET['iframe']) && $_GET['iframe'] === 'true'): ?>
|
<? if (isset($_GET['iframe']) && $_GET['iframe'] === 'true'): ?>
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
<?php
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
/**
|
||||||
|
* This file is part of Icinga Web 2.
|
||||||
|
*
|
||||||
|
* Icinga Web 2 - Head for multiple monitoring backends.
|
||||||
|
* Copyright (C) 2014 Icinga Development Team
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
* @copyright 2014 Icinga Development Team <info@icinga.org>
|
||||||
|
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
|
||||||
|
* @author Icinga Development Team <info@icinga.org>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
|
||||||
|
use \Zend_Controller_Front;
|
||||||
|
use \Zend_View_Helper_Abstract;
|
||||||
|
|
||||||
|
|
||||||
|
class Zend_View_Helper_RequestId extends Zend_View_Helper_Abstract
|
||||||
|
{
|
||||||
|
public function requestId()
|
||||||
|
{
|
||||||
|
return Zend_Controller_Front::getInstance()->getRequest()->getId();
|
||||||
|
}
|
||||||
|
}
|
|
@ -63,4 +63,20 @@ class Request extends Zend_Controller_Request_Http
|
||||||
{
|
{
|
||||||
return $this->user;
|
return $this->user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a identifier to uniquely identify the request's source
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getId()
|
||||||
|
{
|
||||||
|
$requestId = $this->getParam('request_id');
|
||||||
|
|
||||||
|
if ($requestId === null) {
|
||||||
|
$requestId = substr('abcdefghijklmnopqrstuvwxyz', mt_rand(0, 25), 1) . substr(md5(time()), -7);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $requestId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,6 +48,24 @@ define([
|
||||||
*/
|
*/
|
||||||
var initialize = function () {
|
var initialize = function () {
|
||||||
components.load();
|
components.load();
|
||||||
|
|
||||||
|
// qd, wip, wrong, the nastiest piece of JS code you've ever seen..
|
||||||
|
if (window.name === '') {
|
||||||
|
window.name = request_id; // The request id should survive page reloads..
|
||||||
|
}
|
||||||
|
$(document).on('click', 'a', function() {
|
||||||
|
// TODO: The intention of these lines is sending the "request_id" every
|
||||||
|
// time a request is made, though this approach does not work for
|
||||||
|
// XHR requests and it is also hijacking external links.
|
||||||
|
// An alternative is required, once someone reworked the Javascript
|
||||||
|
// implementation so we have some sort of centralized place to handle
|
||||||
|
// stuff like that properly.
|
||||||
|
var href = $(this).attr('href');
|
||||||
|
window.location.href = URI(href).addSearch('request_id', window.name);
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
// qd, wip, wrong, the nastiest piece of JS code you've ever seen..
|
||||||
|
|
||||||
log.debug("Initialization finished");
|
log.debug("Initialization finished");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue