2013-08-12 15:58:26 +02:00
|
|
|
<?php
|
|
|
|
// @codingStandardsIgnoreStart
|
|
|
|
// {{{ICINGA_LICENSE_HEADER}}}
|
|
|
|
/**
|
|
|
|
* Icinga 2 Web - Head for multiple monitoring frontends
|
|
|
|
* Copyright (C) 2013 Icinga Development Team
|
2013-08-16 14:56:23 +02:00
|
|
|
*
|
2013-08-12 15:58:26 +02:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2013-08-16 14:56:23 +02:00
|
|
|
*
|
2013-08-12 15:58:26 +02:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2013-08-16 14:56:23 +02:00
|
|
|
*
|
2013-08-12 15:58:26 +02:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2013-08-16 14:56:23 +02:00
|
|
|
*
|
2013-08-12 15:58:26 +02:00
|
|
|
* @copyright 2013 Icinga Development Team <info@icinga.org>
|
|
|
|
* @author Icinga Development Team <info@icinga.org>
|
|
|
|
*/
|
|
|
|
// {{{ICINGA_LICENSE_HEADER}}}
|
|
|
|
|
2013-08-16 14:56:23 +02:00
|
|
|
use \Icinga\Application\Benchmark;
|
|
|
|
use \Icinga\Authentication\Manager;
|
|
|
|
use \Icinga\Web\Controller\BaseConfigController;
|
|
|
|
use \Icinga\Web\Widget\Tab;
|
|
|
|
use \Icinga\Web\Url;
|
|
|
|
use \Icinga\Web\Hook\Configuration\ConfigurationTabBuilder;
|
|
|
|
use \Icinga\Application\Icinga;
|
2013-08-14 10:53:25 +02:00
|
|
|
use \Icinga\Form\Config\GeneralForm;
|
2013-08-15 14:27:53 +02:00
|
|
|
use \Icinga\Form\Config\AuthenticationForm;
|
2013-08-14 10:53:25 +02:00
|
|
|
use \Icinga\Form\Config\LoggingForm;
|
|
|
|
use \Icinga\Config\PreservingIniWriter;
|
2013-08-12 15:58:26 +02:00
|
|
|
|
|
|
|
/**
|
2013-08-14 12:42:32 +02:00
|
|
|
* Application wide controller for application preferences
|
2013-08-12 15:58:26 +02:00
|
|
|
*/
|
|
|
|
class ConfigController extends BaseConfigController
|
|
|
|
{
|
2013-08-14 12:42:32 +02:00
|
|
|
/**
|
|
|
|
* Create tabs for this configuration controller
|
|
|
|
*
|
2013-08-16 14:56:23 +02:00
|
|
|
* @return array
|
|
|
|
*
|
|
|
|
* @see BaseConfigController::createProvidedTabs()
|
2013-08-14 12:42:32 +02:00
|
|
|
*/
|
2013-08-12 15:58:26 +02:00
|
|
|
public static function createProvidedTabs()
|
|
|
|
{
|
|
|
|
return array(
|
2013-08-16 14:56:23 +02:00
|
|
|
'index' => new Tab(
|
2013-08-12 15:58:26 +02:00
|
|
|
array(
|
2013-08-14 10:53:25 +02:00
|
|
|
"name" => "index",
|
|
|
|
"title" => "Application",
|
|
|
|
"url" => Url::fromPath("/config")
|
2013-08-12 15:58:26 +02:00
|
|
|
)
|
|
|
|
),
|
2013-08-15 14:27:53 +02:00
|
|
|
|
|
|
|
"authentication" => new Tab(
|
|
|
|
array(
|
|
|
|
"name" => "auth",
|
|
|
|
"title" => "Authentication",
|
|
|
|
"url" => Url::fromPath('/config/authentication')
|
|
|
|
)
|
|
|
|
),
|
|
|
|
|
2013-08-14 10:53:25 +02:00
|
|
|
"logging" => new Tab(
|
2013-08-12 15:58:26 +02:00
|
|
|
array(
|
2013-08-14 10:53:25 +02:00
|
|
|
"name" => "logging",
|
|
|
|
"title" => "Logging",
|
|
|
|
"url" => Url::fromPath("/config/logging")
|
|
|
|
)
|
|
|
|
),
|
|
|
|
"modules" => new Tab(
|
|
|
|
array(
|
|
|
|
"name" => "modules",
|
|
|
|
"title" => "Modules",
|
|
|
|
"url" => Url::fromPath("/config/moduleoverview")
|
2013-08-12 15:58:26 +02:00
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-08-14 12:42:32 +02:00
|
|
|
* Index action, entry point for configuration
|
|
|
|
* @TODO: Implement configuration interface (#3777)
|
2013-08-12 15:58:26 +02:00
|
|
|
*/
|
|
|
|
public function indexAction()
|
|
|
|
{
|
2013-08-14 10:53:25 +02:00
|
|
|
$form = new GeneralForm();
|
|
|
|
$form->setConfiguration(IcingaConfig::app());
|
|
|
|
$form->setRequest($this->_request);
|
|
|
|
if ($form->isSubmittedAndValid()) {
|
|
|
|
$cfg = IcingaConfig::app()->getConfigFile();
|
|
|
|
$writer = new PreservingIniWriter(
|
2013-08-14 14:52:47 +02:00
|
|
|
array(
|
|
|
|
'config' => $form->getConfig(),
|
|
|
|
'filename' => $cfg
|
|
|
|
)
|
2013-08-14 10:53:25 +02:00
|
|
|
);
|
2013-08-14 14:52:47 +02:00
|
|
|
$writer->write();
|
2013-08-14 10:53:25 +02:00
|
|
|
}
|
|
|
|
$this->view->form = $form;
|
|
|
|
}
|
|
|
|
|
2013-08-15 14:27:53 +02:00
|
|
|
public function authenticationAction()
|
|
|
|
{
|
|
|
|
$form = new AuthenticationForm();
|
|
|
|
$form->setConfiguration(IcingaConfig::app('authentication'));
|
|
|
|
$form->setRequest($this->_request);
|
|
|
|
$form->isSubmittedAndValid();
|
|
|
|
$this->view->form = $form;
|
|
|
|
}
|
|
|
|
|
2013-08-14 10:53:25 +02:00
|
|
|
public function loggingAction()
|
|
|
|
{
|
|
|
|
$form = new LoggingForm();
|
|
|
|
$form->setConfiguration(IcingaConfig::app());
|
|
|
|
$form->setRequest($this->_request);
|
2013-08-12 15:58:26 +02:00
|
|
|
|
2013-08-14 10:53:25 +02:00
|
|
|
$this->view->form = $form;
|
2013-08-12 15:58:26 +02:00
|
|
|
}
|
|
|
|
|
2013-08-14 12:42:32 +02:00
|
|
|
/**
|
|
|
|
* Display the list of all modules
|
|
|
|
*/
|
2013-08-12 15:58:26 +02:00
|
|
|
public function moduleoverviewAction()
|
|
|
|
{
|
|
|
|
$this->view->modules = Icinga::app()->getModuleManager()->select()
|
|
|
|
->from('modules')
|
|
|
|
->order('name');
|
|
|
|
$this->render('module/overview');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-08-14 12:42:32 +02:00
|
|
|
* Enable a specific module provided by the 'name' param
|
2013-08-12 15:58:26 +02:00
|
|
|
*/
|
|
|
|
public function moduleenableAction()
|
|
|
|
{
|
|
|
|
$manager = Icinga::app()->getModuleManager();
|
|
|
|
$manager->enableModule($this->_getParam('name'));
|
|
|
|
$manager->loadModule($this->_getParam('name'));
|
|
|
|
$this->redirectNow('config/moduleoverview?_render=body');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-08-14 12:42:32 +02:00
|
|
|
* Disable a module specific module provided by the 'name' param
|
2013-08-12 15:58:26 +02:00
|
|
|
*/
|
|
|
|
public function moduledisableAction()
|
|
|
|
{
|
|
|
|
$manager = Icinga::app()->getModuleManager();
|
|
|
|
$manager->disableModule($this->_getParam('name'));
|
|
|
|
$this->redirectNow('config/moduleoverview?_render=body');
|
|
|
|
}
|
2013-08-14 10:53:25 +02:00
|
|
|
|
|
|
|
|
2013-08-12 15:58:26 +02:00
|
|
|
}
|
2013-08-16 14:56:23 +02:00
|
|
|
// @codingStandardsIgnoreEnd
|