From 598d26f0f97586ffd9bbeda41b94841eca797d87 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Thu, 24 Feb 2022 16:13:33 +0100 Subject: [PATCH] Drop class `SetAsBackendConfigForm` --- application/controllers/ConfigController.php | 10 -- application/forms/SetAsBackendConfigForm.php | 105 ------------------- configuration.php | 9 -- 3 files changed, 124 deletions(-) delete mode 100644 application/forms/SetAsBackendConfigForm.php diff --git a/application/controllers/ConfigController.php b/application/controllers/ConfigController.php index e5dfed36..0d64fbfe 100644 --- a/application/controllers/ConfigController.php +++ b/application/controllers/ConfigController.php @@ -5,7 +5,6 @@ namespace Icinga\Module\Icingadb\Controllers; use Icinga\Application\Config; -use Icinga\Module\Icingadb\Forms\SetAsBackendConfigForm; use Icinga\Module\Icingadb\Forms\DatabaseConfigForm; use Icinga\Module\Icingadb\Forms\RedisConfigForm; use Icinga\Module\Icingadb\Web\Controller; @@ -47,15 +46,6 @@ class ConfigController extends Controller $this->addFormToContent($form); } - public function backendAction() - { - $form = new SetAsBackendConfigForm(); - $form->handleRequest(); - - $this->mergeTabs($this->Module()->getConfigTabs()->activate('backend')); - $this->addFormToContent($form); - } - protected function addFormToContent(Form $form) { $this->addContent(new HtmlString($form->render())); diff --git a/application/forms/SetAsBackendConfigForm.php b/application/forms/SetAsBackendConfigForm.php deleted file mode 100644 index 79c75ae0..00000000 --- a/application/forms/SetAsBackendConfigForm.php +++ /dev/null @@ -1,105 +0,0 @@ -addElement('checkbox', 'backend', [ - 'label' => t('Use icinga DB as backend for all modules'), - 'description' => t('Use icinga db as backend resource for all modules'), - 'value' => IcingadbSupportHook::isIcingaDbSetAsPreferredBackend(), - ]); - - $this->addElement( - 'submit', - 'btn_submit', - array( - 'ignore' => true, - 'label' => t('Save to the Preferences'), - 'decorators' => array('ViewHelper'), - 'class' => 'btn-primary' - ) - ); - - $this->addElement( - 'submit', - 'btn_submit_session', - array( - 'ignore' => true, - 'label' => t('Save for the current Session'), - 'decorators' => array('ViewHelper') - ) - ); - - $this->setAttrib('data-progress-element', 'preferences-progress'); - $this->addElement( - 'note', - 'preferences-progress', - array( - 'decorators' => array( - 'ViewHelper', - array('Spinner', array('id' => 'preferences-progress')) - ) - ) - ); - - $this->addDisplayGroup( - array('btn_submit', 'btn_submit_session', 'preferences-progress'), - 'submit_buttons', - array( - 'decorators' => array( - 'FormElements', - array('HtmlTag', array('tag' => 'div', 'class' => 'control-group form-controls')) - ) - ) - ); - } - - public function onSuccess() - { - $this->save($this->getElement('backend')->isChecked()); - } - - public function save($setAsBackend) - { - $user = Auth::getInstance()->getUser(); - try { - $preferencesStore = PreferencesStore::create(new ConfigObject([ - 'store' => Config::app()->get('global', 'config_backend', 'db'), - 'resource' => Config::app()->get('global', 'config_resource') - ]), $user); - $preferences = new Preferences($preferencesStore->load()); - $webPreferences = $user->getPreferences()->get('icingaweb'); - - $webPreferences[IcingadbSupportHook::PREFERENCE_NAME] = $setAsBackend; - $preferences->icingaweb = $webPreferences; - } catch (Exception $e) { - Notification::error('Failed to save the preference'); - return; - } - - Session::getSession()->user->setPreferences($preferences); - - if ($this->getElement('btn_submit') !== null && $this->getElement('btn_submit')->isChecked()) { - $preferencesStore->save($preferences); - Notification::success($this->translate('Preference successfully saved')); - } else { - Notification::success($this->translate('Preference successfully saved for the current session')); - } - } -} diff --git a/configuration.php b/configuration.php index a97af946..115ac3bc 100644 --- a/configuration.php +++ b/configuration.php @@ -540,15 +540,6 @@ namespace Icinga\Module\Icingadb { 'title' => t('Configure the database backend'), 'url' => 'config/database' ]); - - if ($this::exists('monitoring')) { - $this->provideConfigTab('backend', [ - 'label' => t('Backend'), - 'title' => t('Configure IcingaDB as the Backend'), - 'url' => 'config/backend' - ]); - } - $this->provideConfigTab('redis', [ 'label' => t('Redis'), 'title' => t('Configure the Redis connections'),