summaryrefslogtreecommitdiffstats
path: root/application/controllers
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 13:20:19 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 13:20:19 +0000
commit7b64af59410f1a658c70b8be367156fc3f4da17c (patch)
tree367fc1ef06004119d3941460a22c4f83b1ca4d7d /application/controllers
parentInitial commit. (diff)
downloadicingaweb2-module-generictts-7b64af59410f1a658c70b8be367156fc3f4da17c.tar.xz
icingaweb2-module-generictts-7b64af59410f1a658c70b8be367156fc3f4da17c.zip
Adding upstream version 2.1.0.upstream/2.1.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--application/controllers/IntegrationsController.php118
1 files changed, 118 insertions, 0 deletions
diff --git a/application/controllers/IntegrationsController.php b/application/controllers/IntegrationsController.php
new file mode 100644
index 0000000..340e15d
--- /dev/null
+++ b/application/controllers/IntegrationsController.php
@@ -0,0 +1,118 @@
+<?php
+
+/* Icinga Web 2 | (c) 2016 Icinga Development Team | GPLv2+ */
+
+namespace Icinga\Module\Generictts\Controllers;
+
+use Icinga\Exception\NotFoundError;
+use Icinga\Forms\ConfirmRemovalForm;
+use Icinga\Module\Generictts\Forms\Config\TtsIntegrationConfigForm;
+use Icinga\Web\Controller;
+use Icinga\Web\Notification;
+
+/**
+ * Manage trouble ticket system integrations
+ */
+class IntegrationsController extends Controller
+{
+ /**
+ * List trouble ticket system integrations
+ */
+ public function indexAction()
+ {
+ $this->getTabs()->add('integrations', array(
+ 'active' => true,
+ 'label' => $this->translate('Integrations'),
+ 'url' => $this->getRequest()->getUrl()
+ ));
+ $this->view->integrations = $this->Config();
+ }
+
+ /**
+ * Integrate a new trouble ticket system
+ */
+ public function newAction()
+ {
+ $this->getTabs()->add('new-integration', array(
+ 'active' => true,
+ 'label' => $this->translate('New Integration'),
+ 'url' => $this->getRequest()->getUrl()
+ ));
+
+ $integrations = new TtsIntegrationConfigForm();
+ $integrations
+ ->setIniConfig($this->Config())
+ ->setRedirectUrl('generictts/integrations')
+ ->handleRequest();
+
+ $this->view->form = $integrations;
+ }
+
+ /**
+ * Remove a trouble ticket system integration
+ */
+ public function removeAction()
+ {
+ $integration = $this->params->getRequired('integration');
+
+ $this->getTabs()->add('remove-integration', array(
+ 'active' => true,
+ 'label' => $this->translate('Remove Integration'),
+ 'url' => $this->getRequest()->getUrl()
+ ));
+
+ $integrations = new TtsIntegrationConfigForm();
+ try {
+ $integrations
+ ->setIniConfig($this->Config())
+ ->bind($integration);
+ } catch (NotFoundError $e) {
+ $this->httpNotFound($e->getMessage());
+ }
+
+ $confirmation = new ConfirmRemovalForm(array(
+ 'onSuccess' => function (ConfirmRemovalForm $confirmation) use ($integration, $integrations) {
+ $integrations->remove($integration);
+ if ($integrations->save()) {
+ Notification::success(mt('generictts', 'TTS integration removed'));
+ return true;
+ }
+ return false;
+ }
+ ));
+ $confirmation
+ ->setRedirectUrl('generictts/integrations')
+ ->setSubmitLabel($this->translate('Remove Integration'))
+ ->handleRequest();
+
+ $this->view->form = $confirmation;
+ }
+
+ /**
+ * Update a trouble ticket system integration
+ */
+ public function updateAction()
+ {
+ $integration = $this->params->getRequired('integration');
+
+ $this->getTabs()->add('update-integration', array(
+ 'active' => true,
+ 'label' => $this->translate('Update Integration'),
+ 'url' => $this->getRequest()->getUrl()
+ ));
+
+ $integrations = new TtsIntegrationConfigForm();
+ try {
+ $integrations
+ ->setIniConfig($this->Config())
+ ->bind($integration);
+ } catch (NotFoundError $e) {
+ $this->httpNotFound($e->getMessage());
+ }
+ $integrations
+ ->setRedirectUrl('generictts/integrations')
+ ->handleRequest();
+
+ $this->view->form = $integrations;
+ }
+}