From 15999eb8806da5027cd0441e7027c03001614ae2 Mon Sep 17 00:00:00 2001 From: Marius Hein Date: Tue, 6 Aug 2013 11:24:16 +0200 Subject: [PATCH] Change _forward to redirect() to keep url history updates refs #4382 --- .../controllers/AuthenticationController.php | 4 +- application/controllers/IndexController.php | 17 ++++---- application/controllers/ModulesController.php | 39 +++++++++++++++++-- application/controllers/StaticController.php | 36 +++++++++++++++-- .../Protocol/Commandpipe/CommandPipe.php | 36 ----------------- .../controllers/ShowController.php | 29 +++++++++++++- 6 files changed, 108 insertions(+), 53 deletions(-) mode change 100755 => 100644 application/controllers/ModulesController.php diff --git a/application/controllers/AuthenticationController.php b/application/controllers/AuthenticationController.php index 5be42b855..3f0928bc7 100644 --- a/application/controllers/AuthenticationController.php +++ b/application/controllers/AuthenticationController.php @@ -94,8 +94,8 @@ class AuthenticationController extends ActionController )); $this->replaceLayout = true; $auth->removeAuthorization(); - $this->_forward('login'); + $this->redirect('login'); } } -// @codingStandardsIgnoreEnd +// @codingStandardsIgnoreEnd \ No newline at end of file diff --git a/application/controllers/IndexController.php b/application/controllers/IndexController.php index 3e1d83c38..7b3e68ad5 100644 --- a/application/controllers/IndexController.php +++ b/application/controllers/IndexController.php @@ -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 - * @author Icinga Development Team + * @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2 + * @author Icinga Development Team */ // {{{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'); } } diff --git a/application/controllers/ModulesController.php b/application/controllers/ModulesController.php old mode 100755 new mode 100644 index 9c6fc856a..a089af192 --- a/application/controllers/ModulesController.php +++ b/application/controllers/ModulesController.php @@ -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 - * @author Icinga Development Team + * @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2 + * @author Icinga Development Team */ // {{{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 \ No newline at end of file diff --git a/application/controllers/StaticController.php b/application/controllers/StaticController.php index c39249594..98ed57149 100644 --- a/application/controllers/StaticController.php +++ b/application/controllers/StaticController.php @@ -1,4 +1,31 @@ + * @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2 + * @author Icinga Development Team + */ +// {{{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 \ No newline at end of file diff --git a/library/Icinga/Protocol/Commandpipe/CommandPipe.php b/library/Icinga/Protocol/Commandpipe/CommandPipe.php index 2c4392294..520a2949c 100644 --- a/library/Icinga/Protocol/Commandpipe/CommandPipe.php +++ b/library/Icinga/Protocol/Commandpipe/CommandPipe.php @@ -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 * diff --git a/modules/monitoring/application/controllers/ShowController.php b/modules/monitoring/application/controllers/ShowController.php index 23ba73b49..e56c51948 100644 --- a/modules/monitoring/application/controllers/ShowController.php +++ b/modules/monitoring/application/controllers/ShowController.php @@ -1,5 +1,30 @@ + * @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2 + * @author Icinga Development Team + */ // {{{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 \ No newline at end of file