summaryrefslogtreecommitdiffstats
path: root/library/Icingadb/Setup/RedisPage.php
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 12:36:40 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 12:36:40 +0000
commita0901c4b7f2db488cb4fb3be2dd921a0308f4659 (patch)
treefafb393cf330a60df129ff10d0059eb7b14052a7 /library/Icingadb/Setup/RedisPage.php
parentInitial commit. (diff)
downloadicingadb-web-a0901c4b7f2db488cb4fb3be2dd921a0308f4659.tar.xz
icingadb-web-a0901c4b7f2db488cb4fb3be2dd921a0308f4659.zip
Adding upstream version 1.0.2.upstream/1.0.2upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'library/Icingadb/Setup/RedisPage.php')
-rw-r--r--library/Icingadb/Setup/RedisPage.php68
1 files changed, 68 insertions, 0 deletions
diff --git a/library/Icingadb/Setup/RedisPage.php b/library/Icingadb/Setup/RedisPage.php
new file mode 100644
index 0000000..3c0a741
--- /dev/null
+++ b/library/Icingadb/Setup/RedisPage.php
@@ -0,0 +1,68 @@
+<?php
+
+/* Icinga DB Web | (c) 2020 Icinga GmbH | GPLv2 */
+
+namespace Icinga\Module\Icingadb\Setup;
+
+use Icinga\Module\Icingadb\Forms\RedisConfigForm;
+use Icinga\Web\Form;
+
+class RedisPage extends Form
+{
+ public function init()
+ {
+ $this->setName('setup_icingadb_redis');
+ $this->setTitle(t('Icinga DB Redis'));
+ $this->addDescription(t(
+ 'Please fill out the connection details to access the Icinga DB Redis.'
+ ));
+ $this->setValidatePartial(true);
+ }
+
+ public function createElements(array $formData)
+ {
+ $redisConfigForm = new RedisConfigForm();
+ $redisConfigForm->createElements($formData);
+ if (isset($formData['redis_tls']) && $formData['redis_tls']) {
+ $redisConfigForm->getElement('redis_ca_pem')->setIgnore(false);
+ $redisConfigForm->getElement('redis_cert_pem')->setIgnore(false);
+ $redisConfigForm->getElement('redis_key_pem')->setIgnore(false);
+ }
+
+ $this->addElements($redisConfigForm->getElements());
+ $this->addDisplayGroups($redisConfigForm->getDisplayGroups());
+ }
+
+ public function isValid($formData)
+ {
+ if (! parent::isValid($formData)) {
+ return false;
+ }
+
+ if (($el = $this->getElement('skip_validation')) === null || ! $el->isChecked()) {
+ if (! RedisConfigForm::checkRedis($this)) {
+ if ($el === null) {
+ RedisConfigForm::addSkipValidationCheckbox($this);
+ RedisConfigForm::addInsecureCheckboxIfTls($this);
+ }
+
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ public function isValidPartial(array $formData)
+ {
+ if (! parent::isValidPartial($formData)) {
+ return false;
+ }
+
+ if (isset($formData['backend_validation'])) {
+ return RedisConfigForm::checkRedis($this);
+ }
+
+ return true;
+ }
+}