diff --git a/application/controllers/AboutController.php b/application/controllers/AboutController.php index a4247f234..fc1c78931 100644 --- a/application/controllers/AboutController.php +++ b/application/controllers/AboutController.php @@ -1,10 +1,10 @@ getRequest()->hasCookieSupport()) { - echo $this->translate("Cookies must be enabled to run this application.\n"); - $this->getResponse()->setHttpResponseCode(403)->sendHeaders(); + $this + ->getResponse() + ->setBody("Cookies must be enabled to run this application.\n") + ->setHttpResponseCode(403) + ->sendResponse(); exit(); } $form->handleRequest(); diff --git a/application/controllers/ConfigController.php b/application/controllers/ConfigController.php index 09e40f408..5a33f9792 100644 --- a/application/controllers/ConfigController.php +++ b/application/controllers/ConfigController.php @@ -1,21 +1,24 @@ registry = new Filter(); - $query = $this->getRequest()->getParam('query', ''); - $target = $this->getRequest()->getParam('filter_domain', ''); - - if ($this->getRequest()->getHeader('accept') == 'application/json') { - $this->getResponse()->setHeader('Content-Type', 'application/json'); - $this->setupQueries( - $target, - $this->getParam('filter_module', '') - ); - $this->_helper->json($this->parse($query, $target)); - } else { - $this->setupQueries( - $target, - $this->getParam('filter_module') - ); - $urlTarget = $this->parse($query, $target); - $this->redirect($urlTarget['urlParam']); - } - - - } - - /** - * Set up the query handler for the given domain and module - * - * @param string $domain The domain to use - * @param string $module The module to use - */ - private function setupQueries($domain, $module = 'default') - { - $class = '\\Icinga\\Module\\' . ucfirst($module) . '\\Filter\\Registry'; - $factory = strtolower($domain) . 'Filter'; - $this->moduleRegistry = $class; - $this->registry->addDomain($class::$factory()); - } - - /** - * Parse the given query text and returns the json as expected by the semantic search box - * - * @param String $text The query to parse - * @return array The result structure to be returned in json format - */ - private function parse($text, $target) - { - try { - - $queryTree = $this->registry->createQueryTreeForFilter($text); - $registry = $this->moduleRegistry; - return array( - 'state' => 'success', - 'proposals' => $this->registry->getProposalsForQuery($text), - 'urlParam' => $registry::getUrlForTarget($target, $queryTree), - 'valid' => count($this->registry->getIgnoredQueryParts()) === 0 - ); - } catch (\Exception $exc) { - Logger::error($exc); - $this->getResponse()->setHttpResponseCode(500); - return array( - 'state' => 'error', - 'message' => 'Search service is currently not available' - ); - } - } -} diff --git a/application/controllers/GroupController.php b/application/controllers/GroupController.php index 0f0e9514d..bc0211fa3 100644 --- a/application/controllers/GroupController.php +++ b/application/controllers/GroupController.php @@ -1,10 +1,13 @@ getRequest()->getActionName() !== 'welcome') { + // @TODO(el): Avoid landing page redirects: https://dev.icinga.org/issues/9656 $this->redirectNow(Url::fromRequest()->setPath('dashboard')); } } diff --git a/application/controllers/LayoutController.php b/application/controllers/LayoutController.php index 8e391da35..335bee8e0 100644 --- a/application/controllers/LayoutController.php +++ b/application/controllers/LayoutController.php @@ -1,10 +1,12 @@ getValues(); try { $role->add($name, $values); - } catch (InvalidArgumentException $e) { + } catch (AlreadyExistsException $e) { $role->addError($e->getMessage()); return false; } @@ -54,19 +63,11 @@ class RoleController extends AuthBackendController /** * Update a role - * - * @throws Zend_Controller_Action_Exception If the required parameter 'role' is missing or the role does not exist */ public function editAction() { $this->assertPermission('config/authentication/roles/edit'); - $name = $this->_request->getParam('role'); - if (empty($name)) { - throw new Zend_Controller_Action_Exception( - sprintf($this->translate('Required parameter \'%s\' missing'), 'role'), - 400 - ); - } + $name = $this->params->getRequired('role'); $role = new RoleForm(); $role->setTitle(sprintf($this->translate('Update Role %s'), $name)); $role->setSubmitLabel($this->translate('Update Role')); @@ -74,11 +75,8 @@ class RoleController extends AuthBackendController $role ->setIniConfig(Config::app('roles', true)) ->load($name); - } catch (InvalidArgumentException $e) { - throw new Zend_Controller_Action_Exception( - $e->getMessage(), - 400 - ); + } catch (NotFoundError $e) { + $this->httpNotFound($e->getMessage()); } $role ->setOnSuccess(function (RoleForm $role) use ($name) { @@ -87,7 +85,7 @@ class RoleController extends AuthBackendController $values = $role->getValues(); try { $role->update($name, $values, $oldName); - } catch (InvalidArgumentException $e) { + } catch (NotFoundError $e) { $role->addError($e->getMessage()); return false; } @@ -105,35 +103,24 @@ class RoleController extends AuthBackendController /** * Remove a role - * - * @throws Zend_Controller_Action_Exception If the required parameter 'role' is missing or the role does not exist */ public function removeAction() { $this->assertPermission('config/authentication/roles/remove'); - $name = $this->_request->getParam('role'); - if (empty($name)) { - throw new Zend_Controller_Action_Exception( - sprintf($this->translate('Required parameter \'%s\' missing'), 'role'), - 400 - ); - } + $name = $this->params->getRequired('role'); $role = new RoleForm(); try { $role ->setIniConfig(Config::app('roles', true)) ->load($name); - } catch (InvalidArgumentException $e) { - throw new Zend_Controller_Action_Exception( - $e->getMessage(), - 400 - ); + } catch (NotFoundError $e) { + $this->httpNotFound($e->getMessage()); } $confirmation = new ConfirmRemovalForm(array( 'onSuccess' => function (ConfirmRemovalForm $confirmation) use ($name, $role) { try { $role->remove($name); - } catch (InvalidArgumentException $e) { + } catch (NotFoundError $e) { Notification::error($e->getMessage()); return false; } @@ -162,15 +149,15 @@ class RoleController extends AuthBackendController $tabs->add( 'role/list', array( - 'title' => $this->translate( + 'baseTarget' => '_main', + 'label' => $this->translate('Roles'), + 'title' => $this->translate( 'Configure roles to permit or restrict users and groups accessing Icinga Web 2' ), - 'label' => $this->translate('Roles'), - 'url' => 'role/list', - 'baseTarget' => '_main' + 'url' => 'role/list' + ) ); - return $tabs; } } diff --git a/application/controllers/SearchController.php b/application/controllers/SearchController.php index aa5cfaf9d..d14654cdb 100644 --- a/application/controllers/SearchController.php +++ b/application/controllers/SearchController.php @@ -1,6 +1,8 @@ _getParam('module_name'); $file = $this->_getParam('file'); $basedir = Icinga::app()->getModuleManager()->getModule($module)->getBaseDir(); $filePath = realpath($basedir . '/public/img/' . $file); - if (! $filePath || strpos($filePath, $basedir) !== 0) { - throw new ActionException(sprintf( - '%s does not exist', - $filePath - ), 404); + if ($filePath === false) { + $this->httpNotFound('%s does not exist', $filePath); } if (preg_match('/\.([a-z]+)$/i', $file, $m)) { $extension = $m[1]; @@ -80,10 +80,7 @@ class StaticController extends ActionController header(sprintf('ETag: "%x-%x-%x"', $s['ino'], $s['size'], (float) str_pad($s['mtime'], 16, '0'))); header('Cache-Control: public, max-age=3600'); header('Pragma: cache'); - header('Last-Modified: ' . gmdate( - 'D, d M Y H:i:s', - $s['mtime'] - ) . ' GMT'); + header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $s['mtime']) . ' GMT'); readfile($filePath); } @@ -100,7 +97,7 @@ class StaticController extends ActionController $basedir = Icinga::app()->getApplicationDir('../public/js/icinga/components/'); $filePath = $basedir . $file; } else { - if (!Icinga::app()->getModuleManager()->hasEnabled($module)) { + if (! Icinga::app()->getModuleManager()->hasEnabled($module)) { Logger::error( 'Non-existing frontend component "' . $module . '/' . $file . '" was requested. The module "' . $module . '" does not exist or is not active.' @@ -112,7 +109,7 @@ class StaticController extends ActionController $filePath = $basedir . '/public/js/' . $file; } - if (!file_exists($filePath)) { + if (! file_exists($filePath)) { Logger::error( 'Non-existing frontend component "' . $module . '/' . $file . '" was requested, which would resolve to the the path: ' . $filePath @@ -122,41 +119,41 @@ class StaticController extends ActionController } $response = $this->getResponse(); $response->setHeader('Content-Type', 'text/javascript'); - $this->setCacheHeader(3600); + $this->setCacheHeader(); $response->setHeader( 'Last-Modified', - gmdate( - 'D, d M Y H:i:s', - filemtime($filePath) - ) . ' GMT' + gmdate('D, d M Y H:i:s', filemtime($filePath)) . ' GMT' ); readfile($filePath); } /** - * Set cache header for this response + * Set cache header for the response * - * @param integer $maxAge The maximum age to set + * @param int $maxAge The maximum age to set */ - private function setCacheHeader($maxAge) + private function setCacheHeader($maxAge = 3600) { - $this->_response->setHeader('Cache-Control', 'max-age=3600', true); - $this->_response->setHeader('Pragma', 'cache', true); - $this->_response->setHeader( - 'Expires', - gmdate( - 'D, d M Y H:i:s', - time()+3600 - ) . ' GMT', - true - ); + $maxAge = (int) $maxAge; + $this + ->getResponse() + ->setHeader('Cache-Control', sprintf('max-age=%d', $maxAge), true) + ->setHeader('Pragma', 'cache', true) + ->setHeader( + 'Expires', + gmdate('D, d M Y H:i:s', time() + $maxAge) . ' GMT', + true + ); } + /** + * Send application's and modules' CSS + */ public function stylesheetAction() { - $lessCompiler = new \Icinga\Web\LessCompiler(); + $lessCompiler = new LessCompiler(); $moduleManager = Icinga::app()->getModuleManager(); $publicDir = realpath(dirname($_SERVER['SCRIPT_FILENAME'])); @@ -172,7 +169,7 @@ class StaticController extends ActionController } } - $this->_response->setHeader('Content-Type', 'text/css'); + $this->getResponse()->setHeader('Content-Type', 'text/css'); $this->setCacheHeader(3600); $lessCompiler->printStack(); diff --git a/application/controllers/UserController.php b/application/controllers/UserController.php index a5fec106a..40192b42f 100644 --- a/application/controllers/UserController.php +++ b/application/controllers/UserController.php @@ -1,12 +1,15 @@ config->hasSection($name)) { - throw new InvalidArgumentException(sprintf( + throw new NotFoundError( $this->translate('Can\'t load role \'%s\'. Role does not exist'), $name - )); + ); } $role = $this->config->getSection($name)->toArray(); $role['permissions'] = ! empty($role['permissions']) @@ -202,14 +204,14 @@ class RoleForm extends ConfigForm /** * Add a role * - * @param string $name The name of the role + * @param string $name The name of the role * @param array $values * * @return $this * - * @throws LogicException If the config is not set - * @throws InvalidArgumentException If the role to add already exists - * @see ConfigForm::setConfig() For setting the config. + * @throws LogicException If the config is not set + * @throws AlreadyExistsException If the role to add already exists + * @see ConfigForm::setConfig() For setting the config. */ public function add($name, array $values) { @@ -217,10 +219,10 @@ class RoleForm extends ConfigForm throw new LogicException(sprintf('Can\'t add role \'%s\'. Config is not set', $name)); } if ($this->config->hasSection($name)) { - throw new InvalidArgumentException(sprintf( + throw new AlreadyExistsException( $this->translate('Can\'t add role \'%s\'. Role already exists'), $name - )); + ); } $this->config->setSection($name, $values); return $this; @@ -229,13 +231,13 @@ class RoleForm extends ConfigForm /** * Remove a role * - * @param string $name The name of the role + * @param string $name The name of the role * * @return $this * - * @throws LogicException If the config is not set - * @throws InvalidArgumentException If the role does not exist - * @see ConfigForm::setConfig() For setting the config. + * @throws LogicException If the config is not set + * @throws NotFoundError If the role does not exist + * @see ConfigForm::setConfig() For setting the config. */ public function remove($name) { @@ -243,10 +245,10 @@ class RoleForm extends ConfigForm throw new LogicException(sprintf('Can\'t remove role \'%s\'. Config is not set', $name)); } if (! $this->config->hasSection($name)) { - throw new InvalidArgumentException(sprintf( + throw new NotFoundError( $this->translate('Can\'t remove role \'%s\'. Role does not exist'), $name - )); + ); } $this->config->removeSection($name); return $this; @@ -255,15 +257,15 @@ class RoleForm extends ConfigForm /** * Update a role * - * @param string $name The possibly new name of the role + * @param string $name The possibly new name of the role * @param array $values - * @param string $oldName The name of the role to update + * @param string $oldName The name of the role to update * * @return $this * - * @throws LogicException If the config is not set - * @throws InvalidArgumentException If the role to update does not exist - * @see ConfigForm::setConfig() For setting the config. + * @throws LogicException If the config is not set + * @throws NotFoundError If the role to update does not exist + * @see ConfigForm::setConfig() For setting the config. */ public function update($name, array $values, $oldName) { @@ -276,10 +278,10 @@ class RoleForm extends ConfigForm $this->add($name, $values); } else { if (! $this->config->hasSection($name)) { - throw new InvalidArgumentException(sprintf( + throw new NotFoundError( $this->translate('Can\'t update role \'%s\'. Role does not exist'), $name - )); + ); } $this->config->setSection($name, $values); } diff --git a/library/Icinga/Application/ApplicationBootstrap.php b/library/Icinga/Application/ApplicationBootstrap.php index a8d185023..c46aa3a27 100644 --- a/library/Icinga/Application/ApplicationBootstrap.php +++ b/library/Icinga/Application/ApplicationBootstrap.php @@ -78,9 +78,9 @@ abstract class ApplicationBootstrap protected $configDir; /** - * Icinga auto loader + * Icinga class loader * - * @var Loader + * @var ClassLoader */ private $loader; @@ -183,7 +183,7 @@ abstract class ApplicationBootstrap /** * Getter for class loader * - * @return Loader + * @return ClassLoader */ public function getLoader() { @@ -339,15 +339,15 @@ abstract class ApplicationBootstrap } /** - * Setup Icinga auto loader + * Setup Icinga class loader * * @return $this */ public function setupAutoloader() { - require $this->libDir . '/Icinga/Application/Loader.php'; + require $this->libDir . '/Icinga/Application/ClassLoader.php'; - $this->loader = new Loader(); + $this->loader = new ClassLoader(); $this->loader->registerNamespace('Icinga', $this->libDir. '/Icinga'); $this->loader->register(); diff --git a/library/Icinga/Application/ClassLoader.php b/library/Icinga/Application/ClassLoader.php new file mode 100644 index 000000000..3247d3250 --- /dev/null +++ b/library/Icinga/Application/ClassLoader.php @@ -0,0 +1,113 @@ +namespaces[$namespace] = $directory; + + return $this; + } + + /** + * Test whether a namespace exists + * + * @param string $namespace + * + * @return bool + */ + public function hasNamespace($namespace) + { + return array_key_exists($namespace, $this->namespaces); + } + + /** + * Get the source file of the given class or interface + * + * @param string $class Name of the class or interface + * + * @return string|null + */ + public function getSourceFile($class) + { + foreach ($this->namespaces as $namespace => $dir) { + if ($class === strstr($class, $namespace)) { + $classPath = str_replace( + self::NAMESPACE_SEPARATOR, + DIRECTORY_SEPARATOR, + substr($class, strlen($namespace)) + ) . '.php'; + if (file_exists($file = $dir . $classPath)) { + return $file; + } + } + } + return null; + } + + /** + * Load the given class or interface + * + * @param string $class Name of the class or interface + * + * @return bool Whether the class or interface has been loaded + */ + public function loadClass($class) + { + if ($file = $this->getSourceFile($class)) { + require $file; + return true; + } + return false; + } + + /** + * Register {@link loadClass()} as an autoloader + */ + public function register() + { + spl_autoload_register(array($this, 'loadClass')); + } + + /** + * Unregister {@link loadClass()} as an autoloader + */ + public function unregister() + { + spl_autoload_unregister(array($this, 'loadClass')); + } + + /** + * Unregister this as an autoloader + */ + public function __destruct() + { + $this->unregister(); + } +} diff --git a/library/Icinga/Application/Loader.php b/library/Icinga/Application/Loader.php deleted file mode 100644 index 8c1c0b9e7..000000000 --- a/library/Icinga/Application/Loader.php +++ /dev/null @@ -1,138 +0,0 @@ -unRegister(); - } - - /** - * Register new namespace for directory - * - * @param string $namespace - * @param string $directory - * - * @throws ProgrammingError - */ - public function registerNamespace($namespace, $directory) - { - if (!is_dir($directory)) { - throw new ProgrammingError( - 'Directory "%s" for namespace "%s" does not exist', - $directory, - $namespace - ); - } - - $this->namespaces[$namespace] = $directory; - } - - /** - * Test if a namespace exists - * - * @param string $namespace - * - * @return bool - */ - public function hasNamespace($namespace) - { - return array_key_exists($namespace, $this->namespaces); - } - - /** - * Class loader - * - * Ignores all but classes in registered namespaces. - * - * @param string $class - * - * @return boolean - */ - public function loadClass($class) - { - $namespace = $this->getNamespaceForClass($class); - - if ($namespace) { - $file = $this->namespaces[$namespace] . preg_replace('/^' . preg_quote($namespace) . '/', '', $class); - $file = str_replace(self::NAMESPACE_SEPARATOR, '/', $file) . '.php'; - - if (@file_exists($file)) { - require_once $file; - return true; - } - } - - return false; - } - - /** - * Test if we have a registered namespaces for this class - * - * Return is the longest match in the array found - * - * @param string $className - * - * @return bool|string - */ - private function getNamespaceForClass($className) - { - $testNamespace = ''; - $testLength = 0; - - foreach (array_keys($this->namespaces) as $namespace) { - $stub = preg_replace( - '/^' . preg_quote($namespace) . '(' . preg_quote(self::NAMESPACE_SEPARATOR) . '|$)/', '', $className - ); - $length = strlen($className) - strlen($stub); - if ($length > $testLength) { - $testLength = $length; - $testNamespace = $namespace; - } - } - - if ($testLength > 0) { - return $testNamespace; - } - - return false; - } - - /** - * Effectively registers the autoloader the PHP/SPL way - */ - public function register() - { - // Think about to add class pathes to php include path - // this could be faster (tg) - spl_autoload_register(array(&$this, 'loadClass')); - } - - /** - * Detach autoloader from spl registration - */ - public function unRegister() - { - spl_autoload_unregister(array(&$this, 'loadClass')); - } -} diff --git a/library/Icinga/Application/Modules/Module.php b/library/Icinga/Application/Modules/Module.php index 7c415e05c..61256c7d5 100644 --- a/library/Icinga/Application/Modules/Module.php +++ b/library/Icinga/Application/Modules/Module.php @@ -17,6 +17,7 @@ use Icinga\Exception\ProgrammingError; use Icinga\Module\Setup\SetupWizard; use Icinga\Util\File; use Icinga\Util\Translator; +use Icinga\Web\Controller\Dispatcher; use Icinga\Web\Hook; use Icinga\Web\Menu; use Icinga\Web\Widget; @@ -935,7 +936,7 @@ class Module } /** - * Register module namespaces on the autoloader + * Register module namespaces on our class loader * * @return $this */ @@ -945,16 +946,17 @@ class Module return $this; } + $loader = $this->app->getLoader(); $moduleName = ucfirst($this->getName()); $moduleLibraryDir = $this->getLibDir(). '/'. $moduleName; if (is_dir($moduleLibraryDir)) { - $this->app->getLoader()->registerNamespace('Icinga\\Module\\' . $moduleName, $moduleLibraryDir); + $loader->registerNamespace('Icinga\\Module\\' . $moduleName, $moduleLibraryDir); } $moduleFormDir = $this->getFormDir(); if (is_dir($moduleFormDir)) { - $this->app->getLoader()->registerNamespace('Icinga\\Module\\' . $moduleName. '\\Forms', $moduleFormDir); + $loader->registerNamespace('Icinga\\Module\\' . $moduleName. '\\Forms', $moduleFormDir); } $this->registeredAutoloader = true; @@ -1016,19 +1018,23 @@ class Module */ protected function registerWebIntegration() { - if (!$this->app->isWeb()) { + if (! $this->app->isWeb()) { return $this; } - - if (file_exists($this->controllerdir) && is_dir($this->controllerdir)) { + $moduleControllerDir = $this->getControllerDir(); + if (is_dir($moduleControllerDir)) { $this->app->getfrontController()->addControllerDirectory( - $this->controllerdir, - $this->name + $moduleControllerDir, + $this->getName() + ); + $this->app->getLoader()->registerNamespace( + 'Icinga\\Module\\' . ucfirst($this->getName()) . '\\' . Dispatcher::CONTROLLER_NAMESPACE, + $moduleControllerDir ); } - - $this->registerLocales() - ->registerRoutes(); + $this + ->registerLocales() + ->registerRoutes(); return $this; } @@ -1049,8 +1055,9 @@ class Module new Zend_Controller_Router_Route( 'js/' . $this->name . '/:file', array( + 'action' => 'javascript', 'controller' => 'static', - 'action' =>'javascript', + 'module' => 'default', 'module_name' => $this->name ) ) @@ -1060,8 +1067,9 @@ class Module new Zend_Controller_Router_Route_Regex( 'img/' . $this->name . '/(.+)', array( - 'controller' => 'static', 'action' => 'img', + 'controller' => 'static', + 'module' => 'default', 'module_name' => $this->name ), array( diff --git a/library/Icinga/Application/Version.php b/library/Icinga/Application/Version.php index 65b6138d9..c06eca2c2 100644 --- a/library/Icinga/Application/Version.php +++ b/library/Icinga/Application/Version.php @@ -3,12 +3,15 @@ namespace Icinga\Application; +/** + * Retrieve the version of Icinga Web 2 + */ class Version { /** * Get the version of this instance of Icinga Web 2 * - * @return array|bool array on success, false otherwise + * @return array|false array on success, false otherwise */ public static function get() { diff --git a/library/Icinga/Application/Web.php b/library/Icinga/Application/Web.php index 3ee5af39e..e854b8e51 100644 --- a/library/Icinga/Application/Web.php +++ b/library/Icinga/Application/Web.php @@ -15,6 +15,7 @@ use Icinga\Authentication\Auth; use Icinga\User; use Icinga\Util\TimezoneDetect; use Icinga\Util\Translator; +use Icinga\Web\Controller\Dispatcher; use Icinga\Web\Notification; use Icinga\Web\Session; use Icinga\Web\Session\Session as BaseSession; @@ -88,7 +89,7 @@ class Web extends EmbeddedWeb ->setupLogger() ->setupInternationalization() ->setupZendMvc() - ->setupFormNamespace() + ->setupNamespaces() ->setupModuleManager() ->setupUserBackendFactory() ->loadSetupModuleIfNecessary() @@ -210,6 +211,7 @@ class Web extends EmbeddedWeb private function setupFrontController() { $this->frontController = Zend_Controller_Front::getInstance(); + $this->frontController->setDispatcher(new Dispatcher()); $this->frontController->setRequest($this->getRequest()); $this->frontController->setControllerDirectory($this->getApplicationDir('/controllers')); @@ -306,16 +308,22 @@ class Web extends EmbeddedWeb } /** - * Setup an autoloader namespace for Icinga\Forms + * Setup class loader namespaces for Icinga\Controllers and Icinga\Forms * * @return $this */ - private function setupFormNamespace() + private function setupNamespaces() { - $this->getLoader()->registerNamespace( - 'Icinga\\Forms', - $this->getApplicationDir('forms') - ); + $this + ->getLoader() + ->registerNamespace( + 'Icinga\\' . Dispatcher::CONTROLLER_NAMESPACE, + $this->getApplicationDir('controllers') + ) + ->registerNamespace( + 'Icinga\\Forms', + $this->getApplicationDir('forms') + ); return $this; } } diff --git a/library/Icinga/Application/webrouter.php b/library/Icinga/Application/webrouter.php index 5a7d1c95c..5c8cbb6ea 100644 --- a/library/Icinga/Application/webrouter.php +++ b/library/Icinga/Application/webrouter.php @@ -3,11 +3,9 @@ namespace Icinga\Application; -use Icinga\Application\EmbeddedWeb; -use Icinga\Application\Web; -use Icinga\Web\StyleSheet; -use Icinga\Web\JavaScript; use Icinga\Chart\Inline\PieChart; +use Icinga\Web\JavaScript; +use Icinga\Web\StyleSheet; error_reporting(E_ALL | E_STRICT); diff --git a/library/Icinga/Exception/AlreadyExistsException.php b/library/Icinga/Exception/AlreadyExistsException.php new file mode 100644 index 000000000..ea1a1399a --- /dev/null +++ b/library/Icinga/Exception/AlreadyExistsException.php @@ -0,0 +1,11 @@ +setResponse($response); + $controllerName = $request->getControllerName(); + if (! $controllerName) { + parent::dispatch($request, $response); + return; + } + $controllerName = ucfirst($controllerName) . 'Controller'; + $moduleName = $request->getModuleName(); + if ($moduleName === null || $moduleName === $this->_defaultModule) { + $controllerClass = 'Icinga\\' . self::CONTROLLER_NAMESPACE . '\\' . $controllerName; + } else { + $controllerClass = 'Icinga\\Module\\' . ucfirst($moduleName) . '\\' . self::CONTROLLER_NAMESPACE . '\\' + . $controllerName; + } + if (! class_exists($controllerClass)) { + parent::dispatch($request, $response); + return; + } + $controller = new $controllerClass($request, $response, $this->getParams()); + if (! $controller instanceof Zend_Controller_Action + && ! $controller instanceof Zend_Controller_Action_Interface + ) { + throw new Zend_Controller_Dispatcher_Exception( + 'Controller "' . $controllerClass . '" is not an instance of Zend_Controller_Action_Interface' + ); + } + $action = $this->getActionMethod($request); + $request->setDispatched(true); + // Buffer output by default + $disableOb = $this->getParam('disableOutputBuffering'); + $obLevel = ob_get_level(); + if (empty($disableOb)) { + ob_start(); + } + try { + $controller->dispatch($action); + } catch (Exception $e) { + // Clean output buffer on error + $curObLevel = ob_get_level(); + if ($curObLevel > $obLevel) { + do { + ob_get_clean(); + $curObLevel = ob_get_level(); + } while ($curObLevel > $obLevel); + } + throw $e; + } + if (empty($disableOb)) { + $content = ob_get_clean(); + $response->appendBody($content); + } + } +} diff --git a/library/Icinga/Web/Form.php b/library/Icinga/Web/Form.php index 8dd3d1b7a..720654c07 100644 --- a/library/Icinga/Web/Form.php +++ b/library/Icinga/Web/Form.php @@ -1012,6 +1012,8 @@ class Form extends Zend_Form * Populate the elements with the given values * * @param array $defaults The values to populate the elements with + * + * @return $this */ public function populate(array $defaults) { diff --git a/modules/doc/application/controllers/IcingawebController.php b/modules/doc/application/controllers/IcingawebController.php index 9fccd32fa..252e0cfe6 100644 --- a/modules/doc/application/controllers/IcingawebController.php +++ b/modules/doc/application/controllers/IcingawebController.php @@ -1,17 +1,19 @@ applyRestriction('monitoring/filter/objects', $query); $query->addFilter( - new Icinga\Data\Filter\FilterExpression( + new FilterExpression( 'notification_start_time', '>=', $this->getBeginDate($interval)->format('Y-m-d H:i:s') @@ -144,7 +152,7 @@ class Monitoring_AlertsummaryController extends Controller $this->applyRestriction('monitoring/filter/objects', $query); $query->addFilter( - new Icinga\Data\Filter\FilterExpression( + new FilterExpression( 'notification_start_time', '>=', $beginDate->format('Y-m-d H:i:s') @@ -212,7 +220,7 @@ class Monitoring_AlertsummaryController extends Controller $this->applyRestriction('monitoring/filter/objects', $query); $query->addFilter( - new Icinga\Data\Filter\FilterExpression( + new FilterExpression( 'notification_start_time', '>=', $this->getBeginDate($interval)->format('Y-m-d H:i:s') @@ -263,7 +271,7 @@ class Monitoring_AlertsummaryController extends Controller $this->applyRestriction('monitoring/filter/objects', $query); $query->addFilter( - new Icinga\Data\Filter\FilterExpression( + new FilterExpression( 'timestamp', '>=', $this->getBeginDate($interval)->getTimestamp() @@ -271,7 +279,7 @@ class Monitoring_AlertsummaryController extends Controller ); $query->addFilter( - new Icinga\Data\Filter\FilterExpression( + new FilterExpression( 'state', '>', 0 @@ -329,7 +337,7 @@ class Monitoring_AlertsummaryController extends Controller $this->applyRestriction('monitoring/filter/objects', $query); $query->addFilter( - new Icinga\Data\Filter\FilterExpression( + new FilterExpression( 'notification_start_time', '>=', $this->getBeginDate($interval)->format('Y-m-d H:i:s') diff --git a/modules/monitoring/application/controllers/ChartController.php b/modules/monitoring/application/controllers/ChartController.php index d2e9f990c..63e8eae29 100644 --- a/modules/monitoring/application/controllers/ChartController.php +++ b/modules/monitoring/application/controllers/ChartController.php @@ -1,20 +1,18 @@ where('comment_internal_id', $commentId); $this->applyRestriction('monitoring/filter/objects', $query); - $this->comment = $query->getQuery()->fetchRow(); - if ($this->comment === false) { + if (false === $this->comment = $query->fetchRow()) { $this->httpNotFound($this->translate('Comment not found')); } $this->getTabs()->add( 'comment', array( - 'title' => $this->translate( - 'Display detailed information about a comment.' - ), - 'icon' => 'comment', + 'icon' => 'comment', 'label' => $this->translate('Comment'), + 'title' => $this->translate('Display detailed information about a comment.'), 'url' =>'monitoring/comments/show' ) )->activate('comment')->extend(new DashboardAction()); @@ -64,37 +63,19 @@ class Monitoring_CommentController extends Controller */ public function showAction() { - $listCommentsLink = Url::fromPath('monitoring/list/comments') - ->setQueryString('comment_type=(comment|ack)'); - $this->view->comment = $this->comment; + if ($this->hasPermission('monitoring/command/comment/delete')) { - $this->view->delCommentForm = $this->createDelCommentForm(); - $this->view->delCommentForm->populate( - array( - 'redirect' => $listCommentsLink, - 'comment_id' => $this->comment->id, - 'comment_is_service' => isset($this->comment->service_description) - ) - ); + $listUrl = Url::fromPath('monitoring/list/comments')->setQueryString('comment_type=(comment|ack)'); + $form = new DeleteCommentCommandForm(); + $form + ->populate(array( + 'comment_id' => $this->comment->id, + 'comment_is_service' => isset($this->comment->service_description), + 'redirect' => $listUrl + )) + ->handleRequest(); + $this->view->delCommentForm = $form; } } - - /** - * Create a command form to delete a single comment - * - * @return DeleteCommentsCommandForm - */ - private function createDelCommentForm() - { - $this->assertPermission('monitoring/command/comment/delete'); - - $delCommentForm = new DeleteCommentCommandForm(); - $delCommentForm->setAction( - Url::fromPath('monitoring/comment/show') - ->setParam('comment_id', $this->comment->id) - ); - $delCommentForm->handleRequest(); - return $delCommentForm; - } } diff --git a/modules/monitoring/application/controllers/CommentsController.php b/modules/monitoring/application/controllers/CommentsController.php index a86b30310..c47f69b0b 100644 --- a/modules/monitoring/application/controllers/CommentsController.php +++ b/modules/monitoring/application/controllers/CommentsController.php @@ -1,34 +1,41 @@ filter = Filter::fromQueryString(str_replace( 'comment_id', 'comment_internal_id', - (string)$this->params + (string) $this->params )); $query = $this->backend->select()->from('comment', array( 'id' => 'comment_internal_id', @@ -46,19 +53,16 @@ class Monitoring_CommentsController extends Controller ))->addFilter($this->filter); $this->applyRestriction('monitoring/filter/objects', $query); - $this->comments = $query->getQuery()->fetchAll(); - if (false === $this->comments) { - throw new Zend_Controller_Action_Exception($this->translate('Comment not found')); - } + $this->comments = $query; $this->getTabs()->add( 'comments', array( + 'icon' => 'comment', + 'label' => $this->translate('Comments') . sprintf(' (%d)', $query->count()), 'title' => $this->translate( 'Display detailed information about multiple comments.' ), - 'icon' => 'comment', - 'label' => $this->translate('Comments') . sprintf(' (%d)', count($this->comments)), 'url' =>'monitoring/comments/show' ) )->activate('comments'); @@ -71,9 +75,9 @@ class Monitoring_CommentsController extends Controller { $this->view->comments = $this->comments; $this->view->listAllLink = Url::fromPath('monitoring/list/comments') - ->setQueryString($this->filter->toQueryString()); + ->setQueryString($this->filter->toQueryString()); $this->view->removeAllLink = Url::fromPath('monitoring/comments/delete-all') - ->setParams($this->params); + ->setParams($this->params); } /** @@ -89,14 +93,14 @@ class Monitoring_CommentsController extends Controller $delCommentForm->setTitle($this->view->translate('Remove all Comments')); $delCommentForm->addDescription(sprintf( $this->translate('Confirm removal of %d comments.'), - count($this->comments) + $this->comments->count() )); - $delCommentForm->setComments($this->comments) + $delCommentForm->setComments($this->comments->fetchAll()) ->setRedirectUrl($listCommentsLink) ->handleRequest(); $this->view->delCommentForm = $delCommentForm; $this->view->comments = $this->comments; $this->view->listAllLink = Url::fromPath('monitoring/list/comments') - ->setQueryString($this->filter->toQueryString()); + ->setQueryString($this->filter->toQueryString()); } } diff --git a/modules/monitoring/application/controllers/ConfigController.php b/modules/monitoring/application/controllers/ConfigController.php index 2622b9c54..55094bbba 100644 --- a/modules/monitoring/application/controllers/ConfigController.php +++ b/modules/monitoring/application/controllers/ConfigController.php @@ -1,19 +1,23 @@ where('downtime_internal_id', $downtimeId); $this->applyRestriction('monitoring/filter/objects', $query); - $this->downtime = $query->getQuery()->fetchRow(); - if ($this->downtime === false) { + if (false === $this->downtime = $query->fetchRow()) { $this->httpNotFound($this->translate('Downtime not found')); } - if (isset($this->downtime->service_description)) { - $this->isService = true; - } else { - $this->isService = false; - } + $this->getTabs()->add( + 'downtime', + array( - $this->getTabs() - ->add( - 'downtime', - array( - 'title' => $this->translate( - 'Display detailed information about a downtime.' - ), - 'icon' => 'plug', - 'label' => $this->translate('Downtime'), - 'url' =>'monitoring/downtimes/show' - ) - )->activate('downtime')->extend(new DashboardAction()); + 'icon' => 'plug', + 'label' => $this->translate('Downtime'), + 'title' => $this->translate('Display detailed information about a downtime.'), + 'url' =>'monitoring/downtimes/show' + ) + )->activate('downtime')->extend(new DashboardAction()); } /** @@ -88,52 +73,27 @@ class Monitoring_DowntimeController extends Controller */ public function showAction() { + $isService = isset($this->downtime->service_description); $this->view->downtime = $this->downtime; - $this->view->isService = $this->isService; - $this->view->stateName = isset($this->downtime->service_description) ? - Service::getStateText($this->downtime->service_state) : - Host::getStateText($this->downtime->host_state); + $this->view->isService = $isService; $this->view->listAllLink = Url::fromPath('monitoring/list/downtimes'); - $this->view->showHostLink = Url::fromPath('monitoring/host/show') - ->setParam('host', $this->downtime->host_name); + $this->view->showHostLink = Url::fromPath('monitoring/host/show')->setParam('host', $this->downtime->host_name); $this->view->showServiceLink = Url::fromPath('monitoring/service/show') ->setParam('host', $this->downtime->host_name) ->setParam('service', $this->downtime->service_description); + $this->view->stateName = $isService ? Service::getStateText($this->downtime->service_state) + : Host::getStateText($this->downtime->host_state); + if ($this->hasPermission('monitoring/command/downtime/delete')) { - $this->view->delDowntimeForm = $this->createDelDowntimeForm(); - $this->view->delDowntimeForm->populate( - array( - 'redirect' => Url::fromPath('monitoring/list/downtimes'), - 'downtime_id' => $this->downtime->id, - 'downtime_is_service' => $this->isService - ) - ); + $form = new DeleteDowntimeCommandForm(); + $form + ->populate(array( + 'downtime_id' => $this->downtime->id, + 'downtime_is_service' => $isService, + 'redirect' => Url::fromPath('monitoring/list/downtimes'), + )) + ->handleRequest(); + $this->view->delDowntimeForm = $form; } } - - /** - * Receive DeleteDowntimeCommandForm post from other controller - */ - public function removeAction() - { - $this->assertHttpMethod('POST'); - $this->createDelDowntimeForm(); - } - - /** - * Create a command form to delete a single comment - * - * @return DeleteDowntimeCommandForm - */ - private function createDelDowntimeForm() - { - $this->assertPermission('monitoring/command/downtime/delete'); - $delDowntimeForm = new DeleteDowntimeCommandForm(); - $delDowntimeForm->setAction( - Url::fromPath('monitoring/downtime/show') - ->setParam('downtime_id', $this->downtime->id) - ); - $delDowntimeForm->handleRequest(); - return $delDowntimeForm; - } } diff --git a/modules/monitoring/application/controllers/DowntimesController.php b/modules/monitoring/application/controllers/DowntimesController.php index 35950acfe..51c9b79ed 100644 --- a/modules/monitoring/application/controllers/DowntimesController.php +++ b/modules/monitoring/application/controllers/DowntimesController.php @@ -1,27 +1,27 @@ filter = Filter::fromQueryString(str_replace( 'downtime_id', 'downtime_internal_id', - (string)$this->params + (string) $this->params )); $query = $this->backend->select()->from('downtime', array( 'id' => 'downtime_internal_id', @@ -62,38 +60,17 @@ class Monitoring_DowntimesController extends Controller ))->addFilter($this->filter); $this->applyRestriction('monitoring/filter/objects', $query); - $this->downtimes = $query->getQuery()->fetchAll(); - if (false === $this->downtimes) { - throw new Zend_Controller_Action_Exception( - $this->translate('Downtime not found') - ); - } + $this->downtimes = $query; $this->getTabs()->add( 'downtimes', array( - 'title' => $this->translate( - 'Display detailed information about multiple downtimes.' - ), 'icon' => 'plug', - 'label' => $this->translate('Downtimes') . sprintf(' (%d)', count($this->downtimes)), + 'label' => $this->translate('Downtimes') . sprintf(' (%d)', $query->count()), + 'title' => $this->translate('Display detailed information about multiple downtimes.'), 'url' =>'monitoring/downtimes/show' ) )->activate('downtimes'); - - foreach ($this->downtimes as $downtime) { - if (isset($downtime->service_description)) { - $downtime->isService = true; - } else { - $downtime->isService = false; - } - - if ($downtime->isService) { - $downtime->stateText = Service::getStateText($downtime->service_state); - } else { - $downtime->stateText = Host::getStateText($downtime->host_state); - } - } } /** @@ -103,9 +80,8 @@ class Monitoring_DowntimesController extends Controller { $this->view->downtimes = $this->downtimes; $this->view->listAllLink = Url::fromPath('monitoring/list/downtimes') - ->setQueryString($this->filter->toQueryString()); - $this->view->removeAllLink = Url::fromPath('monitoring/downtimes/delete-all') - ->setParams($this->params); + ->setQueryString($this->filter->toQueryString()); + $this->view->removeAllLink = Url::fromPath('monitoring/downtimes/delete-all')->setParams($this->params); } /** @@ -121,10 +97,10 @@ class Monitoring_DowntimesController extends Controller $delDowntimeForm->setTitle($this->view->translate('Remove all Downtimes')); $delDowntimeForm->addDescription(sprintf( $this->translate('Confirm removal of %d downtimes.'), - count($this->downtimes) + $this->downtimes->count() )); $delDowntimeForm->setRedirectUrl(Url::fromPath('monitoring/list/downtimes')); - $delDowntimeForm->setDowntimes($this->downtimes)->handleRequest(); + $delDowntimeForm->setDowntimes($this->downtimes->fetchAll())->handleRequest(); $this->view->delDowntimeForm = $delDowntimeForm; } } diff --git a/modules/monitoring/application/controllers/HostController.php b/modules/monitoring/application/controllers/HostController.php index 1016092cf..4a3f77a6a 100644 --- a/modules/monitoring/application/controllers/HostController.php +++ b/modules/monitoring/application/controllers/HostController.php @@ -1,6 +1,8 @@ backend, $this->params->getRequired('host')); - $this->applyRestriction('monitoring/filter/objects', $host); - if ($host->fetch() === false) { $this->httpNotFound($this->translate('Host not found')); } diff --git a/modules/monitoring/application/controllers/HostsController.php b/modules/monitoring/application/controllers/HostsController.php index 9d5da9e50..036b78c32 100644 --- a/modules/monitoring/application/controllers/HostsController.php +++ b/modules/monitoring/application/controllers/HostsController.php @@ -1,23 +1,25 @@ handleCommandForm($form); } - /** - * Delete a comment - */ - public function deleteCommentAction() - { - $this->assertPermission('monitoring/command/comment/delete'); - - $form = new DeleteCommentCommandForm(); - $form->setTitle($this->translate('Delete Host Comments')); - $this->handleCommandForm($form); - } - /** * Acknowledge host problems */ diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index 7fba86647..c6d51e7d7 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -1,19 +1,22 @@ view->form = $form; } } - - /** - * @todo should be dropped later - */ - public function performanceAction() - { - $this->getTabs()->activate('performance'); - $this->setAutorefreshInterval(10); - $this->view->runtimevariables = (object) $this->backend->select() - ->from('runtimevariables', array('varname', 'varvalue')) - ->getQuery()->fetchPairs(); - - $this->view->checkperformance = $this->backend->select() - ->from('runtimesummary') - ->getQuery()->fetchAll(); - } } diff --git a/modules/monitoring/application/controllers/ServiceController.php b/modules/monitoring/application/controllers/ServiceController.php index cf7c4807c..2c8f1f3f0 100644 --- a/modules/monitoring/application/controllers/ServiceController.php +++ b/modules/monitoring/application/controllers/ServiceController.php @@ -1,6 +1,8 @@ handleCommandForm($form); } - - /** - * Delete a comment - */ - public function deleteCommentAction() - { - $this->assertPermission('monitoring/command/comment/delete'); - - $form = new DeleteCommentCommandForm(); - $form->setTitle($this->translate('Delete Service Comments')); - $this->handleCommandForm($form); - } - - /** * Acknowledge service problems */ diff --git a/modules/monitoring/application/controllers/ShowController.php b/modules/monitoring/application/controllers/ShowController.php index cfed8bd0d..184bb7ee8 100644 --- a/modules/monitoring/application/controllers/ShowController.php +++ b/modules/monitoring/application/controllers/ShowController.php @@ -1,60 +1,27 @@ redirectNow(Url::fromRequest()->setPath('monitoring/service/show')); - } - - /** - * @deprecated - */ - public function hostAction() - { - $this->redirectNow(Url::fromRequest()->setPath('monitoring/host/show')); - } - - /** - * @deprecated - */ - public function historyAction() - { - if ($this->params->has('service')) { - $this->redirectNow(Url::fromRequest()->setPath('monitoring/service/history')); - } - - $this->redirectNow(Url::fromRequest()->setPath('monitoring/host/history')); - } - public function contactAction() { - $contactName = $this->getParam('contact_name'); - - if (! $contactName) { - throw new Zend_Controller_Action_Exception( - $this->translate('The parameter `contact_name\' is required'), - 404 - ); - } + $contactName = $this->params->getRequired('contact_name'); $query = $this->backend->select()->from('contact', array( 'contact_name', diff --git a/modules/monitoring/application/controllers/TacticalController.php b/modules/monitoring/application/controllers/TacticalController.php index fce4664f0..40641128b 100644 --- a/modules/monitoring/application/controllers/TacticalController.php +++ b/modules/monitoring/application/controllers/TacticalController.php @@ -1,11 +1,13 @@ - compact): ?> - = $this->tabs; ?> - - -
- = $this->render('partials/comment/comment-description.phtml'); ?> - | -- = $this->render('partials/comment/comment-detail.phtml'); ?> - | ++ = $this->partial('partials/comment/comment-description.phtml', array('comment' => $comment)) ?> + | ++ = $this->partial('partials/comment/comment-detail.phtml', array('comment' => $comment)) ?> + |
- 5): ?> = $this->qlink( - sprintf($this->translate('show all %d comments'), $i), + sprintf($this->translate('List all %d comments'), $comments->count()), $listAllLink, null, array( - 'icon' => $i > 5 ? 'down-open' : '', - 'data-base-target' => "_next" + 'data-base-target' => '_next', + 'icon' => 'down-open' ) ) ?> -
+ diff --git a/modules/monitoring/application/views/scripts/partials/downtime/downtimes-header.phtml b/modules/monitoring/application/views/scripts/partials/downtime/downtimes-header.phtml index 16e0daee7..e80ec72e3 100644 --- a/modules/monitoring/application/views/scripts/partials/downtime/downtimes-header.phtml +++ b/modules/monitoring/application/views/scripts/partials/downtime/downtimes-header.phtml @@ -1,95 +1,111 @@ -
- start <= time() && ! $downtime->is_in_effect): ?>
- = $this->translate('Ends'); ?>
- - = $this->timeUntil($downtime->is_flexible ? $downtime->scheduled_end : $downtime->end, $this->compact) ?> - - = $downtime->is_in_effect ? $this->translate('Expires') : $this->translate('Starts'); ?> - - = $this->timeUntil($downtime->is_in_effect ? $downtime->end : $downtime->start, $this->compact) ?> - - |
- - isService): ?> - = $this->icon('service', $this->translate('Service')) ?> - = $this->link()->service( - $downtime->service_description, - $downtime->service_display_name, - $downtime->host_name, - $downtime->host_display_name - ); ?> - - = $this->icon('host', $this->translate('Host')) ?> - = $this->link()->host($downtime->host_name, $downtime->host_display_name); ?> - + } + if ($downtime->objecttype === 'service') { + $isService = true; + $stateText = Service::getStateText($downtime->service_state); + } else { + $isService = false; + $stateText = Host::getStateText($downtime->host_state); + } + ?> + |
+ start <= time() && ! $downtime->is_in_effect): ?>
+ = $this->translate('Ends') ?>
+ + = $this->timeUntil( + $downtime->is_flexible ? $downtime->scheduled_end : $downtime->end, $this->compact + ) ?> + + + = $downtime->is_in_effect ? $this->translate('Expires') : $this->translate('Starts') ?> + + + = $this->timeUntil($downtime->is_in_effect ? $downtime->end : $downtime->start, $this->compact) ?> + + |
+
+
+ = $this->icon('service', $this->translate('Service')) ?>
+ = $this->link()->service(
+ $downtime->service_description,
+ $downtime->service_display_name,
+ $downtime->host_name,
+ $downtime->host_display_name
+ ) ?>
+
+ = $this->icon('host', $this->translate('Host')) ?>
+ = $this->link()->host($downtime->host_name, $downtime->host_display_name) ?>
+
- is_flexible): ?> - is_in_effect): ?> - = sprintf( - $downtime->isService - ? $this->translate('This flexible service downtime was started on %s at %s and lasts for %s until %s at %s.') - : $this->translate('This flexible host downtime was started on %s at %s and lasts for %s until %s at %s.'), - $this->formatDate($downtime->start), - $this->formatTime($downtime->start), - $this->formatDuration($downtime->duration), - $this->formatDate($downtime->end), - $this->formatTime($downtime->end) - ); ?> - - = sprintf( - $downtime->isService - ? $this->translate('This flexible service downtime has been scheduled to start between %s - %s and to last for %s.') - : $this->translate('This flexible host downtime has been scheduled to start between %s - %s and to last for %s.'), - $this->formatDateTime($downtime->scheduled_start), - $this->formatDateTime($downtime->scheduled_end), - $this->formatDuration($downtime->duration) - ); ?> - - - is_in_effect): ?> - = sprintf( - $downtime->isService - ? $this->translate('This fixed service downtime was started on %s at %s and expires on %s at %s.') - : $this->translate('This fixed host downtime was started on %s at %s and expires on %s at %s.'), - $this->formatDate($downtime->start), - $this->formatTime($downtime->start), - $this->formatDate($downtime->end), - $this->formatTime($downtime->end) - ); ?> - - = sprintf( - $downtime->isService - ? $this->translate('This fixed service downtime has been scheduled to start on %s at %s and to end on %s at %s.') - : $this->translate('This fixed host downtime has been scheduled to start on %s at %s and to end on %s at %s.'), - $this->formatDate($downtime->scheduled_start), - $this->formatTime($downtime->scheduled_start), - $this->formatDate($downtime->scheduled_end), - $this->formatTime($downtime->scheduled_end) - ); ?> - - + is_flexible): ?> + is_in_effect): ?> + = sprintf( + $isService + ? $this->translate('This flexible service downtime was started on %s at %s and lasts for %s until %s at %s.') + : $this->translate('This flexible host downtime was started on %s at %s and lasts for %s until %s at %s.'), + $this->formatDate($downtime->start), + $this->formatTime($downtime->start), + $this->formatDuration($downtime->duration), + $this->formatDate($downtime->end), + $this->formatTime($downtime->end) + ) ?> + + = sprintf( + $isService + ? $this->translate('This flexible service downtime has been scheduled to start between %s - %s and to last for %s.') + : $this->translate('This flexible host downtime has been scheduled to start between %s - %s and to last for %s.'), + $this->formatDateTime($downtime->scheduled_start), + $this->formatDateTime($downtime->scheduled_end), + $this->formatDuration($downtime->duration) + ) ?> + + + is_in_effect): ?> + = sprintf( + $isService + ? $this->translate('This fixed service downtime was started on %s at %s and expires on %s at %s.') + : $this->translate('This fixed host downtime was started on %s at %s and expires on %s at %s.'), + $this->formatDate($downtime->start), + $this->formatTime($downtime->start), + $this->formatDate($downtime->end), + $this->formatTime($downtime->end) + ) ?> + + = sprintf( + $isService + ? $this->translate('This fixed service downtime has been scheduled to start on %s at %s and to end on %s at %s.') + : $this->translate('This fixed host downtime has been scheduled to start on %s at %s and to end on %s at %s.'), + $this->formatDate($downtime->scheduled_start), + $this->formatTime($downtime->scheduled_start), + $this->formatDate($downtime->scheduled_end), + $this->formatTime($downtime->scheduled_end) + ) ?> + + |
= $this->qlink( - sprintf($this->translate('List all %d downtimes'), $i), + sprintf($this->translate('List all %d downtimes'), $downtimes->count()), $listAllLink, null, array( - 'icon' => 'down-open', - 'data-base-target' => "_next" + 'data-base-target' => '_next', + 'icon' => 'down-open' ) ) ?>
diff --git a/modules/monitoring/application/views/scripts/process/performance.phtml b/modules/monitoring/application/views/scripts/process/performance.phtml deleted file mode 100644 index 0bff8891f..000000000 --- a/modules/monitoring/application/views/scripts/process/performance.phtml +++ /dev/null @@ -1,110 +0,0 @@ -compact): ?> -- | # overall / scheduled | -
- Hosts - | -- = $rv->total_hosts; ?> - / = $rv->total_scheduled_hosts; ?> - | -
- Services - | -- = $rv->total_services; ?> - / = $rv->total_scheduled_services; ?> - | -
- Average services per host - | -- = sprintf('%.2f', $rv->average_services_per_host); ?> - / = sprintf('%.2f', $rv->average_scheduled_services_per_host); ?> - | -
- | # | -Latency | -Execution time | -
- Host Checks - | -= $cp->host_active_count; ?> | -= sprintf('%.3f', $cp->host_active_latency_avg); ?>s | -= sprintf('%.3f', $cp->host_active_execution_avg); ?>s | -
- Service Checks - | -= $cp->service_active_count; ?> | -= sprintf('%.3f', $cp->service_active_latency_avg); ?>s | -= sprintf('%.3f', $cp->service_active_execution_avg); ?>s | -
- | # | -
- Host Checks - | -= $cp->host_passive_count; ?> | -
- Service Checks - | -= $cp->service_passive_count; ?> | -