From 7b64af59410f1a658c70b8be367156fc3f4da17c Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 14 Apr 2024 15:20:19 +0200 Subject: Adding upstream version 2.1.0. Signed-off-by: Daniel Baumann --- application/controllers/IntegrationsController.php | 118 +++++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 application/controllers/IntegrationsController.php (limited to 'application/controllers') 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 @@ +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; + } +} -- cgit v1.2.3