Change _forward to redirect() to keep url history updates

refs #4382
This commit is contained in:
Marius Hein 2013-08-06 11:24:16 +02:00 committed by Johannes Meyer
parent 4befc9be94
commit 15999eb880
6 changed files with 108 additions and 53 deletions

View File

@ -94,8 +94,8 @@ class AuthenticationController extends ActionController
));
$this->replaceLayout = true;
$auth->removeAuthorization();
$this->_forward('login');
$this->redirect('login');
}
}
// @codingStandardsIgnoreEnd
// @codingStandardsIgnoreEnd

View File

@ -2,25 +2,28 @@
// @codingStandardsIgnoreStart
// {{{ICINGA_LICENSE_HEADER}}}
/**
* Icinga 2 Web - Head for multiple monitoring frontends
* This file is part of Icinga 2 Web.
*
* Icinga 2 Web - Head for multiple monitoring backends.
* Copyright (C) 2013 Icinga Development Team
*
*
* 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.
*
*
* 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.
*
*
* 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.
*
*
* @copyright 2013 Icinga Development Team <info@icinga.org>
* @author Icinga Development Team <info@icinga.org>
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
* @author Icinga Development Team <info@icinga.org>
*/
// {{{ICINGA_LICENSE_HEADER}}}
@ -47,7 +50,7 @@ class IndexController extends ActionController
{
parent::preDispatch(); // -> auth :(
if ($this->action_name !== 'welcome') {
$this->_forward('welcome');
$this->redirect('index/welcome');
}
}

39
application/controllers/ModulesController.php Executable file → Normal file
View File

@ -2,7 +2,9 @@
// @codingStandardsIgnoreStart
// {{{ICINGA_LICENSE_HEADER}}}
/**
* Icinga 2 Web - Head for multiple monitoring frontends
* This file is part of Icinga 2 Web.
*
* Icinga 2 Web - Head for multiple monitoring backends.
* Copyright (C) 2013 Icinga Development Team
*
* This program is free software; you can redistribute it and/or
@ -20,25 +22,42 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* @copyright 2013 Icinga Development Team <info@icinga.org>
* @author Icinga Development Team <info@icinga.org>
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
* @author Icinga Development Team <info@icinga.org>
*/
// {{{ICINGA_LICENSE_HEADER}}}
# namespace Icinga\Application\Controllers;
use Icinga\Web\ActionController;
use Icinga\Application\Icinga;
use Icinga\Web\Hook\Configuration\ConfigurationTabBuilder;
use Icinga\Application\Modules\Manager as ModuleManager;
use Zend_Controller_Action as ZfActionController;
/**
* Handle module depending frontend actions
*/
class ModulesController extends ActionController
{
/**
* @var ModuleManager
*/
protected $manager;
/**
* Setup this controller
* @see ZfActionController::init
*/
public function init()
{
$this->manager = Icinga::app()->getModuleManager();
}
/**
* Display a list of all modules
*/
public function indexAction()
{
$tabBuilder = new ConfigurationTabBuilder(
@ -55,25 +74,37 @@ class ModulesController extends ActionController
$this->render('overview');
}
/**
* Alias for index
*
* @see self::indexAction
*/
public function overviewAction()
{
$this->indexAction();
}
/**
* Enable a module
*/
public function enableAction()
{
$this->manager->enableModule($this->_getParam('name'));
$this->manager->loadModule($this->_getParam('name'));
$this->getResponse()->setHeader('X-Icinga-Enable-Module', $this->_getParam('name'));
$this->redirectNow('index?_render=body');
$this->redirectNow('modules/overview?_render=body');
}
/**
* Disable a module
*/
public function disableAction()
{
$this->manager->disableModule($this->_getParam('name'));
$this->redirectNow('modules/overview?_render=body');
}
}
// @codingStandardsIgnoreEnd

View File

@ -1,4 +1,31 @@
<?php
// @codingStandardsIgnoreStart
// {{{ICINGA_LICENSE_HEADER}}}
/**
* This file is part of Icinga 2 Web.
*
* Icinga 2 Web - Head for multiple monitoring backends.
* Copyright (C) 2013 Icinga Development Team
*
* 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.
*
* 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.
*
* 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.
*
* @copyright 2013 Icinga Development Team <info@icinga.org>
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
* @author Icinga Development Team <info@icinga.org>
*/
// {{{ICINGA_LICENSE_HEADER}}}
use Icinga\Web\ActionController;
use Icinga\Application\Icinga,
@ -47,7 +74,7 @@ class StaticController extends ActionController
{
$module = $this->_getParam('moduleName');
$file = $this->_getParam('file');
$basedir = Icinga::app()->getModule($module)->getBaseDir();
$basedir = Icinga::app()->getModuleManager()->getModule($module)->getBaseDir();
$filePath = $basedir . '/public/img/' . $file;
if (! file_exists($filePath)) {
@ -80,9 +107,10 @@ class StaticController extends ActionController
public function javascriptAction()
{
$module = $this->_getParam('moduleName');
$module = $this->_getParam('module_name');
$file = $this->_getParam('file');
$basedir = Icinga::app()->getModule($module)->getBaseDir();
$basedir = Icinga::app()->getModuleManager()->getModule($module)->getBaseDir();
$filePath = $basedir . '/public/js/' . $file;
if (!file_exists($filePath)) {
@ -119,3 +147,5 @@ class StaticController extends ActionController
}
}
// @codingStandardsIgnoreEnd

View File

@ -683,42 +683,6 @@ class CommandPipe
}
}
/**
* Start obsessing over provided services/hosts
*
* @param array $objects An array of hosts and/or services
*/
public function startObsessing($objects)
{
foreach ($objects as $object) {
$type = $this->getObjectType($object);
$msg = "START_OBSESSING_OVER_". (($type == self::TYPE_SERVICE) ? 'SVC' : 'HOST');
$msg .= ';'.$object->host_name;
if ($type == self::TYPE_SERVICE) {
$msg .= ';'.$object->service_description;
}
$this->send($msg);
}
}
/**
* Stop obsessing over provided services/hosts
*
* @param array $objects An array of hosts and/or services
*/
public function stopObsessing($objects)
{
foreach ($objects as $object) {
$type = $this->getObjectType($object);
$msg = "STOP_OBSESSING_OVER_". (($type == self::TYPE_SERVICE) ? 'SVC' : 'HOST');
$msg .= ';'.$object->host_name;
if ($type == self::TYPE_SERVICE) {
$msg .= ';'.$object->service_description;
}
$this->send($msg);
}
}
/**
* Send a custom host or service notification
*

View File

@ -1,5 +1,30 @@
<?php
// @codingStandardsIgnoreStart
// {{{ICINGA_LICENSE_HEADER}}}
/**
* This file is part of Icinga 2 Web.
*
* Icinga 2 Web - Head for multiple monitoring backends.
* Copyright (C) 2013 Icinga Development Team
*
* 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.
*
* 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.
*
* 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.
*
* @copyright 2013 Icinga Development Team <info@icinga.org>
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
* @author Icinga Development Team <info@icinga.org>
*/
// {{{ICINGA_LICENSE_HEADER}}}
use Monitoring\Backend;
@ -342,7 +367,7 @@ class Monitoring_ShowController extends ModuleActionController
$id = $this->_getParam('ticket');
$ticketModule = 'rt';
$this->render();
$this->_forward(
$this->redirect(
'ticket',
'show',
$ticketModule,
@ -483,3 +508,5 @@ class Monitoring_ShowController extends ModuleActionController
return $tabs;
}
}
// @codingStandardsIgnoreEnd