mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-31 01:34:09 +02:00
Fix messages in ConfigController
Store messages in the current user session to be able to fetch messages from other controllers, so that the use can be redirected back to the index, instead of staying in the original action refs #5100
This commit is contained in:
parent
941ce6d68e
commit
2a0add3ec3
@ -30,13 +30,15 @@
|
|||||||
|
|
||||||
use \Icinga\Web\Controller\BaseConfigController;
|
use \Icinga\Web\Controller\BaseConfigController;
|
||||||
use \Icinga\Web\Widget\Tab;
|
use \Icinga\Web\Widget\Tab;
|
||||||
|
use \Icinga\Web\Widget\AlertMessageBox;
|
||||||
use \Icinga\Web\Url;
|
use \Icinga\Web\Url;
|
||||||
use \Icinga\Web\Widget\Tabs;
|
|
||||||
use \Icinga\Web\Hook\Configuration\ConfigurationTabBuilder;
|
use \Icinga\Web\Hook\Configuration\ConfigurationTabBuilder;
|
||||||
|
use \Icinga\User\Message;
|
||||||
use \Icinga\Application\Icinga;
|
use \Icinga\Application\Icinga;
|
||||||
use \Icinga\Application\Config as IcingaConfig;
|
use \Icinga\Application\Config as IcingaConfig;
|
||||||
use \Icinga\Data\ResourceFactory;
|
use \Icinga\Data\ResourceFactory;
|
||||||
use \Icinga\Form\Config\GeneralForm;
|
use \Icinga\Form\Config\GeneralForm;
|
||||||
|
use \Icinga\Authentication\Manager as AuthenticationManager;
|
||||||
use \Icinga\Form\Config\Authentication\ReorderForm;
|
use \Icinga\Form\Config\Authentication\ReorderForm;
|
||||||
use \Icinga\Form\Config\Authentication\LdapBackendForm;
|
use \Icinga\Form\Config\Authentication\LdapBackendForm;
|
||||||
use \Icinga\Form\Config\Authentication\DbBackendForm;
|
use \Icinga\Form\Config\Authentication\DbBackendForm;
|
||||||
@ -57,6 +59,7 @@ class ConfigController extends BaseConfigController
|
|||||||
*/
|
*/
|
||||||
private $resourceTypes = array('livestatus', 'ido', 'statusdat', 'ldap');
|
private $resourceTypes = array('livestatus', 'ido', 'statusdat', 'ldap');
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create tabs for this configuration controller
|
* Create tabs for this configuration controller
|
||||||
*
|
*
|
||||||
@ -110,17 +113,18 @@ class ConfigController extends BaseConfigController
|
|||||||
*/
|
*/
|
||||||
public function indexAction()
|
public function indexAction()
|
||||||
{
|
{
|
||||||
$form = new GeneralForm();
|
$this->view->messageBox = new AlertMessageBox($this->getAndClearMessages());
|
||||||
|
|
||||||
|
$form = new GeneralForm();
|
||||||
$form->setConfiguration(IcingaConfig::app());
|
$form->setConfiguration(IcingaConfig::app());
|
||||||
$form->setRequest($this->_request);
|
$form->setRequest($this->_request);
|
||||||
if ($form->isSubmittedAndValid()) {
|
if ($form->isSubmittedAndValid()) {
|
||||||
if (!$this->writeConfigFile($form->getConfig(), 'config')) {
|
if (!$this->writeConfigFile($form->getConfig(), 'config')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$this->view->successMessage = "Config Sucessfully Updated";
|
$this->addSuccessMessage("Configuration Sucessfully Updated");
|
||||||
$form->setConfiguration(IcingaConfig::app(), true);
|
$form->setConfiguration(IcingaConfig::app(), true);
|
||||||
|
$this->redirectNow('config/index');
|
||||||
}
|
}
|
||||||
$this->view->form = $form;
|
$this->view->form = $form;
|
||||||
}
|
}
|
||||||
@ -130,6 +134,8 @@ class ConfigController extends BaseConfigController
|
|||||||
*/
|
*/
|
||||||
public function loggingAction()
|
public function loggingAction()
|
||||||
{
|
{
|
||||||
|
$this->view->messageBox = new AlertMessageBox($this->getAndClearMessages());
|
||||||
|
|
||||||
$form = new LoggingForm();
|
$form = new LoggingForm();
|
||||||
$form->setConfiguration(IcingaConfig::app());
|
$form->setConfiguration(IcingaConfig::app());
|
||||||
$form->setRequest($this->_request);
|
$form->setRequest($this->_request);
|
||||||
@ -137,8 +143,9 @@ class ConfigController extends BaseConfigController
|
|||||||
if (!$this->writeConfigFile($form->getConfig(), 'config')) {
|
if (!$this->writeConfigFile($form->getConfig(), 'config')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$this->view->successMessage = "Config Sucessfully Updated";
|
$this->addSuccessMessage("Configuration Sucessfully Updated");
|
||||||
$form->setConfiguration(IcingaConfig::app(), true);
|
$form->setConfiguration(IcingaConfig::app(), true);
|
||||||
|
$this->redirectNow('config/logging');
|
||||||
}
|
}
|
||||||
$this->view->form = $form;
|
$this->view->form = $form;
|
||||||
}
|
}
|
||||||
@ -148,6 +155,9 @@ class ConfigController extends BaseConfigController
|
|||||||
*/
|
*/
|
||||||
public function moduleoverviewAction()
|
public function moduleoverviewAction()
|
||||||
{
|
{
|
||||||
|
$this->view->messageBox = new AlertMessageBox($this->getAndClearMessages());
|
||||||
|
|
||||||
|
$this->view->messages = $this->getAndClearMessages();
|
||||||
$this->view->modules = Icinga::app()->getModuleManager()->select()
|
$this->view->modules = Icinga::app()->getModuleManager()->select()
|
||||||
->from('modules')
|
->from('modules')
|
||||||
->order('name');
|
->order('name');
|
||||||
@ -164,10 +174,11 @@ class ConfigController extends BaseConfigController
|
|||||||
try {
|
try {
|
||||||
$manager->enableModule($module);
|
$manager->enableModule($module);
|
||||||
$manager->loadModule($module);
|
$manager->loadModule($module);
|
||||||
$this->view->successMessage = 'Module "' . $module . '" enabled';
|
$this->addSuccessMessage('Module "' . $module . '" enabled');
|
||||||
$this->moduleoverviewAction();
|
$this->redirectNow('config/moduleoverview');
|
||||||
|
return;
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$this->view->exceptionMessage = $e->getMessage();
|
$this->view->exceptionMesssage = $e->getMessage();
|
||||||
$this->view->moduleName = $module;
|
$this->view->moduleName = $module;
|
||||||
$this->view->action = 'enable';
|
$this->view->action = 'enable';
|
||||||
$this->render('module-configuration-error');
|
$this->render('module-configuration-error');
|
||||||
@ -183,8 +194,9 @@ class ConfigController extends BaseConfigController
|
|||||||
$manager = Icinga::app()->getModuleManager();
|
$manager = Icinga::app()->getModuleManager();
|
||||||
try {
|
try {
|
||||||
$manager->disableModule($module);
|
$manager->disableModule($module);
|
||||||
$this->view->successMessage = 'Module "' . $module . '" disabled';
|
$this->addSuccessMessage('Module "' . $module . '" disabled');
|
||||||
$this->moduleoverviewAction();
|
$this->redirectNow('config/moduleoverview');
|
||||||
|
return;
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$this->view->exceptionMessage = $e->getMessage();
|
$this->view->exceptionMessage = $e->getMessage();
|
||||||
$this->view->moduleName = $module;
|
$this->view->moduleName = $module;
|
||||||
@ -201,6 +213,7 @@ class ConfigController extends BaseConfigController
|
|||||||
$config = IcingaConfig::app('authentication', true);
|
$config = IcingaConfig::app('authentication', true);
|
||||||
$order = array_keys($config->toArray());
|
$order = array_keys($config->toArray());
|
||||||
$this->view->backends = array();
|
$this->view->backends = array();
|
||||||
|
$this->view->messageBox = new AlertMessageBox($this->getAndClearMessages());
|
||||||
|
|
||||||
foreach ($config as $backend=>$backendConfig) {
|
foreach ($config as $backend=>$backendConfig) {
|
||||||
$form = new ReorderForm();
|
$form = new ReorderForm();
|
||||||
@ -211,8 +224,8 @@ class ConfigController extends BaseConfigController
|
|||||||
|
|
||||||
if (!$showOnly && $form->isSubmittedAndValid()) {
|
if (!$showOnly && $form->isSubmittedAndValid()) {
|
||||||
if ($this->writeAuthenticationFile($form->getReorderedConfig($config))) {
|
if ($this->writeAuthenticationFile($form->getReorderedConfig($config))) {
|
||||||
$this->view->successMessage = 'Authentication Order Updated';
|
$this->addSuccessMessage('Authentication Order Updated');
|
||||||
$this->authenticationAction(true);
|
$this->redirectNow('config/authentication');
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -230,6 +243,8 @@ class ConfigController extends BaseConfigController
|
|||||||
*/
|
*/
|
||||||
public function createauthenticationbackendAction()
|
public function createauthenticationbackendAction()
|
||||||
{
|
{
|
||||||
|
$this->view->messageBox = new AlertMessageBox();
|
||||||
|
|
||||||
if ($this->getRequest()->getParam('type') === 'ldap') {
|
if ($this->getRequest()->getParam('type') === 'ldap') {
|
||||||
$form = new LdapBackendForm();
|
$form = new LdapBackendForm();
|
||||||
} else {
|
} else {
|
||||||
@ -248,7 +263,7 @@ class ConfigController extends BaseConfigController
|
|||||||
foreach ($form->getConfig() as $backendName => $settings) {
|
foreach ($form->getConfig() as $backendName => $settings) {
|
||||||
unset($settings->{'name'});
|
unset($settings->{'name'});
|
||||||
if (isset($backendCfg[$backendName])) {
|
if (isset($backendCfg[$backendName])) {
|
||||||
$this->view->errorMessage = 'Backend name already exists';
|
$this->view->messageBox->addError('Backend name already exists');
|
||||||
$this->view->form = $form;
|
$this->view->form = $form;
|
||||||
$this->render('authentication/create');
|
$this->render('authentication/create');
|
||||||
return;
|
return;
|
||||||
@ -257,11 +272,13 @@ class ConfigController extends BaseConfigController
|
|||||||
}
|
}
|
||||||
if ($this->writeAuthenticationFile($backendCfg)) {
|
if ($this->writeAuthenticationFile($backendCfg)) {
|
||||||
// redirect to overview with success message
|
// redirect to overview with success message
|
||||||
$this->view->successMessage = 'Backend Modification Written';
|
$this->addSuccessMessage('Backend Modification Written.');
|
||||||
$this->authenticationAction(true);
|
$this->redirectNow("config/authentication");
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->view->messageBox->addForm($form);
|
||||||
$this->view->form = $form;
|
$this->view->form = $form;
|
||||||
$this->render('authentication/create');
|
$this->render('authentication/create');
|
||||||
}
|
}
|
||||||
@ -278,13 +295,13 @@ class ConfigController extends BaseConfigController
|
|||||||
$configArray = IcingaConfig::app('authentication', true)->toArray();
|
$configArray = IcingaConfig::app('authentication', true)->toArray();
|
||||||
$authBackend = $this->getParam('auth_backend');
|
$authBackend = $this->getParam('auth_backend');
|
||||||
if (!isset($configArray[$authBackend])) {
|
if (!isset($configArray[$authBackend])) {
|
||||||
$this->view->errorMessage = 'Can\'t edit: Unknown Authentication Backend Provided';
|
$this->addErrorMessage('Can\'t edit: Unknown Authentication Backend Provided');
|
||||||
$this->authenticationAction(true);
|
$this->configurationerrorAction();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!array_key_exists('resource', $configArray[$authBackend])) {
|
if (!array_key_exists('resource', $configArray[$authBackend])) {
|
||||||
$this->view->errorMessage = 'Configuration error: Backend "' . $authBackend . '" has no Resource';
|
$this->addErrorMessage('Configuration error: Backend "' . $authBackend . '" has no Resource');
|
||||||
$this->authenticationAction(true);
|
$this->configurationerrorAction();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -297,8 +314,8 @@ class ConfigController extends BaseConfigController
|
|||||||
$form = new DbBackendForm();
|
$form = new DbBackendForm();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$this->view->errorMessage = 'Can\'t edit: backend type "' . $type . '" of given resource not supported.';
|
$this->addErrorMessage('Can\'t edit: backend type "' . $type . '" of given resource not supported.');
|
||||||
$this->authenticationAction(true);
|
$this->configurationerrorAction();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -318,12 +335,13 @@ class ConfigController extends BaseConfigController
|
|||||||
}
|
}
|
||||||
if ($this->writeAuthenticationFile($backendCfg)) {
|
if ($this->writeAuthenticationFile($backendCfg)) {
|
||||||
// redirect to overview with success message
|
// redirect to overview with success message
|
||||||
$this->view->successMessage = 'Backend "' . $authBackend . '" created';
|
$this->addSuccessMessage('Backend "' . $authBackend . '" created');
|
||||||
$this->authenticationAction(true);
|
$this->redirectNow("config/authentication");
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->view->messageBox->addForm($form);
|
||||||
$this->view->name = $authBackend;
|
$this->view->name = $authBackend;
|
||||||
$this->view->form = $form;
|
$this->view->form = $form;
|
||||||
$this->render('authentication/modify');
|
$this->render('authentication/modify');
|
||||||
@ -336,16 +354,22 @@ class ConfigController extends BaseConfigController
|
|||||||
*/
|
*/
|
||||||
public function removeauthenticationbackendAction()
|
public function removeauthenticationbackendAction()
|
||||||
{
|
{
|
||||||
|
$this->view->messageBox = new AlertMessageBox();
|
||||||
|
|
||||||
$configArray = IcingaConfig::app('authentication', true)->toArray();
|
$configArray = IcingaConfig::app('authentication', true)->toArray();
|
||||||
$authBackend = $this->getParam('auth_backend');
|
$authBackend = $this->getParam('auth_backend');
|
||||||
if (!isset($configArray[$authBackend])) {
|
if (!isset($configArray[$authBackend])) {
|
||||||
$this->view->errorMessage = 'Can\'t perform removal: Unknown Authentication Backend Provided';
|
$this->view->messageBox->addMessage(
|
||||||
$this->authenticationAction(true);
|
new Message('Can\'t perform removal: Unknown Authentication Backend Provided', Zend_Log::ERR)
|
||||||
|
);
|
||||||
|
$this->render('authentication/remove');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!array_key_exists('resource', $configArray[$authBackend])) {
|
if (!array_key_exists('resource', $configArray[$authBackend])) {
|
||||||
$this->view->errorMessage = 'Configuration error: Backend "' . $authBackend . '" has no Resource';
|
$this->view->messageBox->addMessage(
|
||||||
$this->authenticationAction(true);
|
new Message('Configuration error: Backend "' . $authBackend . '" has no Resource', Zend_Log::ERR)
|
||||||
|
);
|
||||||
|
$this->render('authentication/remove');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -356,8 +380,8 @@ class ConfigController extends BaseConfigController
|
|||||||
if ($form->isSubmittedAndValid()) {
|
if ($form->isSubmittedAndValid()) {
|
||||||
unset($configArray[$authBackend]);
|
unset($configArray[$authBackend]);
|
||||||
if ($this->writeAuthenticationFile($configArray)) {
|
if ($this->writeAuthenticationFile($configArray)) {
|
||||||
$this->view->successMessage = 'Authentication Backend "' . $authBackend . '" Removed';
|
$this->addSuccessMessage('Authentication Backend "' . $authBackend . '" Removed');
|
||||||
$this->authenticationAction(true);
|
$this->redirectNow("config/authentication");
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -369,6 +393,7 @@ class ConfigController extends BaseConfigController
|
|||||||
|
|
||||||
public function resourceAction($showOnly = false)
|
public function resourceAction($showOnly = false)
|
||||||
{
|
{
|
||||||
|
$this->view->messageBox = new AlertMessageBox($this->getAndClearMessages());
|
||||||
|
|
||||||
$this->view->resources = IcingaConfig::app('resources', true)->toArray();
|
$this->view->resources = IcingaConfig::app('resources', true)->toArray();
|
||||||
$this->render('resource');
|
$this->render('resource');
|
||||||
@ -383,29 +408,33 @@ class ConfigController extends BaseConfigController
|
|||||||
if ($form->isSubmittedAndValid()) {
|
if ($form->isSubmittedAndValid()) {
|
||||||
$name = $form->getName();
|
$name = $form->getName();
|
||||||
if (isset($resources->{$name})) {
|
if (isset($resources->{$name})) {
|
||||||
$this->view->errorMessage = 'Resource name "' . $name .'" already in use.';
|
$this->addErrorMessage('Resource name "' . $name .'" already in use.');
|
||||||
$this->view->form = $form;
|
} else {
|
||||||
$this->render('resource/create');
|
$resources->{$name} = $form->getConfig();
|
||||||
return;
|
if ($this->writeConfigFile($resources, 'resources')) {
|
||||||
|
$this->addSuccessMessage('Resource "' . $name . '" created.');
|
||||||
|
$this->redirectNow("config/resource");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$resources->{$name} = $form->getConfig();
|
|
||||||
if ($this->writeConfigFile($resources, 'resources')) {
|
|
||||||
$this->view->successMessage = 'Resource "' . $name . '" created.';
|
|
||||||
$this->resourceAction(true);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->view->messageBox = new AlertMessageBox($this->getAndClearMessages());
|
||||||
|
$this->view->messageBox->addForm($form);
|
||||||
$this->view->form = $form;
|
$this->view->form = $form;
|
||||||
$this->render('resource/create');
|
$this->render('resource/create');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function editresourceAction()
|
public function editresourceAction()
|
||||||
{
|
{
|
||||||
|
$this->view->messageBox = new AlertMessageBox();
|
||||||
|
|
||||||
$resources = ResourceFactory::getResourceConfigs();
|
$resources = ResourceFactory::getResourceConfigs();
|
||||||
$name = $this->getParam('resource');
|
$name = $this->getParam('resource');
|
||||||
if ($resources->get($name) === null) {
|
if ($resources->get($name) === null) {
|
||||||
$this->view->errorMessage = 'Can\'t edit: Unknown Resource Provided';
|
$this->view->messageBox->addMessage(
|
||||||
$this->resourceAction(true);
|
new Message('Can\'t edit: Unknown Resource Provided', Zend_Log::ERR)
|
||||||
|
);
|
||||||
|
$this->render('resource/modify');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$form = new EditResourceForm();
|
$form = new EditResourceForm();
|
||||||
@ -423,11 +452,13 @@ class ConfigController extends BaseConfigController
|
|||||||
}
|
}
|
||||||
$resources->{$name} = $form->getConfig();
|
$resources->{$name} = $form->getConfig();
|
||||||
if ($this->writeConfigFile($resources, 'resources')) {
|
if ($this->writeConfigFile($resources, 'resources')) {
|
||||||
$this->view->successMessage = 'Resource "' . $name . '" created.';
|
$this->addSuccessMessage('Resource "' . $name . '" edited.');
|
||||||
$this->resourceAction(true);
|
$this->redirectNow("config/resource");
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->view->messageBox->addForm($form);
|
||||||
$this->view->form = $form;
|
$this->view->form = $form;
|
||||||
$this->view->name = $name;
|
$this->view->name = $name;
|
||||||
$this->render('resource/modify');
|
$this->render('resource/modify');
|
||||||
@ -435,11 +466,15 @@ class ConfigController extends BaseConfigController
|
|||||||
|
|
||||||
public function removeresourceAction()
|
public function removeresourceAction()
|
||||||
{
|
{
|
||||||
|
$this->view->messageBox = new AlertMessageBox();
|
||||||
|
|
||||||
$resources = ResourceFactory::getResourceConfigs()->toArray();
|
$resources = ResourceFactory::getResourceConfigs()->toArray();
|
||||||
$name = $this->getParam('resource');
|
$name = $this->getParam('resource');
|
||||||
if (!isset($resources[$name])) {
|
if (!isset($resources[$name])) {
|
||||||
$this->view->errorMessage = 'Can\'t remove: Unknown resource provided';
|
$this->view->messageBox->addMessage(
|
||||||
$this->resourceAction(true);
|
new Message('Can\'t remove: Unknown resource provided', Zend_Log::ERR)
|
||||||
|
);
|
||||||
|
$this->render('resource/remove');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -449,8 +484,8 @@ class ConfigController extends BaseConfigController
|
|||||||
if ($form->isSubmittedAndValid()) {
|
if ($form->isSubmittedAndValid()) {
|
||||||
unset($resources[$name]);
|
unset($resources[$name]);
|
||||||
if ($this->writeConfigFile($resources, 'resources')) {
|
if ($this->writeConfigFile($resources, 'resources')) {
|
||||||
$this->view->successMessage = 'Resource "' . $name . '" removed';
|
$this->addSuccessMessage('Resource "' . $name . '" removed.');
|
||||||
$this->resourceAction(true);
|
$this->redirectNow('config/resource');
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -460,6 +495,19 @@ class ConfigController extends BaseConfigController
|
|||||||
$this->render('resource/remove');
|
$this->render('resource/remove');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Redirect target only for error-states
|
||||||
|
*
|
||||||
|
* When an error is opened in the side-pane, redirecting this request to the index or the overview will look
|
||||||
|
* weird. This action returns a clear page containing only an AlertMessageBox.
|
||||||
|
*/
|
||||||
|
public function configurationerrorAction()
|
||||||
|
{
|
||||||
|
$this->view->messageBox = new AlertMessageBox($this->getAndClearMessages());
|
||||||
|
$this->render('error/error');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write changes to an authentication file
|
* Write changes to an authentication file
|
||||||
*
|
*
|
||||||
|
@ -390,6 +390,9 @@ class EditResourceForm extends Form
|
|||||||
!file_exists($config->object_file) ||
|
!file_exists($config->object_file) ||
|
||||||
!file_exists($config->status_file)
|
!file_exists($config->status_file)
|
||||||
) {
|
) {
|
||||||
|
$this->addErrorMessage(
|
||||||
|
'Connectivity validation failed, the provided file or socket does not exist.'
|
||||||
|
);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -402,6 +405,7 @@ class EditResourceForm extends Form
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} catch (\Exception $exc) {
|
} catch (\Exception $exc) {
|
||||||
|
$this->addErrorMessage('Connectivity validation failed, connection to the given resource not possible.');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -6,20 +6,9 @@ $createDbBackend = $this->href('/config/createAuthenticationBackend', array('typ
|
|||||||
|
|
||||||
<?= $this->tabs->render($this); ?>
|
<?= $this->tabs->render($this); ?>
|
||||||
|
|
||||||
<?php if ($this->errorMessage): ?>
|
<?php if (isset($this->messageBox)): ?>
|
||||||
<div class="alert alert-danger">
|
<?= $this->messageBox->render() ?>
|
||||||
<i class="icinga-icon-error"></i>
|
<?php endif ?>
|
||||||
<strong><?= $this->escape($this->errorMessage); ?></strong>
|
|
||||||
</div>
|
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
|
|
||||||
<?php if ($this->successMessage): ?>
|
|
||||||
<div class="alert alert-success">
|
|
||||||
<i class="icinga-icon-success"></i>
|
|
||||||
<strong><?= $this->escape($this->successMessage); ?></strong>
|
|
||||||
</div>
|
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<div class="panel-heading panel-title">
|
<div class="panel-heading panel-title">
|
||||||
|
@ -3,11 +3,10 @@
|
|||||||
Create New Authentication Backend
|
Create New Authentication Backend
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
<?php if ($this->errorMessage): ?>
|
|
||||||
<div class="alert alert-danger">
|
<?php if (isset($this->messageBox)): ?>
|
||||||
<?= $this->escape($this->errorMessage); ?>
|
<?= $this->messageBox->render() ?>
|
||||||
</div>
|
<?php endif ?>
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Create a new backend for authenticating your users. This backend will be added at the end of your authentication order.
|
Create a new backend for authenticating your users. This backend will be added at the end of your authentication order.
|
||||||
|
@ -3,11 +3,14 @@
|
|||||||
Edit Backend "<?= $this->escape($this->name); ?>"
|
Edit Backend "<?= $this->escape($this->name); ?>"
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
<?php if ($this->errorMessage || $this->form->getErrorMessages()): ?>
|
<?php if (isset($this->messageBox)): ?>
|
||||||
|
<?= $this->messageBox->render() ?>
|
||||||
|
<?php endif ?>
|
||||||
|
|
||||||
|
<?php if ($this->form->getErrorMessages()): ?>
|
||||||
<div class="alert alert-danger">
|
<div class="alert alert-danger">
|
||||||
<?= $this->escape($this->errorMessage); ?>
|
|
||||||
<?php foreach ($this->form->getErrorMessages() as $error): ?>
|
<?php foreach ($this->form->getErrorMessages() as $error): ?>
|
||||||
<?= $this->escape($error); ?><br/>
|
<?= $this->escape($error); ?><br/>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</div>
|
</div>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
@ -2,4 +2,9 @@
|
|||||||
<i class="icinga-icon-remove"></i>
|
<i class="icinga-icon-remove"></i>
|
||||||
Remove Backend "<?= $this->escape($this->name); ?>"
|
Remove Backend "<?= $this->escape($this->name); ?>"
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
|
<?php if (isset($this->messageBox)): ?>
|
||||||
|
<?= $this->messageBox->render() ?>
|
||||||
|
<?php endif ?>
|
||||||
|
|
||||||
<?= $this->form ?>
|
<?= $this->form ?>
|
@ -1,10 +1,7 @@
|
|||||||
<?= $this->tabs->render($this); ?>
|
<?= $this->tabs->render($this); ?>
|
||||||
|
|
||||||
<?php if ($this->successMessage): ?>
|
<?php if (isset($this->messageBox)): ?>
|
||||||
<div class="alert alert-success">
|
<?= $this->messageBox->render() ?>
|
||||||
<i class="icinga-icon-success"></i>
|
<?php endif ?>
|
||||||
<strong><?= $this->escape($this->successMessage); ?></strong>
|
|
||||||
</div>
|
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
<?= $this->form ?>
|
<?= $this->form ?>
|
@ -2,6 +2,10 @@
|
|||||||
|
|
||||||
<?php $errors = $this->form->getErrorMessages(); ?>
|
<?php $errors = $this->form->getErrorMessages(); ?>
|
||||||
|
|
||||||
|
<?php if (isset($this->messageBox)): ?>
|
||||||
|
<?= $this->messageBox->render() ?>
|
||||||
|
<?php endif ?>
|
||||||
|
|
||||||
<?php if ($this->successMessage): ?>
|
<?php if ($this->successMessage): ?>
|
||||||
<div class="alert alert-success">
|
<div class="alert alert-success">
|
||||||
<i class="icinga-icon-success"></i>
|
<i class="icinga-icon-success"></i>
|
||||||
|
@ -9,12 +9,9 @@ $modules = $this->modules->paginate();
|
|||||||
|
|
||||||
<h3>Installed Modules</h3>
|
<h3>Installed Modules</h3>
|
||||||
|
|
||||||
<?php if ($this->successMessage): ?>
|
<?php if (isset($this->messageBox)): ?>
|
||||||
<div class="alert alert-success">
|
<?= $this->messageBox->render() ?>
|
||||||
<i class="icinga-icon-success"></i>
|
<?php endif ?>
|
||||||
<strong><?= $this->escape($this->successMessage); ?></strong>
|
|
||||||
</div>
|
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
<?= $this->paginationControl($modules, null, null, array(
|
<?= $this->paginationControl($modules, null, null, array(
|
||||||
'preserve' => $this->preserve
|
'preserve' => $this->preserve
|
||||||
|
@ -2,28 +2,11 @@
|
|||||||
use Icinga\Web\Url;
|
use Icinga\Web\Url;
|
||||||
$createResource = $this->href('/config/createresource');
|
$createResource = $this->href('/config/createresource');
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<?= $this->tabs->render($this); ?>
|
<?= $this->tabs->render($this); ?>
|
||||||
|
|
||||||
<?php if ($this->errorMessage): ?>
|
<?php if (isset($this->messageBox)): ?>
|
||||||
<div class="alert alert-danger">
|
<?= $this->messageBox->render() ?>
|
||||||
<i class="icinga-icon-error"></i>
|
<?php endif ?>
|
||||||
<strong><?= $this->escape($this->errorMessage); ?></strong>
|
|
||||||
</div>
|
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
<?php if ($this->successMessage): ?>
|
|
||||||
<div class="alert alert-success">
|
|
||||||
<i class="icinga-icon-success"></i>
|
|
||||||
<strong><?= $this->escape($this->successMessage); ?></strong>
|
|
||||||
</div>
|
|
||||||
<?php elseif ($this->flashMessages): ?>
|
|
||||||
<div class="alert alert-success">
|
|
||||||
<i class="icinga-icon-success"></i>
|
|
||||||
<strong><?= $this->escape($this->flashMessages); ?></strong>
|
|
||||||
</div>
|
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
|
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<div class="panel-heading panel-title">
|
<div class="panel-heading panel-title">
|
||||||
|
@ -3,14 +3,12 @@
|
|||||||
Create New Resource
|
Create New Resource
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
<?php if ($this->errorMessage): ?>
|
<?php if (isset($this->messageBox)): ?>
|
||||||
<div class="alert alert-danger">
|
<?= $this->messageBox->render() ?>
|
||||||
<?= $this->escape($this->errorMessage); ?>
|
<?php endif ?>
|
||||||
</div>
|
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Create a new resource to describes a data sourc
|
Resources are entities that provide data to Icingaweb.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<?= $this->form ?>
|
<?= $this->form ?>
|
@ -3,13 +3,16 @@
|
|||||||
Edit Resource "<?= $this->escape($this->name); ?>"
|
Edit Resource "<?= $this->escape($this->name); ?>"
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
<?php if ($this->errorMessage || $this->form->getErrorMessages()): ?>
|
<?php if (isset($this->messageBox)): ?>
|
||||||
|
<?= $this->messageBox->render() ?>
|
||||||
|
<?php endif ?>
|
||||||
|
|
||||||
|
<?php if ($this->form->getErrorMessages()): ?>
|
||||||
<div class="alert alert-danger">
|
<div class="alert alert-danger">
|
||||||
<?= $this->escape($this->errorMessage); ?>
|
|
||||||
<?php foreach ($this->form->getErrorMessages() as $error): ?>
|
<?php foreach ($this->form->getErrorMessages() as $error): ?>
|
||||||
<?= $this->escape($error); ?><br/>
|
<?= $this->escape($error); ?><br/>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</div>
|
</div>
|
||||||
<?php endif; ?>
|
<?php endif ?>
|
||||||
|
|
||||||
<?= $this->form ?>
|
<?= $this->form ?>
|
@ -2,4 +2,9 @@
|
|||||||
<i class="icinga-icon-remove"></i>
|
<i class="icinga-icon-remove"></i>
|
||||||
Remove Resource "<?= $this->escape($this->name); ?>"
|
Remove Resource "<?= $this->escape($this->name); ?>"
|
||||||
</h4>
|
</h4>
|
||||||
<?= $this->form ?>
|
|
||||||
|
<?php if (isset($this->messageBox)): ?>
|
||||||
|
<?= $this->messageBox->render() ?>
|
||||||
|
<?php endif ?>
|
||||||
|
|
||||||
|
<?= $this->form ?>
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?= $this->tabs->render($this); ?>
|
<?= $this->tabs->render($this); ?>
|
||||||
|
|
||||||
|
|
||||||
<br/>
|
<br/>
|
||||||
<div class="alert alert-error">
|
<div class="alert alert-error">
|
||||||
<h4><i>WARNING ICON</i>Saving "<?= $this->escape($this->file); ?>.ini" Failed</h4>
|
<h4><i>WARNING ICON</i>Saving "<?= $this->escape($this->file); ?>.ini" Failed</h4>
|
||||||
|
@ -1,26 +1,9 @@
|
|||||||
|
<?= $this->tabs->render($this); ?>
|
||||||
|
|
||||||
<div class="alert alert-error">
|
<div class="alert alert-error">
|
||||||
<h1>An error occurred</h1>
|
<h1>An error occurred</h1>
|
||||||
<p>
|
|
||||||
<?php echo $this->message ?>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<?php if (isset($this->exception)): ?>
|
<?php if (isset($this->messageBox)) : ?>
|
||||||
<div style="text-align:left;">
|
<?= $this->messageBox->render() ?>
|
||||||
<h3>Exception information:</h3>
|
<? endif ?>
|
||||||
|
|
||||||
<p>
|
|
||||||
<b>Message:</b>
|
|
||||||
<?= $this->exception->getMessage(); ?>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<h3>Stack trace:</h3>
|
|
||||||
<pre>
|
|
||||||
<?= $this->exception->getTraceAsString(); ?>
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<h3>Request Parameters:</h3>
|
|
||||||
<pre><?= var_export(\Zend_Controller_Front::getInstance()->getParams(), true); ?>
|
|
||||||
</pre>
|
|
||||||
</div>
|
|
||||||
<?php endif; ?>
|
|
||||||
</div>
|
</div>
|
||||||
|
@ -347,7 +347,6 @@ class Manager
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->user->sendMessage("Hallo ich bin nachricht.");
|
|
||||||
if ($persist == true) {
|
if ($persist == true) {
|
||||||
$this->persistCurrentUser();
|
$this->persistCurrentUser();
|
||||||
$this->session->write();
|
$this->session->write();
|
||||||
@ -399,9 +398,9 @@ class Manager
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the current user or null if no user is authenticated
|
* Returns the current user or null if no user is authenticated
|
||||||
*
|
*
|
||||||
* @return User
|
* @return User
|
||||||
**/
|
**/
|
||||||
public function getUser()
|
public function getUser()
|
||||||
{
|
{
|
||||||
|
@ -64,10 +64,13 @@ abstract class Session
|
|||||||
* @see self::persist
|
* @see self::persist
|
||||||
* @param string $key Name of value
|
* @param string $key Name of value
|
||||||
* @param mixed $value Value
|
* @param mixed $value Value
|
||||||
|
*
|
||||||
|
* @returns PhpSession this
|
||||||
*/
|
*/
|
||||||
public function set($key, $value)
|
public function set($key, $value)
|
||||||
{
|
{
|
||||||
$this->sessionValues[$key] = $value;
|
$this->sessionValues[$key] = $value;
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -32,14 +32,15 @@ namespace Icinga;
|
|||||||
use \DateTimeZone;
|
use \DateTimeZone;
|
||||||
use \InvalidArgumentException;
|
use \InvalidArgumentException;
|
||||||
use \Icinga\User\Preferences;
|
use \Icinga\User\Preferences;
|
||||||
|
use \Icinga\User\Message;
|
||||||
use \Icinga\Authentication\PhpSession;
|
use \Icinga\Authentication\PhpSession;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class represents an authorized user
|
* This class represents an authorized user
|
||||||
*
|
*
|
||||||
* You can retrieve authorization information (@TODO: Not implemented yet) or
|
* You can retrieve authorization information (@TODO: Not implemented yet) or
|
||||||
* to retrieve user information
|
* to retrieve user information
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
class User
|
class User
|
||||||
{
|
{
|
||||||
@ -344,17 +345,34 @@ class User
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send a message to this user that can be accessed in other requests.
|
* Add a message that can be accessed from future requests, to this user.
|
||||||
*
|
*
|
||||||
* @param $msg
|
* This function does NOT automatically write to the session, messages will not be persisted until you do.
|
||||||
|
*
|
||||||
|
* @param Message $msg The message
|
||||||
*/
|
*/
|
||||||
public function sendMessage($msg)
|
public function addMessage(Message $msg)
|
||||||
{
|
{
|
||||||
$this->messages[] = $msg;
|
$this->messages[] = $msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all currently pending messages
|
||||||
|
*
|
||||||
|
* @return array the messages
|
||||||
|
*/
|
||||||
public function getMessages()
|
public function getMessages()
|
||||||
{
|
{
|
||||||
return $this->messages;
|
return isset($this->messages) ? $this->messages : array();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove all messages from this user
|
||||||
|
*
|
||||||
|
* This function does NOT automatically write the session, messages will not be persisted until you do.
|
||||||
|
*/
|
||||||
|
public function clearMessages()
|
||||||
|
{
|
||||||
|
$this->messages = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
57
library/Icinga/User/Message.php
Normal file
57
library/Icinga/User/Message.php
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Icinga\User;
|
||||||
|
|
||||||
|
use \Zend_Log;
|
||||||
|
use \DateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Message
|
||||||
|
*
|
||||||
|
* A Message with an additional logging level to indicate the type.
|
||||||
|
*
|
||||||
|
* @package Icinga\User
|
||||||
|
*/
|
||||||
|
class Message {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The content of this message
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $message;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The logging-level of this message
|
||||||
|
*/
|
||||||
|
private $level;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new Message
|
||||||
|
*
|
||||||
|
* @param string $message The message content
|
||||||
|
* @param $level The status of the message
|
||||||
|
* * Zend_Log::INFO
|
||||||
|
* * Zend_Log::ERR
|
||||||
|
*/
|
||||||
|
public function __construct($message, $level = Zend_Log::INFO) {
|
||||||
|
$this->message = $message;
|
||||||
|
$this->level = $level;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getMessage()
|
||||||
|
{
|
||||||
|
return $this->message;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The
|
||||||
|
*/
|
||||||
|
public function getLevel()
|
||||||
|
{
|
||||||
|
return $this->level;
|
||||||
|
}
|
||||||
|
}
|
@ -30,6 +30,9 @@
|
|||||||
namespace Icinga\Web\Controller;
|
namespace Icinga\Web\Controller;
|
||||||
|
|
||||||
use \Icinga\Application\Icinga;
|
use \Icinga\Application\Icinga;
|
||||||
|
use \Icinga\Authentication\Manager as AuthenticationManager;
|
||||||
|
use \Zend_Log;
|
||||||
|
use \Icinga\User\Message;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for Configuration Controllers
|
* Base class for Configuration Controllers
|
||||||
@ -38,7 +41,6 @@ use \Icinga\Application\Icinga;
|
|||||||
* added to the application's configuration dialog. If you create a subclass of
|
* added to the application's configuration dialog. If you create a subclass of
|
||||||
* BasePreferenceController and overwrite @see init(), make sure you call
|
* BasePreferenceController and overwrite @see init(), make sure you call
|
||||||
* parent::init(), otherwise you won't have the $tabs property in your view.
|
* parent::init(), otherwise you won't have the $tabs property in your view.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
class BaseConfigController extends ActionController
|
class BaseConfigController extends ActionController
|
||||||
{
|
{
|
||||||
@ -47,6 +49,50 @@ class BaseConfigController extends ActionController
|
|||||||
*/
|
*/
|
||||||
protected $flashManager;
|
protected $flashManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove all messages from the current user, return them and commit
|
||||||
|
* changes to the underlying session.
|
||||||
|
*
|
||||||
|
* @return array The messages
|
||||||
|
*/
|
||||||
|
protected function getAndClearMessages()
|
||||||
|
{
|
||||||
|
// empty all messages
|
||||||
|
$user = AuthenticationManager::getInstance()->getUser();
|
||||||
|
$messages = $user->getMessages();
|
||||||
|
$user->clearMessages();
|
||||||
|
AuthenticationManager::getInstance()->getSession()->write();
|
||||||
|
return $messages;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send a message with the logging level Zend_Log::INFO to the current user and
|
||||||
|
* commit the changes to the underlying session.
|
||||||
|
*
|
||||||
|
* @param $msg The message content
|
||||||
|
*/
|
||||||
|
protected function addSuccessMessage($msg)
|
||||||
|
{
|
||||||
|
AuthenticationManager::getInstance()->getUser()->addMessage(
|
||||||
|
new Message($msg, Zend_Log::INFO)
|
||||||
|
);
|
||||||
|
AuthenticationManager::getInstance()->getSession()->write();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send a message with the logging level Zend_Log::ERR to the current user and
|
||||||
|
* commit the changes to the underlying session.
|
||||||
|
*
|
||||||
|
* @param $msg The message content
|
||||||
|
*/
|
||||||
|
protected function addErrorMessage($msg)
|
||||||
|
{
|
||||||
|
AuthenticationManager::getInstance()->getUser()->addMessage(
|
||||||
|
new Message($msg, Zend_Log::ERR)
|
||||||
|
);
|
||||||
|
AuthenticationManager::getInstance()->getSession()->write();
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Return an array of tabs provided by this configuration controller.
|
* Return an array of tabs provided by this configuration controller.
|
||||||
*
|
*
|
||||||
@ -68,6 +114,5 @@ class BaseConfigController extends ActionController
|
|||||||
{
|
{
|
||||||
parent::init();
|
parent::init();
|
||||||
$this->view->tabs = ControllerTabCollector::collectControllerTabs('ConfigController');
|
$this->view->tabs = ControllerTabCollector::collectControllerTabs('ConfigController');
|
||||||
$this->view->flashMessages = $this->_request->getParam('flash_message');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
113
library/Icinga/Web/Widget/AlertMessageBox.php
Normal file
113
library/Icinga/Web/Widget/AlertMessageBox.php
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Icinga\Web\Widget;
|
||||||
|
|
||||||
|
use \Zend_Log;
|
||||||
|
use \Zend_Form;
|
||||||
|
use \Icinga\User\Message;
|
||||||
|
use \Zend_View_Abstract;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class AlertMessageBox
|
||||||
|
*
|
||||||
|
* Displays a set of alert messages to the user.
|
||||||
|
*
|
||||||
|
* @package Icinga\Web\Widget
|
||||||
|
*/
|
||||||
|
class AlertMessageBox implements \Icinga\Web\Widget\Widget {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The displayed alert messages
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
private $messages = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The available states.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
private $states = array(
|
||||||
|
Zend_Log::INFO => array(
|
||||||
|
'state' => 'alert-success',
|
||||||
|
'icon' => 'icinga-icon-success'
|
||||||
|
),
|
||||||
|
Zend_Log::NOTICE => array(
|
||||||
|
'state' => 'alert-info',
|
||||||
|
'icon' => 'icinga-icon-info'
|
||||||
|
),
|
||||||
|
Zend_Log::WARN => array(
|
||||||
|
'state' => 'alert-warning',
|
||||||
|
'icon' => 'icinga-icon-warning'
|
||||||
|
),
|
||||||
|
Zend_Log::ERR => array(
|
||||||
|
'state' => 'alert-danger',
|
||||||
|
'icon' => 'icinga-icon-danger'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new AlertBox
|
||||||
|
*
|
||||||
|
* @param Message|array $messages The message(s) to display
|
||||||
|
*/
|
||||||
|
public function __construct($messages = array()) {
|
||||||
|
if (!is_array($messages)) {
|
||||||
|
$this->messages = array($messages);
|
||||||
|
} else {
|
||||||
|
$this->messages = $messages;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a new message.
|
||||||
|
*
|
||||||
|
* @param Message $message
|
||||||
|
*/
|
||||||
|
public function addMessage(Message $message)
|
||||||
|
{
|
||||||
|
$this->messages[] = $message;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a new error
|
||||||
|
*
|
||||||
|
* @param $error
|
||||||
|
*/
|
||||||
|
public function addError($error)
|
||||||
|
{
|
||||||
|
$this->messages[] = new Message($error, Zend_Log::ERR);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add the error messages of the given Zend_Form
|
||||||
|
*/
|
||||||
|
public function addForm(Zend_Form $form)
|
||||||
|
{
|
||||||
|
foreach ($form->getErrorMessages() as $error) {
|
||||||
|
$this->addError($error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Output the HTML of the AlertBox
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function render(Zend_View_Abstract $view = null) {
|
||||||
|
$html = '';
|
||||||
|
foreach ($this->messages as $message) {
|
||||||
|
$level = $message->getLevel();
|
||||||
|
if (!array_key_exists($level, $this->states)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$alert = $this->states[$level];
|
||||||
|
$html .= '<div class="alert ' . $alert['state']. '">' .
|
||||||
|
'<i class="' . $alert['icon'] . '"></i>' .
|
||||||
|
'<strong>' . htmlspecialchars($message->getMessage()) . '</strong>' .
|
||||||
|
'</div>';
|
||||||
|
}
|
||||||
|
return $html;
|
||||||
|
}
|
||||||
|
}
|
@ -34,6 +34,7 @@ use \Icinga\Application\Config as IcingaConfig;
|
|||||||
use \Icinga\Config\PreservingIniWriter;
|
use \Icinga\Config\PreservingIniWriter;
|
||||||
use \Icinga\Web\Controller\BaseConfigController;
|
use \Icinga\Web\Controller\BaseConfigController;
|
||||||
use \Icinga\Web\Widget\Tab;
|
use \Icinga\Web\Widget\Tab;
|
||||||
|
use \Icinga\Web\Widget\AlertMessageBox;
|
||||||
use \Icinga\Web\Url;
|
use \Icinga\Web\Url;
|
||||||
|
|
||||||
use Icinga\Module\Monitoring\Form\Config\ConfirmRemovalForm;
|
use Icinga\Module\Monitoring\Form\Config\ConfirmRemovalForm;
|
||||||
@ -69,6 +70,7 @@ class Monitoring_ConfigController extends BaseConfigController {
|
|||||||
*/
|
*/
|
||||||
public function indexAction()
|
public function indexAction()
|
||||||
{
|
{
|
||||||
|
$this->view->messageBox = new AlertMessageBox($this->getAndClearMessages());
|
||||||
$this->view->backends = IcingaConfig::module('monitoring', 'backends')->toArray();
|
$this->view->backends = IcingaConfig::module('monitoring', 'backends')->toArray();
|
||||||
$this->view->instances = IcingaConfig::module('monitoring', 'instances')->toArray();
|
$this->view->instances = IcingaConfig::module('monitoring', 'instances')->toArray();
|
||||||
$this->render('index');
|
$this->render('index');
|
||||||
@ -89,11 +91,11 @@ class Monitoring_ConfigController extends BaseConfigController {
|
|||||||
$backendForm->setBackendConfiguration(IcingaConfig::module('monitoring', 'backends')->get($backend));
|
$backendForm->setBackendConfiguration(IcingaConfig::module('monitoring', 'backends')->get($backend));
|
||||||
|
|
||||||
if ($backendForm->isSubmittedAndValid()) {
|
if ($backendForm->isSubmittedAndValid()) {
|
||||||
|
|
||||||
$newConfig = $backendForm->getConfig();
|
$newConfig = $backendForm->getConfig();
|
||||||
$config = IcingaConfig::module('monitoring', 'backends');
|
$config = IcingaConfig::module('monitoring', 'backends');
|
||||||
$config->$backend = $newConfig;
|
$config->$backend = $newConfig;
|
||||||
if ($this->writeConfiguration($config, 'backends')) {
|
if ($this->writeConfiguration($config, 'backends')) {
|
||||||
|
$this->addSuccessMessage('Backend ' . $backend . ' Modified.');
|
||||||
$this->redirectNow('monitoring/config');
|
$this->redirectNow('monitoring/config');
|
||||||
} else {
|
} else {
|
||||||
$this->render('show-configuration');
|
$this->render('show-configuration');
|
||||||
@ -116,8 +118,8 @@ class Monitoring_ConfigController extends BaseConfigController {
|
|||||||
$configArray[$form->getBackendName()] = $form->getConfig();
|
$configArray[$form->getBackendName()] = $form->getConfig();
|
||||||
|
|
||||||
if ($this->writeConfiguration(new Zend_Config($configArray), 'backends')) {
|
if ($this->writeConfiguration(new Zend_Config($configArray), 'backends')) {
|
||||||
$this->view->successMessage = 'Backend Creation Succeeded';
|
$this->addSuccessMessage('Backend Creation Succeeded');
|
||||||
$this->indexAction();
|
$this->redirectNow('monitoring/config');
|
||||||
} else {
|
} else {
|
||||||
$this->render('show-configuration');
|
$this->render('show-configuration');
|
||||||
}
|
}
|
||||||
@ -146,8 +148,8 @@ class Monitoring_ConfigController extends BaseConfigController {
|
|||||||
unset($configArray[$backend]);
|
unset($configArray[$backend]);
|
||||||
|
|
||||||
if ($this->writeConfiguration(new Zend_Config($configArray), 'backends')) {
|
if ($this->writeConfiguration(new Zend_Config($configArray), 'backends')) {
|
||||||
$this->view->successMessage = 'Backend "' . $backend . '" Removed';
|
$this->addSuccessMessage('Backend "' . $backend . '" Removed');
|
||||||
$this->indexAction();
|
$this->redirectNow('monitoring/config');
|
||||||
} else {
|
} else {
|
||||||
$this->render('show-configuration');
|
$this->render('show-configuration');
|
||||||
}
|
}
|
||||||
@ -178,8 +180,8 @@ class Monitoring_ConfigController extends BaseConfigController {
|
|||||||
unset($configArray[$instance]);
|
unset($configArray[$instance]);
|
||||||
|
|
||||||
if ($this->writeConfiguration(new Zend_Config($configArray), 'instances')) {
|
if ($this->writeConfiguration(new Zend_Config($configArray), 'instances')) {
|
||||||
$this->view->successMessage = 'Instance "' . $instance . '" Removed';
|
$this->addSuccessMessage('Instance "' . $instance . '" Removed');
|
||||||
$this->indexAction();
|
$this->redirectNow('monitoring/config');
|
||||||
} else {
|
} else {
|
||||||
$this->render('show-configuration');
|
$this->render('show-configuration');
|
||||||
}
|
}
|
||||||
@ -207,8 +209,8 @@ class Monitoring_ConfigController extends BaseConfigController {
|
|||||||
$instanceConfig = IcingaConfig::module('monitoring', 'instances')->toArray();
|
$instanceConfig = IcingaConfig::module('monitoring', 'instances')->toArray();
|
||||||
$instanceConfig[$instance] = $form->getConfig();
|
$instanceConfig[$instance] = $form->getConfig();
|
||||||
if ($this->writeConfiguration(new Zend_Config($instanceConfig), 'instances')) {
|
if ($this->writeConfiguration(new Zend_Config($instanceConfig), 'instances')) {
|
||||||
$this->view->successMessage = 'Instance Modified';
|
$this->addSuccessMessage('Instance Modified');
|
||||||
$this->indexAction();
|
$this->redirectNow('monitoring/config');
|
||||||
} else {
|
} else {
|
||||||
$this->render('show-configuration');
|
$this->render('show-configuration');
|
||||||
return;
|
return;
|
||||||
@ -228,8 +230,8 @@ class Monitoring_ConfigController extends BaseConfigController {
|
|||||||
$instanceConfig = IcingaConfig::module('monitoring', 'instances')->toArray();
|
$instanceConfig = IcingaConfig::module('monitoring', 'instances')->toArray();
|
||||||
$instanceConfig[$form->getInstanceName()] = $form->getConfig()->toArray();
|
$instanceConfig[$form->getInstanceName()] = $form->getConfig()->toArray();
|
||||||
if ($this->writeConfiguration(new Zend_Config($instanceConfig), 'instances')) {
|
if ($this->writeConfiguration(new Zend_Config($instanceConfig), 'instances')) {
|
||||||
$this->view->successMessage = 'Instance Creation Succeeded';
|
$this->addSuccessMessage('Instance Creation Succeeded');
|
||||||
$this->indexAction();
|
$this->redirectNow('monitoring/config');
|
||||||
} else {
|
} else {
|
||||||
$this->render('show-configuration');
|
$this->render('show-configuration');
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,6 @@ class Monitoring_ShowController extends MonitoringController
|
|||||||
*/
|
*/
|
||||||
public function init()
|
public function init()
|
||||||
{
|
{
|
||||||
|
|
||||||
if ($this->getRequest()->getActionName() === 'host') {
|
if ($this->getRequest()->getActionName() === 'host') {
|
||||||
$this->view->object = new Host($this->getRequest());
|
$this->view->object = new Host($this->getRequest());
|
||||||
} elseif ($this->getRequest()->getActionName() === 'service'
|
} elseif ($this->getRequest()->getActionName() === 'service'
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
<?= $this->tabs->render($this); ?>
|
|
||||||
<?php if ($this->name): ?>
|
<?php if ($this->name): ?>
|
||||||
<h4><i>{{EDIT_ICON}} Edit Backend "<?= $this->escape($this->name) ?>"</h4>
|
<h4><i> <i class="icinga-icon-edit"></i> Edit Backend "<?= $this->escape($this->name) ?>"</h4>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<h4>{{CREATE_ICON}} Create New Backend</h4>
|
<h4> <i class="icinga-icon-create"></i> Create New Backend</h4>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
<?php if ($this->error): ?>
|
<?php if ($this->error): ?>
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
<?= $this->tabs->render($this); ?>
|
|
||||||
|
|
||||||
<?php if (isset($this->name)): ?>
|
<?php if (isset($this->name)): ?>
|
||||||
<h4>{{EDIT_ICON}} Edit Instance Configuration for "<?= $this->escape($this->name) ?>"</h4>
|
<h4><i class="icinga-icon-edit"></i> } Edit Instance Configuration for "<?= $this->escape($this->name) ?>"</h4>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<h4>{{CREATE_ICON}} Configure New Icinga Instance</h4>
|
<h4><i class="icinga-icon-create"></i> Configure New Icinga Instance</h4>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
<?php if ($this->error): ?>
|
<?php if ($this->error): ?>
|
||||||
|
@ -3,16 +3,13 @@
|
|||||||
|
|
||||||
<h3>Monitoring Backends</h3>
|
<h3>Monitoring Backends</h3>
|
||||||
|
|
||||||
<?php if ($this->successMessage): ?>
|
<?php if (isset($this->messageBox)): ?>
|
||||||
<div class="alert alert-success">
|
<?= $this->messageBox->render() ?>
|
||||||
<i>{{OK_ICON}}</i>
|
<?php endif ?>
|
||||||
<strong><?= $this->escape($this->successMessage); ?></strong>
|
|
||||||
</div>
|
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<a href="<?= Url::fromPath('/monitoring/config/createbackend')->getAbsoluteUrl();?>">
|
<a href="<?= Url::fromPath('/monitoring/config/createbackend')->getAbsoluteUrl();?>">
|
||||||
{{CREATE_ICON}} Create New Monitoring Backend
|
<i class="icinga-icon-create"></i> Create New Monitoring Backend
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<br/>
|
<br/>
|
||||||
@ -24,8 +21,8 @@
|
|||||||
<b><?= $this->escape($backendName); ?></b>
|
<b><?= $this->escape($backendName); ?></b>
|
||||||
<small>(Type: <?= $this->escape($config['type'] === 'ido' ? 'IDO' : ucfirst($config['type'])); ?>)</small>
|
<small>(Type: <?= $this->escape($config['type'] === 'ido' ? 'IDO' : ucfirst($config['type'])); ?>)</small>
|
||||||
<div>
|
<div>
|
||||||
<a href="<?= $removeUrl; ?>">{{REMOVE_ICON}} Remove This Backend</a><br/>
|
<a href="<?= $removeUrl; ?>"><i class="icinga-icon-remove"></i> Remove This Backend</a><br/>
|
||||||
<a href="<?= $editUrl; ?>">{{EDIT_ICON}} Edit This Backend</a>
|
<a href="<?= $editUrl; ?>"><i class="icinga-icon-edit"></i> Edit This Backend</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<br/>
|
<br/>
|
||||||
@ -37,7 +34,7 @@
|
|||||||
|
|
||||||
<div>
|
<div>
|
||||||
<a href="<?= Url::fromPath('/monitoring/config/createinstance')->getAbsoluteUrl();?>">
|
<a href="<?= Url::fromPath('/monitoring/config/createinstance')->getAbsoluteUrl();?>">
|
||||||
{{CREATE_ICON}} Create New Instance
|
<i class="icinga-icon-create"></i> Create New Instance
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -50,8 +47,8 @@
|
|||||||
<small>(Type: <?= isset($config['host']) ? 'Remote' : 'Local'; ?>)</small>
|
<small>(Type: <?= isset($config['host']) ? 'Remote' : 'Local'; ?>)</small>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<a href="<?= $removeUrl; ?>">{{REMOVE_ICON}} Remove This Instance</a><br/>
|
<a href="<?= $removeUrl; ?>"><i class="icinga-icon-remove"></i> Remove This Instance</a><br/>
|
||||||
<a href="<?= $editUrl; ?>">{{EDIT_ICON}} Edit This Instance</a>
|
<a href="<?= $editUrl; ?>"><i class="icinga-icon-edit"></i> Edit This Instance</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<br/>
|
<br/>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<?= $this->tabs->render($this); ?>
|
|
||||||
<h4>{{REMOVE_ICON}} Remove Backend "<?= $this->escape($this->name) ?>"</h4>
|
<h4><i class="icinga-icon-remove"></i> Remove Backend "<?= $this->escape($this->name) ?>"</h4>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Are you sure you want to remove the backend <?= $this->escape($this->name) ?>?
|
Are you sure you want to remove the backend <?= $this->escape($this->name) ?>?
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
<?= $this->tabs->render($this); ?>
|
|
||||||
<h4>{{REMOVE_ICON}} Remove Instance "<?= $this->escape($this->name) ?>"</h4>
|
<h4><i class="icinga-icon-remove"></i> Remove Instance "<?= $this->escape($this->name) ?>"</h4>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Are you sure you want to remove the instance <?= $this->escape($this->name) ?>?
|
Are you sure you want to remove the instance <?= $this->escape($this->name) ?>?
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
{{WARNING_ICON}} If you have still any environments or views refering to this instance, you won't be able to send commands anymore
|
<i class="icinga-icon-warning"></i> If you have still any environments or views refering to this instance, you won't be able to send commands anymore
|
||||||
after deletion.
|
after deletion.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?= $this->tabs->render($this); ?>
|
<?= $this->tabs->render($this); ?>
|
||||||
<br/>
|
<br/>
|
||||||
<div class="alert alert-error">
|
<div class="alert alert-error">
|
||||||
<h4><i>{{ERROR_ICON}}</i> Saving <?= $this->escape($this->file); ?>failed</h4>
|
<h4><i><i class="icinga-icon-error"></i> </i> Saving <?= $this->escape($this->file); ?>failed</h4>
|
||||||
<br/>
|
<br/>
|
||||||
<p>
|
<p>
|
||||||
Your <?= $this->escape($this->file); ?> configuration couldn't be stored (error: "<?= $this->exceptionMessage; ?>").<br/>
|
Your <?= $this->escape($this->file); ?> configuration couldn't be stored (error: "<?= $this->exceptionMessage; ?>").<br/>
|
||||||
|
@ -179,17 +179,6 @@ class ManagerTest extends BaseTestCase
|
|||||||
$this->assertTrue($auth->isAuthenticated());
|
$this->assertTrue($auth->isAuthenticated());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException Exception
|
|
||||||
* @expectedExceptionMessage Session write after close
|
|
||||||
*/
|
|
||||||
public function testWriteSessionTwice()
|
|
||||||
{
|
|
||||||
$auth = $this->getManagerInstance($session, false);
|
|
||||||
$this->assertFalse($auth->isAuthenticated(true));
|
|
||||||
$auth->authenticate(new Credential("jdoe", "passjdoe"));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException Icinga\Exception\ConfigurationError
|
* @expectedException Icinga\Exception\ConfigurationError
|
||||||
* @expectedExceptionMessage No authentication backend set
|
* @expectedExceptionMessage No authentication backend set
|
||||||
|
Loading…
x
Reference in New Issue
Block a user