+
= $this->translate('Authentication Configuration'); ?>
diff --git a/application/views/scripts/mixedPagination.phtml b/application/views/scripts/mixedPagination.phtml
index 4704d8f51..160657b12 100644
--- a/application/views/scripts/mixedPagination.phtml
+++ b/application/views/scripts/mixedPagination.phtml
@@ -9,8 +9,8 @@ use Icinga\Web\Url;
if ($this->pageCount <= 1) return;
-?>
= t('Pagination') ?>
-= t('Pagination') ?>
+- create();
+ if ($this->protectIds) {
+ if (null !== $this->getAttrib('id')) {
+ $this->setAttrib('id', $this->getRequest()->protectId($this->getAttrib('id')));
+ } else {
+ $this->setAttrib('id', $this->getRequest()->protectId($this->name));
+ }
+
+ /** @var Zend_Form_Element $element */
+ foreach ($this->getElements() as $element) {
+ if (null !== $element->getAttrib('id')) {
+ $element->setAttrib(
+ 'id',
+ $this->getRequest()->protectId($this->getName() . '-' . $element->getAttrib('id'))
+ );
+ } else {
+ $element->setAttrib(
+ 'id',
+ $this->getRequest()->protectId($this->getName() . '-' . $element->getName())
+ );
+ }
+ }
+ }
return parent::render($view);
}
@@ -944,4 +973,29 @@ class Form extends Zend_Form
throw new SecurityException('No permission for %s', $permission);
}
}
+
+ /**
+ * Enable or disable whether ids should be altered to guard them against duplications
+ *
+ * @param $value boolean Whether or not protect ids against collisions through other requests
+ */
+ public function setProtectIds($value)
+ {
+ $this->protectIds = $value;
+ }
+
+ /**
+ * Get the id that is written into the output html when rendering this form
+ *
+ * This will return the protected id, in case $protectIds is enabled.
+ *
+ * @return string The id
+ */
+ public function getId()
+ {
+ if ($this->protectIds) {
+ return $this->getRequest()->protectId($this->getName());
+ }
+ return $this->getName();
+ }
}
diff --git a/library/Icinga/Web/Request.php b/library/Icinga/Web/Request.php
index 4dd57df91..90551b33c 100644
--- a/library/Icinga/Web/Request.php
+++ b/library/Icinga/Web/Request.php
@@ -18,6 +18,11 @@ class Request extends Zend_Controller_Request_Http
*/
private $user;
+ /**
+ * @var string
+ */
+ private $uniqueId;
+
private $url;
public function getUrl()
@@ -47,4 +52,19 @@ class Request extends Zend_Controller_Request_Http
{
return $this->user;
}
+
+ /**
+ * Makes an ID unique to this request, to prevent id collisions in different containers
+ *
+ * Call this whenever an ID might show up multiple times in different containers. This function is useful
+ * for ensuring unique ids on sites, even if we combine the HTML of different requests into one site,
+ * while still being able to reference elements uniquely in the same request.
+ */
+ public function protectId($id)
+ {
+ if (! isset($this->uniqueId)) {
+ $this->uniqueId = Window::generateId();
+ }
+ return $id . '-' . $this->uniqueId;
+ }
}
diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php
index 3fb782856..60c669f93 100644
--- a/modules/monitoring/application/controllers/ListController.php
+++ b/modules/monitoring/application/controllers/ListController.php
@@ -702,7 +702,7 @@ class Monitoring_ListController extends Controller
private function setupSortControl(array $columns)
{
$this->view->sortControl = new SortBox(
- $this->getRequest()->getActionName(),
+ 'sortbox-' . $this->getRequest()->getActionName(),
$columns
);
$this->view->sortControl->applyRequest($this->getRequest());