diff --git a/application/layouts/scripts/layout.phtml b/application/layouts/scripts/layout.phtml
index 8141acf68..914cddaaf 100755
--- a/application/layouts/scripts/layout.phtml
+++ b/application/layouts/scripts/layout.phtml
@@ -20,6 +20,7 @@
if (isset($_GET['iframe']) && $_GET['iframe'] === 'true'): ?>
diff --git a/application/views/helpers/RequestId.php b/application/views/helpers/RequestId.php
new file mode 100644
index 000000000..6eb4fb0c8
--- /dev/null
+++ b/application/views/helpers/RequestId.php
@@ -0,0 +1,40 @@
+
+ * @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
+ * @author Icinga Development Team
+ *
+ */
+// {{{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();
+ }
+}
diff --git a/library/Icinga/Web/Request.php b/library/Icinga/Web/Request.php
index 95a5a2a37..8d6114d8a 100644
--- a/library/Icinga/Web/Request.php
+++ b/library/Icinga/Web/Request.php
@@ -63,4 +63,20 @@ class Request extends Zend_Controller_Request_Http
{
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;
+ }
}
diff --git a/public/js/icinga/icinga.js b/public/js/icinga/icinga.js
index dfbf4f6e4..a816b1494 100755
--- a/public/js/icinga/icinga.js
+++ b/public/js/icinga/icinga.js
@@ -48,6 +48,24 @@ define([
*/
var initialize = function () {
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");
};