Merge branch 'master' of git.icinga.org:icingaweb2

fixes #7006
This commit is contained in:
Matthias Jentsch 2014-08-27 17:22:09 +02:00
commit 947cd0c5d3
107 changed files with 732 additions and 808 deletions

View File

@ -5,7 +5,7 @@
namespace Icinga\Clicommands;
use Icinga\Cli\Command;
use Exception;
use Icinga\Exception\IcingaException;
class WebCommand extends Command
{
@ -13,11 +13,11 @@ class WebCommand extends Command
{
$minVersion = '5.4.0';
if (version_compare(PHP_VERSION, $minVersion) < 0) {
throw new Exception(sprintf(
throw new IcingaException(
'You are running PHP %s, internal webserver requires %s.',
PHP_VERSION,
$minVersion
));
);
}
$fork = $this->params->get('daemonize');
@ -27,12 +27,12 @@ class WebCommand extends Command
// TODO: Sanity check!!
if ($socket === null) {
$socket = '0.0.0.0:80';
// throw new Exception('Socket is required');
// throw new IcingaException('Socket is required');
}
if ($basedir === null) {
$basedir = dirname(ICINGAWEB_APPDIR) . '/public';
if (! file_exists($basedir) || ! is_dir($basedir)) {
throw new Exception('Basedir is required');
throw new IcingaException('Basedir is required');
}
}
$basedir = realpath($basedir);
@ -68,7 +68,7 @@ class WebCommand extends Command
{
$pid = pcntl_fork();
if ($pid == -1) {
throw new Exception('Could not fork');
throw new IcingaException('Could not fork');
} else if ($pid) {
echo $this->screen->colorize('[OK]')
. " Icinga Web server forked successfully\n";

View File

@ -2,7 +2,7 @@
// {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}}
use \Zend_Config;
use Zend_Config;
use Icinga\Web\Url;
use Icinga\Logger\Logger;
use Icinga\Config\PreservingIniWriter;
@ -12,6 +12,7 @@ use Icinga\Form\Dashboard\AddUrlForm;
use Icinga\Exception\NotReadableError;
use Icinga\Exception\ConfigurationError;
use Icinga\Web\Controller\ActionController;
use Icinga\Exception\IcingaException;
/**
* Handle creation, removal and displaying of dashboards, panes and components
@ -42,7 +43,7 @@ class DashboardController extends ActionController
}
$dashboard->readConfig($dashboardConfig);
} catch (NotReadableError $e) {
Logger::error(new Exception('Cannot load dashboard configuration. An exception was thrown:', 0, $e));
Logger::error(new IcingaException('Cannot load dashboard configuration. An exception was thrown:', $e));
return null;
}
return $dashboard;

View File

@ -31,11 +31,11 @@ class LayoutController extends ActionController
{
$topbarHtmlParts = array();
/** @var Hook\Layout\TopBar $hook */
/** @var Hook\TopBarHook $hook */
$hook = null;
foreach (Hook::all('TopBar') as $hook) {
$topbarHtmlParts[] = $hook->getHtml($this->getRequest(), $this->view);
$topbarHtmlParts[] = $hook->getHtml($this->getRequest());
}
$this->view->topbarHtmlParts = $topbarHtmlParts;

View File

@ -2,7 +2,7 @@
// {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}}
use \Zend_Controller_Action_Exception as ActionException;
use Zend_Controller_Action_Exception as ActionException;
use Icinga\Web\Controller\ActionController;
use Icinga\Application\Icinga;
use Icinga\Logger\Logger;

View File

@ -4,8 +4,8 @@
namespace Icinga\Form\Config\Authentication;
use \Zend_Config;
use \Zend_Form_Element_Checkbox;
use Zend_Config;
use Zend_Form_Element_Checkbox;
use Icinga\Web\Form;
use Icinga\Data\ResourceFactory;
use Icinga\Web\Form\Decorator\HelpText;

View File

@ -4,8 +4,8 @@
namespace Icinga\Form\Config\Authentication;
use \Exception;
use \Zend_Config;
use Exception;
use Zend_Config;
use Icinga\Data\ResourceFactory;
use Icinga\Authentication\DbConnection;
use Icinga\Authentication\Backend\DbUserBackend;

View File

@ -4,8 +4,8 @@
namespace Icinga\Form\Config\Authentication;
use \Exception;
use \Zend_Config;
use Exception;
use Zend_Config;
use Icinga\Web\Form;
use Icinga\Data\ResourceFactory;
use Icinga\Authentication\Backend\LdapUserBackend;
@ -157,7 +157,7 @@ class LdapBackendForm extends BaseBackendForm
$testConn->assertAuthenticationPossible();
/*
if ($testConn->count() === 0) {
throw new Exception('No Users Found On Directory Server');
throw new IcingaException('No Users Found On Directory Server');
}
*/
} catch (Exception $exc) {

View File

@ -4,7 +4,7 @@
namespace Icinga\Form\Config\Authentication;
use \Zend_Config;
use Zend_Config;
use Icinga\Web\Form;
/**

View File

@ -4,7 +4,7 @@
namespace Icinga\Form\Config;
use \Zend_Config;
use Zend_Config;
use Icinga\Web\Form;
use Icinga\Application\Icinga;
use Icinga\Web\Form\Validator\WritablePathValidator;

View File

@ -4,15 +4,15 @@
namespace Icinga\Form\Preference;
use \DateTimeZone;
use \Zend_Config;
use \Zend_Form_Element_Text;
use \Zend_Form_Element_Select;
use \Zend_View_Helper_DateFormat;
use \Icinga\Web\Form;
use \Icinga\Web\Form\Validator\TimeFormatValidator;
use \Icinga\Web\Form\Validator\DateFormatValidator;
use \Icinga\Util\Translator;
use DateTimeZone;
use Zend_Config;
use Zend_Form_Element_Text;
use Zend_Form_Element_Select;
use Zend_View_Helper_DateFormat;
use Icinga\Web\Form;
use Icinga\Web\Form\Validator\TimeFormatValidator;
use Icinga\Web\Form\Validator\DateFormatValidator;
use Icinga\Util\Translator;
/**
* General user preferences

View File

@ -2,7 +2,7 @@
// {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}}
use \Zend_View_Helper_FormElement;
use Zend_View_Helper_FormElement;
/**
* Helper to generate a "datetime" element

View File

@ -2,7 +2,7 @@
// {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}}
use \Zend_View_Helper_FormElement;
use Zend_View_Helper_FormElement;
/**
* Helper to generate a "datetime" element

View File

@ -83,7 +83,7 @@ BuildArch: noarch
AutoReqProv: Off
%endif
Source0: icingaweb2-%{version}.tar.gz
Source: icingaweb2-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root

View File

@ -14,6 +14,7 @@ use Icinga\Exception\NotReadableError;
use Icinga\Logger\Logger;
use Icinga\Util\DateTimeFactory;
use Icinga\Util\Translator;
use Icinga\Exception\IcingaException;
/**
* This class bootstraps a thin Icinga application layer
@ -332,7 +333,7 @@ abstract class ApplicationBootstrap
try {
$this->moduleManager->loadEnabledModules();
} catch (NotReadableError $e) {
Logger::error(new Exception('Cannot load enabled modules. An exception was thrown:', 0, $e));
Logger::error(new IcingaException('Cannot load enabled modules. An exception was thrown:', $e));
}
return $this;
}
@ -369,7 +370,7 @@ abstract class ApplicationBootstrap
try {
$this->config = Config::app();
} catch (NotReadableError $e) {
Logger::error(new Exception('Cannot load application configuration. An exception was thrown:', 0, $e));
Logger::error(new IcingaException('Cannot load application configuration. An exception was thrown:', $e));
$this->config = new Zend_Config(array());
}
return $this;
@ -417,7 +418,7 @@ abstract class ApplicationBootstrap
ResourceFactory::setConfig($config);
} catch (NotReadableError $e) {
Logger::error(
new Exception('Cannot load resource configuration. An exception was thrown:', 0, $e)
new IcingaException('Cannot load resource configuration. An exception was thrown:', $e)
);
}

View File

@ -19,6 +19,7 @@ use Icinga\Web\Widget;
use Icinga\Web\Widget\Dashboard\Pane;
use Icinga\Util\File;
use Icinga\Exception\ProgrammingError;
use Icinga\Exception\IcingaException;
/**
* Module handling
@ -176,6 +177,7 @@ class Module
/**
* Add a pane to dashboard
*
* @param $id
* @param $name
* @return Pane
*/
@ -199,19 +201,21 @@ class Module
/**
* Add a menu Section to the Sidebar menu
*
* @param $name
* @param string $id
* @param string $name
* @param array $properties
* @return mixed
*/
protected function menuSection($name, array $properties = array())
protected function menuSection($id, $name, array $properties = array())
{
if (array_key_exists($name, $this->menuItems)) {
$this->menuItems[$name]->setProperties($properties);
if (array_key_exists($id, $this->menuItems)) {
$this->menuItems[$id]->setProperties($properties);
} else {
$this->menuItems[$name] = new Menu($name, new Zend_Config($properties));
$this->menuItems[$id] = new Menu($id, new Zend_Config($properties));
$this->menuItems[$id]->setTitle($name);
}
return $this->menuItems[$name];
return $this->menuItems[$id];
}
/**
@ -627,8 +631,9 @@ class Module
protected function providePermission($name, $description)
{
if ($this->providesPermission($name)) {
throw new Exception(
sprintf('Cannot provide permission "%s" twice', $name)
throw new IcingaException(
'Cannot provide permission "%s" twice',
$name
);
}
$this->permissionList[$name] = (object) array(
@ -648,8 +653,9 @@ class Module
protected function provideRestriction($name, $description)
{
if ($this->providesRestriction($name)) {
throw new Exception(
sprintf('Cannot provide restriction "%s" twice', $name)
throw new IcingaException(
'Cannot provide restriction "%s" twice',
$name
);
}
$this->restrictionList[$name] = (object) array(

View File

@ -2,7 +2,7 @@
// {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}}
use \Icinga\Util\Translator;
use Icinga\Util\Translator;
if (extension_loaded('gettext')) {
function t($messageId)

View File

@ -11,6 +11,7 @@ use Icinga\Exception\AuthenticationException;
use Exception;
use Zend_Db_Expr;
use Zend_Db_Select;
use Icinga\Exception\IcingaException;
class DbUserBackend extends UserBackend
{
@ -60,7 +61,10 @@ class DbUserBackend extends UserBackend
return false;
}
if ($salt === '') {
throw new Exception('Cannot find salt for user ' . $user->getUsername());
throw new IcingaException(
'Cannot find salt for user %s',
$user->getUsername()
);
}
$select = new Zend_Db_Select($this->conn->getConnection());

View File

@ -13,6 +13,7 @@ use Icinga\Exception\NotReadableError;
use Icinga\Application\Config as IcingaConfig;
use Icinga\User\Preferences;
use Icinga\User\Preferences\PreferencesStore;
use Icinga\Exception\IcingaException;
class Manager
{
@ -55,7 +56,11 @@ class Manager
$config = IcingaConfig::app();
} catch (NotReadableError $e) {
Logger::error(
new Exception('Cannot load preferences for user "' . $username . '". An exception was thrown', 0, $e)
new IcingaException(
'Cannot load preferences for user "%s". An exception was thrown',
$username,
$e
)
);
$config = new Zend_Config(array());
}
@ -68,8 +73,10 @@ class Manager
$preferences = new Preferences($preferencesStore->load());
} catch (NotReadableError $e) {
Logger::error(
new Exception(
'Cannot load preferences for user "' . $username . '". An exception was thrown', 0, $e
new IcingaException(
'Cannot load preferences for user "%s". An exception was thrown',
$username,
$e
)
);
$preferences = new Preferences();

View File

@ -9,6 +9,7 @@ use Icinga\Chart\Legend;
use Icinga\Chart\Palette;
use Icinga\Chart\Primitive\Drawable;
use Icinga\Chart\SVGRenderer;
use Icinga\Exception\IcingaException;
/**
* Base class for charts, extended by all other Chart classes.
@ -89,15 +90,15 @@ abstract class Chart implements Drawable
*
* Render this graph and return the created SVG
*
* @return string The SVG created by the SvgRenderer
* @return string The SVG created by the SvgRenderer
*
* @throws Exception Thrown wen the dataset is not valid for this graph
* @throws IcingaException Thrown wen the dataset is not valid for this graph
* @see SVGRenderer::render
*/
public function render()
{
if (!$this->isValidDataFormat()) {
throw new Exception('Dataset for graph doesn\'t have the proper structure');
throw new IcingaException('Dataset for graph doesn\'t have the proper structure');
}
$this->build();
if ($this->align) {

View File

@ -7,6 +7,7 @@ namespace Icinga\Chart\Inline;
use Icinga\Chart\PieChart as PieChartRenderer;
use Imagick;
use Exception;
use Icinga\Exception\IcingaException;
/**
* Draw an inline pie-chart directly from the available request parameters.
@ -33,7 +34,7 @@ class PieChart extends Inline
{
if (! class_exists('Imagick')) {
// TODO: This is quick & dirty. 404?
throw new Exception('Cannot render PNGs without Imagick');
throw new IcingaException('Cannot render PNGs without Imagick');
}
$image = new Imagick();
$image->readImageBlob($this->render(false));

View File

@ -4,8 +4,8 @@
namespace Icinga\Chart\Primitive;
use \DomElement;
use \Icinga\Chart\Render\RenderContext;
use DomElement;
use Icinga\Chart\Render\RenderContext;
use Icinga\Chart\Format;
/**

View File

@ -5,6 +5,7 @@
namespace Icinga\Cli;
use Icinga\Cli\Screen;
use Icinga\Exception\IcingaException;
// @see http://en.wikipedia.org/wiki/ANSI_escape_code
@ -74,7 +75,10 @@ class AnsiScreen extends Screen
protected function fgColor($color)
{
if (! array_key_exists($color, $this->fgColors)) {
throw new \Exception(sprintf('There is no such foreground color: %s', $color));
throw new IcingaException(
'There is no such foreground color: %s',
$color
);
}
return $this->fgColors[$color];
}
@ -82,7 +86,10 @@ class AnsiScreen extends Screen
protected function bgColor($color)
{
if (! array_key_exists($color, $this->bgColors)) {
throw new \Exception(sprintf('There is no such background color: %s', $color));
throw new IcingaException(
'There is no such background color: %s',
$color
);
}
return $this->bgColors[$color];
}

View File

@ -10,6 +10,7 @@ use Icinga\Cli\Params;
use Icinga\Application\Config;
use Icinga\Application\ApplicationBootstrap as App;
use Exception;
use Icinga\Exception\IcingaException;
abstract class Command
{
@ -123,7 +124,7 @@ abstract class Command
public function fail($msg)
{
throw new Exception($msg);
throw new IcingaException('%s', $msg);
}
public function getDefaultActionName()

View File

@ -11,6 +11,7 @@ use Icinga\Data\Filter\FilterExpression;
use Icinga\Data\Filter\FilterOr;
use Icinga\Data\Filter\FilterAnd;
use Icinga\Data\Filter\FilterNot;
use Icinga\Exception\IcingaException;
use Zend_Db_Select;
/**
@ -124,7 +125,10 @@ class DbQuery extends SimpleQuery
$op = ' AND ';
$str .= ' NOT ';
} else {
throw new \Exception('Cannot render filter: ' . $filter);
throw new IcingaException(
'Cannot render filter: %s',
$filter
);
}
$parts = array();
if (! $filter->isEmpty()) {
@ -177,7 +181,7 @@ class DbQuery extends SimpleQuery
if (! $value) {
/*
NOTE: It's too late to throw exceptions, we might finish in __toString
throw new \Exception(sprintf(
throw new IcingaException(sprintf(
'"%s" is not a valid time expression',
$value
));

View File

@ -4,11 +4,11 @@
namespace Icinga\Data\Filter;
use Exception;
use Icinga\Exception\IcingaException;
/**
* Filter Exception Class
*
* Filter Exceptions should be thrown on filter parse errors or similar
*/
class FilterException extends Exception {}
class FilterException extends IcingaException {}

View File

@ -4,8 +4,8 @@
namespace Icinga\Data\Filter;
use Exception;
use Icinga\Exception\IcingaException;
class FilterParseException extends Exception
class FilterParseException extends IcingaException
{
}

View File

@ -15,7 +15,7 @@ class FilterQueryString
protected $reportDebug = false;
protected $length;
protected function __construct()
{
}
@ -111,13 +111,13 @@ class FilterQueryString
$extra .= "\n" . implode("\n", $this->debug);
}
throw new FilterParseException(sprintf(
throw new FilterParseException(
'Invalid filter "%s", unexpected %s at pos %d%s',
$this->string,
$char,
$this->pos,
$extra
));
);
}
protected function readFilters($nestingLevel = 0, $op = null)

View File

@ -9,6 +9,7 @@ use Icinga\Data\Filter\Filter;
use Icinga\Web\Paginator\Adapter\QueryAdapter;
use Zend_Paginator;
use Exception;
use Icinga\Exception\IcingaException;
class SimpleQuery implements QueryInterface, Queryable
{
@ -158,7 +159,7 @@ class SimpleQuery implements QueryInterface, Queryable
public function setOrderColumns(array $orderColumns)
{
throw new Exception('This function does nothing and will be removed');
throw new IcingaException('This function does nothing and will be removed');
}
/**

View File

@ -5,6 +5,7 @@
namespace Icinga\Logger\Writer;
use Exception;
use Icinga\Exception\IcingaException;
use Zend_Config;
use Icinga\Util\File;
use Icinga\Logger\Logger;
@ -68,7 +69,7 @@ class FileWriter extends LogWriter
*
* @return string The string representation of the severity
*
* @throws Exception In case the given severity is unknown
* @throws IcingaException In case the given severity is unknown
*/
protected function getSeverityString($severity)
{
@ -82,7 +83,10 @@ class FileWriter extends LogWriter
case Logger::$DEBUG:
return '- DEBUG -';
default:
throw new Exception('Unknown severity "' . $severity . '"');
throw new IcingaException(
'Unknown severity "%s"',
$severity
);
}
}

View File

@ -9,6 +9,7 @@ use Zend_Config;
use Icinga\Logger\Logger;
use Icinga\Logger\LogWriter;
use Icinga\Exception\ConfigurationError;
use Icinga\Exception\IcingaException;
/**
* Class to write messages to syslog
@ -72,7 +73,10 @@ class SyslogWriter extends LogWriter
);
if (!array_key_exists($severity, $priorities)) {
throw new Exception('Severity "' . $severity . '" cannot be mapped to a valid syslog priority');
throw new IcingaException(
'Severity "%s" cannot be mapped to a valid syslog priority',
$severity
);
}
$this->open();

View File

@ -4,7 +4,7 @@
namespace Icinga\Protocol\Commandpipe\Transport;
use \Zend_Config;
use Zend_Config;
/**
* Interface for Transport classes handling the concrete access to the command pipe

View File

@ -8,7 +8,7 @@ use Icinga\Protocol\Ldap\Exception as LdapException;
use Icinga\Application\Platform;
use Icinga\Application\Config;
use Icinga\Logger\Logger;
use \Zend_Config;
use Zend_Config;
/**
* Backend class managing all the LDAP stuff for you.

View File

@ -4,6 +4,8 @@
namespace Icinga\Protocol\Ldap;
use Icinga\Exception\IcingaException;
/**
* Search class
*
@ -82,12 +84,10 @@ class Query
public function limit($count = null, $offset = null)
{
if (! preg_match('~^\d+~', $count . $offset)) {
throw new Exception(
sprintf(
'Got invalid limit: %s, %s',
$count,
$offset
)
throw new IcingaException(
'Got invalid limit: %s, %s',
$count,
$offset
);
}
$this->limit_count = (int) $count;
@ -316,7 +316,7 @@ class Query
{
$parts = array();
if (! isset($this->filters['objectClass']) || $this->filters['objectClass'] === null) {
// throw new Exception('Object class is mandatory');
// throw new IcingaException('Object class is mandatory');
}
foreach ($this->filters as $key => $value) {
$parts[] = sprintf(

View File

@ -4,6 +4,8 @@
namespace Icinga\Protocol\Ldap;
use Icinga\Exception\IcingaException;
/**
* This class is a special node object, representing your connections root node
*
@ -95,16 +97,14 @@ class Root
/**
* @param $rdn
* @return mixed
* @throws Exception
* @throws IcingaException
*/
public function getChildByRDN($rdn)
{
if (!$this->hasChildRDN($rdn)) {
throw new Exception(
sprintf(
'The child RDN "%s" is not available',
$rdn
)
throw new IcingaException(
'The child RDN "%s" is not available',
$rdn
);
}
return $this->children[strtolower($rdn)];
@ -154,28 +154,24 @@ class Root
/**
* @param $dn
* @return $this
* @throws Exception
* @throws IcingaException
*/
protected function assertSubDN($dn)
{
$mydn = $this->getDN();
$end = substr($dn, -1 * strlen($mydn));
if (strtolower($end) !== strtolower($mydn)) {
throw new Exception(
sprintf(
'"%s" is not a child of "%s"',
$dn,
$mydn
)
throw new IcingaException(
'"%s" is not a child of "%s"',
$dn,
$mydn
);
}
if (strlen($dn) === strlen($mydn)) {
throw new Exception(
sprintf(
'"%s" is not a child of "%s", they are equal',
$dn,
$mydn
)
throw new IcingaException(
'"%s" is not a child of "%s", they are equal',
$dn,
$mydn
);
}
return $this;

View File

@ -6,6 +6,7 @@ namespace Icinga\Protocol\Livestatus;
use Icinga\Application\Benchmark;
use Exception;
use Icinga\Exception\IcingaException;
/**
* Backend class managing handling MKI Livestatus connections
@ -73,22 +74,18 @@ class Connection
$this->assertPhpExtensionLoaded('sockets');
if ($socket[0] === '/') {
if (! is_writable($socket)) {
throw new \Exception(
sprintf(
'Cannot write to livestatus socket "%s"',
$socket
)
throw new IcingaException(
'Cannot write to livestatus socket "%s"',
$socket
);
}
$this->socket_type = self::TYPE_UNIX;
$this->socket_path = $socket;
} else {
if (! preg_match('~^tcp://([^:]+):(\d+)~', $socket, $m)) {
throw new \Exception(
sprintf(
'Invalid TCP socket syntax: "%s"',
$socket
)
throw new IcingaException(
'Invalid TCP socket syntax: "%s"',
$socket
);
}
// TODO: Better syntax checks
@ -156,17 +153,15 @@ class Connection
$length = (int) trim(substr($header, 4));
$body = $this->readFromSocket($length);
if ($status !== 200) {
throw new Exception(
sprintf(
'Problem while reading %d bytes from livestatus: %s',
$length,
$body
)
throw new IcingaException(
'Problem while reading %d bytes from livestatus: %s',
$length,
$body
);
}
$result = json_decode($body);
if ($result === null) {
throw new Exception('Got invalid response body from livestatus');
throw new IcingaException('Got invalid response body from livestatus');
}
return $result;
@ -180,11 +175,9 @@ class Connection
while ($offset < $length) {
$data = socket_read($this->connection, $length - $offset);
if ($data === false) {
throw new Exception(
sprintf(
'Failed to read from livestatus socket: %s',
socket_strerror(socket_last_error($this->connection))
)
throw new IcingaException(
'Failed to read from livestatus socket: %s',
socket_strerror(socket_last_error($this->connection))
);
}
$size = strlen($data);
@ -196,12 +189,10 @@ class Connection
}
}
if ($offset !== $length) {
throw new \Exception(
sprintf(
'Got only %d instead of %d bytes from livestatus socket',
$offset,
$length
)
throw new IcingaException(
'Got only %d instead of %d bytes from livestatus socket',
$offset,
$length
);
}
@ -212,7 +203,7 @@ class Connection
{
$res = socket_write($this->connection, $data);
if ($res === false) {
throw new \Exception('Writing to livestatus socket failed');
throw new IcingaException('Writing to livestatus socket failed');
}
return true;
}
@ -220,11 +211,9 @@ class Connection
protected function assertPhpExtensionLoaded($name)
{
if (! extension_loaded($name)) {
throw new \Exception(
sprintf(
'The extension "%s" is not loaded',
$name
)
throw new IcingaException(
'The extension "%s" is not loaded',
$name
);
}
}
@ -250,13 +239,11 @@ class Connection
$this->connection = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
if (! @socket_connect($this->connection, $this->socket_host, $this->socket_port)) {
throw new \Exception(
sprintf(
'Cannot connect to livestatus TCP socket "%s:%d": %s',
$this->socket_host,
$this->socket_port,
socket_strerror(socket_last_error($this->connection))
)
throw new IcingaException(
'Cannot connect to livestatus TCP socket "%s:%d": %s',
$this->socket_host,
$this->socket_port,
socket_strerror(socket_last_error($this->connection))
);
}
socket_set_option($this->connection, SOL_TCP, TCP_NODELAY, 1);
@ -266,11 +253,9 @@ class Connection
{
$this->connection = socket_create(AF_UNIX, SOCK_STREAM, 0);
if (! socket_connect($this->connection, $this->socket_path)) {
throw new \Exception(
sprintf(
'Cannot connect to livestatus local socket "%s"',
$this->socket_path
)
throw new IcingaException(
'Cannot connect to livestatus local socket "%s"',
$this->socket_path
);
}
}

View File

@ -5,6 +5,7 @@
namespace Icinga\Protocol\Livestatus;
use Icinga\Protocol\AbstractQuery;
use Icinga\Exception\IcingaException;
class Query extends AbstractQuery
{
@ -86,12 +87,10 @@ class Query extends AbstractQuery
public function limit($count = null, $offset = null)
{
if (! preg_match('~^\d+~', $count . $offset)) {
throw new Exception(
sprintf(
'Got invalid limit: %s, %s',
$count,
$offset
)
throw new IcingaException(
'Got invalid limit: %s, %s',
$count,
$offset
);
}
$this->limit_count = (int) $count;
@ -122,11 +121,9 @@ class Query extends AbstractQuery
public function from($table, $columns = null)
{
if (! $this->connection->hasTable($table)) {
throw new Exception(
sprintf(
'This livestatus connection does not provide "%s"',
$table
)
throw new IcingaException(
'This livestatus connection does not provide "%s"',
$table
);
}
$this->table = $table;
@ -169,7 +166,7 @@ class Query extends AbstractQuery
public function __toString()
{
if ($this->table === null) {
throw new Exception('Table is required');
throw new IcingaException('Table is required');
}
$default_headers = array(
'OutputFormat: json',

View File

@ -4,6 +4,8 @@
namespace Icinga\Protocol\Nrpe;
use Icinga\Exception\IcingaException;
class Connection
{
protected $host;
@ -47,11 +49,10 @@ class Connection
// TODO: Check result checksum!
$result = fread($conn, 8192);
if ($result === false) {
throw new \Exception('CHECK_NRPE: Error receiving data from daemon.');
throw new IcingaException('CHECK_NRPE: Error receiving data from daemon.');
} elseif (strlen($result) === 0) {
throw new \Exception(
'CHECK_NRPE: Received 0 bytes from daemon.'
. ' Check the remote server logs for error messages'
throw new IcingaException(
'CHECK_NRPE: Received 0 bytes from daemon. Check the remote server logs for error messages'
);
}
// TODO: CHECK_NRPE: Receive underflow - only %d bytes received (%d expected)
@ -80,7 +81,10 @@ class Connection
$ctx
);
if (! $this->connection) {
throw new \Exception(sprintf('NRPE Connection failed: ' . $errstr));
throw new IcingaException(
'NRPE Connection failed: %s',
$errstr
);
}
}

View File

@ -9,6 +9,7 @@ use Icinga\Exception\ProgrammingError;
use Icinga\Data\SimpleQuery;
use Icinga\Protocol\Statusdat\View\MonitoringObjectList;
use Icinga\Protocol\Statusdat\Query\IQueryPart;
use Icinga\Exception\IcingaException;
/**
* Base implementation for Statusdat queries.
@ -163,7 +164,7 @@ class Query extends SimpleQuery
* @param array $columns An array of attributes to use (required for fetchPairs())
*
* @return $this Fluent interface
* @throws \Exception If the target is unknonw
* @throws IcingaException If the target is unknonw
*/
public function from($table, array $attributes = null)
{
@ -173,7 +174,10 @@ class Query extends SimpleQuery
if (isset(self::$VALID_TARGETS[$table])) {
$this->source = $table;
} else {
throw new \Exception('Unknown from target for status.dat :' . $table);
throw new IcingaException(
'Unknown from target for status.dat :%s',
$table
);
}
return $this;
}
@ -397,16 +401,15 @@ class Query extends SimpleQuery
/**
* Fetch the result as an associative array using the first column as the key and the second as the value
*
* @return array An associative array with the result
* @throws \Exception If no attributes are defined
* @return array An associative array with the result
* @throws IcingaException If no attributes are defined
*/
public function fetchPairs()
{
$result = array();
if (count($this->getColumns()) < 2) {
throw new Exception(
'Status.dat "fetchPairs()" query expects at least' .
' columns to be set in the query expression'
throw new IcingaException(
'Status.dat "fetchPairs()" query expects at least columns to be set in the query expression'
);
}
$attributes = $this->getColumns();

View File

@ -4,6 +4,8 @@
namespace Icinga\Protocol\Statusdat\Query;
use Icinga\Exception\IcingaException;
class Expression implements IQueryPart
{
/**
@ -70,7 +72,7 @@ class Expression implements IQueryPart
/**
* @param $token
* @throws \Exception
* @throws IcingaException
*/
private function getOperatorType($token)
{
@ -106,7 +108,11 @@ class Expression implements IQueryPart
$this->CB = "isNotIn";
break;
default:
throw new \Exception("Unknown operator $token in expression $this->expression !");
throw new IcingaException(
'Unknown operator %s in expression %s !',
$token,
$this->expression
);
}
}

View File

@ -4,6 +4,8 @@
namespace Icinga\Protocol\Statusdat\Query;
use Icinga\Exception\IcingaException;
/**
* Class Group
* @package Icinga\Protocol\Statusdat\Query
@ -130,7 +132,7 @@ class Group implements IQueryPart
}
/**
* @throws \Exception
* @throws IcingaException
*/
private function tokenize()
{
@ -154,7 +156,10 @@ class Group implements IQueryPart
}
if ($token === self::GROUP_END) {
if ($subgroupCount < 1) {
throw new \Exception("Invalid Query: unexpected ')' at pos " . $this->parsePos);
throw new IcingaException(
'Invalid Query: unexpected \')\' at pos %s',
$this->parsePos
);
}
$subgroupCount--;
/*
@ -192,7 +197,7 @@ class Group implements IQueryPart
$this->subExpressionLength = $this->parsePos - $this->subExpressionStart;
}
if ($subgroupCount > 0) {
throw new \Exception("Unexpected end of query, are you missing a parenthesis?");
throw new IcingaException('Unexpected end of query, are you missing a parenthesis?');
}
$this->startNewSubExpression();

View File

@ -4,10 +4,11 @@
namespace Icinga\Protocol\Statusdat\View;
use \Iterator;
use \Countable;
use \ArrayAccess;
use \Exception;
use Iterator;
use Countable;
use ArrayAccess;
use Exception;
use Icinga\Exception\IcingaException;
/**
* Wrapper around an array of monitoring objects that can be enhanced with an optional
@ -115,7 +116,7 @@ class MonitoringObjectList implements Iterator, Countable, ArrayAccess
public function __set($name, $value)
{
throw new Exception("Setting is currently not available for objects");
throw new IcingaException('Setting is currently not available for objects');
}
public function offsetExists($offset)

View File

@ -4,7 +4,7 @@
namespace Icinga\User\Preferences;
use \Zend_Config;
use Zend_Config;
use Icinga\User;
use Icinga\User\Preferences;
use Icinga\Data\ResourceFactory;

View File

@ -5,6 +5,7 @@
namespace Icinga\Util;
use Exception;
use Icinga\Exception\IcingaException;
/**
* Helper class to ease internationalization when using gettext
@ -53,12 +54,16 @@ class Translator
* @param string $name The name of the domain to register
* @param string $directory The directory where message catalogs can be found
*
* @throws Exception In case the domain was not successfully registered
* @throws IcingaException In case the domain was not successfully registered
*/
public static function registerDomain($name, $directory)
{
if (bindtextdomain($name, $directory) === false) {
throw new Exception("Cannot register domain '$name' with path '$directory'");
throw new IcingaException(
'Cannot register domain \'%s\' with path \'%s\'',
$name,
$directory
);
}
bind_textdomain_codeset($name, 'UTF-8');
self::$knownDomains[$name] = $directory;
@ -69,14 +74,17 @@ class Translator
*
* @param string $localeName The name of the locale to use
*
* @throws Exception In case the locale's name is invalid
* @throws IcingaException In case the locale's name is invalid
*/
public static function setupLocale($localeName)
{
if (setlocale(LC_ALL, $localeName . '.UTF-8') === false && setlocale(LC_ALL, $localeName) === false) {
setlocale(LC_ALL, 'C'); // C == "use whatever is hardcoded"
if ($localeName !== self::DEFAULT_LOCALE) {
throw new Exception("Cannot set locale '$localeName' for category 'LC_ALL'");
throw new IcingaException(
'Cannot set locale \'%s\' for category \'LC_ALL\'',
$localeName
);
}
} else {
$locale = setlocale(LC_ALL, 0);

View File

@ -8,6 +8,7 @@ use Exception;
use Icinga\Authentication\Manager as AuthManager;
use Icinga\Application\Benchmark;
use Icinga\Application\Config;
use Icinga\Exception\IcingaException;
use Icinga\Util\Translator;
use Icinga\Web\Widget\Tabs;
use Icinga\Web\Window;
@ -177,7 +178,10 @@ class ActionController extends Zend_Controller_Action
{
if (! $this->Auth()->hasPermission($name)) {
// TODO: Shall this be an Auth Exception? Or a 404?
throw new Exception(sprintf('Auth error, no permission for "%s"', $name));
throw new IcingaException(
'Auth error, no permission for "%s"',
$name
);
}
}
@ -381,7 +385,7 @@ class ActionController extends Zend_Controller_Action
if ($this->view->title) {
if (preg_match('~[\r\n]~', $this->view->title)) {
// TODO: Innocent exception and error log for hack attempts
throw new Exception('No way, guy');
throw new IcingaException('No way, guy');
}
$resp->setHeader(
'X-Icinga-Title',

View File

@ -4,7 +4,7 @@
namespace Icinga\Web\Form\Decorator;
use \Zend_Form_Decorator_Abstract;
use Zend_Form_Decorator_Abstract;
/**
* Decorator to hide elements using a &gt;noscript&lt; tag instead of

View File

@ -5,9 +5,9 @@
namespace Icinga\Web\Form\Element;
use Icinga\Web\Form\Validator\DateTimeValidator;
use \Zend_Form_Element_Text;
use \Zend_Form_Element;
use \Icinga\Util\DateTimeFactory;
use Zend_Form_Element_Text;
use Zend_Form_Element;
use Icinga\Util\DateTimeFactory;
/**
* Datetime form element which returns the input as Unix timestamp after the input has been proven valid. Utilizes

View File

@ -4,8 +4,8 @@
namespace Icinga\Web\Form\Element;
use \Icinga\Web\Form\Validator\TriStateValidator;
use \Zend_Form_Element_Xhtml;
use Icinga\Web\Form\Validator\TriStateValidator;
use Zend_Form_Element_Xhtml;
/**
* A checkbox that can display three different states:

View File

@ -4,7 +4,7 @@
namespace Icinga\Web\Form\Validator;
use \Zend_Validate_Abstract;
use Zend_Validate_Abstract;
/**
* Validator that checks if a textfield contains a correct date format

View File

@ -4,9 +4,9 @@
namespace Icinga\Web\Form\Validator;
use \Icinga\Util\DateTimeFactory;
use \Zend_Validate_Abstract;
use \Icinga\Exception\ProgrammingError;
use Icinga\Util\DateTimeFactory;
use Zend_Validate_Abstract;
use Icinga\Exception\ProgrammingError;
/**
* Validator that checks if a textfield contains a correct date format

View File

@ -4,7 +4,7 @@
namespace Icinga\Web\Form\Validator;
use \Zend_Validate_Abstract;
use Zend_Validate_Abstract;
/**
* Validator that checks if a textfield contains a correct time format

View File

@ -4,7 +4,7 @@
namespace Icinga\Web\Form\Validator;
use \Zend_Validate_Abstract;
use Zend_Validate_Abstract;
class TriStateValidator extends Zend_Validate_Abstract
{

View File

@ -4,8 +4,8 @@
namespace Icinga\Web\Form\Validator;
use \Zend_Validate_Abstract;
use \Icinga\Application\Config as IcingaConfig;
use Zend_Validate_Abstract;
use Icinga\Application\Config as IcingaConfig;
/**
* Validator that interprets the value as a path and checks if it's writable

View File

@ -41,6 +41,15 @@ class Hook
*/
public static $BASE_NS = 'Icinga\\Web\\Hook\\';
/**
* Append this string to base class
*
* All base classes renamed to *Hook
*
* @var string
*/
public static $classSuffix = 'Hook';
/**
* Reset object state
*/
@ -114,7 +123,7 @@ class Hook
*/
private static function assertValidHook($instance, $name)
{
$base_class = self::$BASE_NS . ucfirst($name);
$base_class = self::$BASE_NS . ucfirst($name) . self::$classSuffix;
if (!$instance instanceof $base_class) {
throw new ProgrammingError(
'%s is not an instance of %s',

View File

@ -1,145 +0,0 @@
<?php
// {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}}
namespace Icinga\Web\Hook\Configuration;
use Icinga\Exception\ProgrammingError;
/**
* Class ConfigurationTab
*
* Hook to represent configuration tabs
*
* @package Icinga\Web\Hook\Configuration
*/
class ConfigurationTab implements ConfigurationTabInterface
{
/**
* Module name
* @var string
*/
private $moduleName;
/**
* Url segment to invoke controller
* @var string
*/
private $url;
/**
* Title of the tab
* @var string
*/
private $title;
/**
* Create a new instance
*
* @param string|null $name
* @param string|null $url
* @param string|null $title
*/
public function __construct($name = null, $url = null, $title = null)
{
if ($name !== null) {
$this->setModuleName($name);
if ($title === null) {
$this->setTitle($name);
}
}
if ($url !== null) {
$this->setUrl($url);
}
if ($title !== null) {
$this->setTitle($title);
}
}
/**
* Setter for title
* @param string $title
*/
public function setTitle($title)
{
$this->title = $title;
}
/**
* Getter for title
* @return string
*/
public function getTitle()
{
return $this->title;
}
/**
* Setter for url
* @param string $url
*/
public function setUrl($url)
{
$this->url = $url;
}
/**
* Getter for url
* @return string
*/
public function getUrl()
{
return $this->url;
}
/**
* Setter for module name
* @param string $moduleName
*/
public function setModuleName($moduleName)
{
$this->moduleName = $moduleName;
}
private function assertConfiguration()
{
if (!$this->moduleName) {
throw new ProgrammingError('moduleName is missing');
}
if (!$this->getUrl()) {
throw new ProgrammingError('url is missing');
}
if (!$this->getTitle()) {
throw new ProgrammingError('title is missing');
}
}
/**
* Returns a tab configuration to build configuration links
* @return array
*/
public function getTab()
{
$this->assertConfiguration();
return array(
'title' => $this->getTitle(),
'url' => $this->getUrl()
);
}
/**
* Return the tab key
* @return string
*/
public function getModuleName()
{
$this->assertConfiguration();
return $this->moduleName;
}
}

View File

@ -1,107 +0,0 @@
<?php
// {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}}
namespace Icinga\Web\Hook\Configuration;
use Icinga\Exception\ProgrammingError;
use Icinga\Web\Hook;
use Icinga\Web\Widget\Tabs;
/**
* Class ConfigurationTabBuilder
*
* Glue config tabs together
*
* @package Icinga\Web\Hook\Configuration
*/
class ConfigurationTabBuilder
{
/**
* Namespace for configuration tabs
*/
const HOOK_NAMESPACE = 'Configuration/Tabs';
/**
* Tabs widget
* @var Tabs
*/
private $tabs;
/**
* Create a new instance
* @param Tabs $tabs
*/
public function __construct(Tabs $tabs)
{
$this->setTabs($tabs);
$this->initializeSystemConfigurationTabs();
}
/**
* Setter for tabs
* @param \Icinga\Web\Widget\Tabs $tabs
*/
public function setTabs($tabs)
{
$this->tabs = $tabs;
}
/**
* Getter for tabs
* @return \Icinga\Web\Widget\Tabs
*/
public function getTabs()
{
return $this->tabs;
}
/**
* Build the tabs
*
*/
public function build()
{
/** @var ConfigurationTab $configTab */
$configTab = null;
foreach (Hook::all(self::HOOK_NAMESPACE) as $configTab) {
if (!$configTab instanceof ConfigurationTabInterface) {
throw new ProgrammingError('tab not instance of ConfigTabInterface');
}
$this->getTabs()->add($configTab->getModuleName(), $configTab->getTab());
}
}
/**
* Initialize system configuration tabs
*/
public function initializeSystemConfigurationTabs()
{
$configurationTab = new ConfigurationTab(
'configuration',
'configuration/index',
'Configuration'
);
// Display something about us
Hook::registerObject(
ConfigurationTabBuilder::HOOK_NAMESPACE,
$configurationTab->getModuleName(),
$configurationTab
);
$modulesOverviewTab = new ConfigurationTab(
'modules',
'modules/overview',
'Modules'
);
Hook::registerObject(
ConfigurationTabBuilder::HOOK_NAMESPACE,
$modulesOverviewTab->getModuleName(),
$modulesOverviewTab
);
}
}

View File

@ -1,27 +0,0 @@
<?php
// {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}}
namespace Icinga\Web\Hook\Configuration;
/**
* Interface ConfigurationTabInterface
*
* Used to register configuration tab settings
*
* @package Icinga\Web\Hook\Configuration
*/
interface ConfigurationTabInterface
{
/**
* Returns a tab configuration to build configuration links
* @return array
*/
public function getTab();
/**
* Return the tab key
* @return string
*/
public function getModuleName();
}

View File

@ -4,6 +4,8 @@
namespace Icinga\Web\Hook;
use Icinga\Exception\ProgrammingError;
/**
* Icinga Web Grapher Hook base class
*
@ -14,7 +16,7 @@ namespace Icinga\Web\Hook;
* @author Icinga-Web Team <info@icinga.org>
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License
*/
class Grapher
abstract class GrapherHook
{
/**
* Whether this grapher provides preview images
@ -56,9 +58,13 @@ class Grapher
/**
* Whether a graph for the given host[, service [, plot]] exists
*
* @param string $host
* @param string $service
* @param string $plot
*
* @return bool
*/
public function hasGraph($host, $service = null, $plot = null)
public function has($host, $service = null, $plot = null)
{
return false;
}
@ -66,13 +72,47 @@ class Grapher
/**
* Get a preview image for the given host[, service [, plot]] exists
*
* WARNING: We are not sure yet whether this will remain as is
* @param string $host
* @param string $service
* @param string $plot
*
* @return string
* @return string
*
* @throws ProgrammingError
*/
public function getPreviewImage($host, $service = null, $plot = null)
public function getPreviewHtml($host, $service = null, $plot = null)
{
throw new Exception('This backend has no preview images');
throw new ProgrammingError('This backend has no preview images');
}
/**
* Whether a tiny graph for the given host[, service [, plot]] exists
*
* @param string $host
* @param string $service
* @param string $plot
*
* @return bool
*/
public function hasTinyPreview($host, $service = null, $plot = null)
{
return false;
}
/**
* Get a tiny preview image for the given host[, service [, plot]] exists
*
* @param string $host
* @param string $service
* @param string $plot
*
* @return string
*
* @throws ProgrammingError
*/
public function getTinyPreviewHtml($host, $service = null, $plot = null)
{
throw new ProgrammingError('This backend has no tiny preview images');
}
/**
@ -80,10 +120,11 @@ class Grapher
*
* WARNING: We are not sure yet whether this will remain as is
*
* @return string
* @param string $host
* @param string $service
* @param string $plot
*
* @return string
*/
public function getGraphUrl($host, $service = null, $plot = null)
{
throw new Exception('This backend has no images');
}
abstract function getGraphUrl($host, $service = null, $plot = null);
}

View File

@ -14,7 +14,7 @@ namespace Icinga\Web\Hook;
* @author Icinga-Web Team <info@icinga.org>
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License
*/
abstract class Ticket
abstract class TicketHook
{
/**
* Constructor must live without arguments right now

View File

@ -4,21 +4,20 @@
namespace Icinga\Web\Hook;
use \Icinga\Web\Request;
use \Zend_View;
use Icinga\Web\Request;
use Zend_View;
/**
* Hook to extend topbar items
*/
interface TopBar
abstract class TopBarHook extends WebBaseHook
{
/**
* Function to generate top bar content
*
* @param Request $request
* @param Zend_View $view
*
* @return string
*/
public function getHtml($request, $view);
abstract public function getHtml($request);
}

View File

@ -0,0 +1,51 @@
<?php
// {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}}
namespace Icinga\Web\Hook;
use Zend_Controller_Action_HelperBroker;
use Zend_View;
/**
* Base class for web hooks
*
* The class provides access to the view
*/
class WebBaseHook
{
/**
* View instance
*
* @var Zend_View
*/
private $view;
/**
* Set the view instance
*
* @param Zend_View $view
*/
public function setView(Zend_View $view)
{
$this->view = $view;
}
/**
* Get the view instance
*
* @return Zend_View
*/
public function getView()
{
if ($this->view === null) {
$viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
if ($viewRenderer->view === null) {
$viewRenderer->initView();
}
$this->view = $viewRenderer->view;
}
return $this->view;
}
}

View File

@ -5,6 +5,7 @@
namespace Icinga\Web;
use Icinga\Exception\ConfigurationError;
use Icinga\Logger\Logger;
use Zend_Config;
use RecursiveIterator;
use Icinga\Application\Config;
@ -172,34 +173,34 @@ class Menu implements RecursiveIterator
*/
protected function addMainMenuItems()
{
$this->add(t('Dashboard'), array(
$this->add('dashboard', t('Dashboard'), array(
'url' => 'dashboard',
'icon' => 'img/icons/dashboard.png',
'priority' => 10
));
$section = $this->add(t('System'), array(
$section = $this->add('system', t('System'), array(
'icon' => 'img/icons/configuration.png',
'priority' => 200
));
$section->add(t('Preferences'), array(
$section->add('preferences', t('Preferences'), array(
'url' => 'preference',
'priority' => 200
));
$section->add(t('Configuration'), array(
$section->add('configuration', t('Configuration'), array(
'url' => 'config',
'priority' => 300
));
$section->add(t('Modules'), array(
$section->add('modules', t('Modules'), array(
'url' => 'config/modules',
'priority' => 400
));
$section->add(t('ApplicationLog'), array(
$section->add('applicationlog', t('ApplicationLog'), array(
'url' => 'list/applicationlog',
'priority' => 500
));
$this->add(t('Logout'), array(
$this->add('logout', t('Logout'), array(
'url' => 'authentication/logout',
'icon' => 'img/icons/logout.png',
'priority' => 300
@ -427,9 +428,10 @@ class Menu implements RecursiveIterator
* @param array $config
* @return Menu
*/
public function add($name, $config = array())
public function add($id, $name, $config = array())
{
return $this->addSubMenu($name, new Zend_Config($config));
$config['title'] = $name;
return $this->addSubMenu($id, new Zend_Config($config));
}
/**

View File

@ -4,9 +4,10 @@
namespace Icinga\Web\Session;
use \Exception;
use \ArrayIterator;
use \IteratorAggregate;
use Exception;
use ArrayIterator;
use Icinga\Exception\IcingaException;
use IteratorAggregate;
/**
* Container for session values
@ -76,7 +77,10 @@ class SessionNamespace implements IteratorAggregate
public function __get($key)
{
if (!array_key_exists($key, $this->values)) {
throw new Exception('Cannot access non-existent session value "' . $key . '"');
throw new IcingaException(
'Cannot access non-existent session value "%s"',
$key
);
}
return $this->get($key);
@ -178,7 +182,7 @@ class SessionNamespace implements IteratorAggregate
public function write()
{
if (!$this->session) {
throw new Exception('Cannot save, session not set');
throw new IcingaException('Cannot save, session not set');
}
$this->session->write();

View File

@ -4,6 +4,7 @@
namespace Icinga\Web\Widget\Dashboard;
use Icinga\Exception\IcingaException;
use Icinga\Util\Dimension;
use Icinga\Web\Form;
use Icinga\Web\Url;
@ -29,6 +30,13 @@ class Component extends AbstractWidget
*/
private $url;
/**
* The id of this Component
*
* @var string
*/
private $id;
/**
* The title being displayed on top of the component
* @var
@ -59,12 +67,14 @@ EOD;
/**
* Create a new component displaying the given url in the provided pane
*
* @param string $id The id to use for this component
* @param string $title The title to use for this component
* @param Url|string $url The url this component uses for displaying information
* @param Pane $pane The pane this Component will be added to
*/
public function __construct($title, $url, Pane $pane)
public function __construct($id, $title, $url, Pane $pane)
{
$this->id = $id;
$this->title = $title;
$this->pane = $pane;
if ($url instanceof Url) {
@ -72,11 +82,9 @@ EOD;
} elseif ($url) {
$this->url = Url::fromPath($url);
} else {
throw new Exception(
sprintf(
'Cannot create dashboard component "%s" without valid URL',
$title
)
throw new IcingaException(
'Cannot create dashboard component "%s" without valid URL',
$title
);
}
}
@ -187,14 +195,14 @@ EOD;
/**
* Create a @see Component instance from the given Zend config, using the provided title
*
* @param $id The id for this component
* @param $title The title for this component
* @param Zend_Config $config The configuration defining url, parameters, height, width, etc.
* @param Pane $pane The pane this component belongs to
*
* @return Component A newly created Component for use in the Dashboard
*/
public static function fromIni($title, Zend_Config $config, Pane $pane)
public static function fromIni($id, $title, Zend_Config $config, Pane $pane)
{
$height = null;
$width = null;
@ -202,7 +210,27 @@ EOD;
$parameters = $config->toArray();
unset($parameters['url']); // otherwise there's an url = parameter in the Url
$cmp = new Component($title, Url::fromPath($url, $parameters), $pane);
$cmp = new Component($id, $title, Url::fromPath($url, $parameters), $pane);
return $cmp;
}
/**
* Set the components id
*
* @param $id string
*/
public function setId($id)
{
$this->id = $id;
}
/**
* Retrieve the components id
*
* @return string
*/
public function getId()
{
return $this->id;
}
}

View File

@ -83,44 +83,44 @@ class Pane extends AbstractWidget
/**
* Return true if a component with the given title exists in this pane
*
* @param string $title The title of the component to check for existence
* @param string $id The id of the component to check for existence
*
* @return bool
*/
public function hasComponent($title)
public function hasComponent($id)
{
return array_key_exists($title, $this->components);
return array_key_exists($id, $this->components);
}
/**
* Return a component with the given name if existing
*
* @param string $title The title of the component to return
* @param string $id The id of the component to return
*
* @return Component The component with the given title
* @throws ProgrammingError If the component doesn't exist
*/
public function getComponent($title)
public function getComponent($id)
{
if ($this->hasComponent($title)) {
return $this->components[$title];
if ($this->hasComponent($id)) {
return $this->components[$id];
}
throw new ProgrammingError(
'Trying to access invalid component: %s',
$title
$id
);
}
/**
* Removes the component with the given title if it exists in this pane
* Removes the component with the given id if it exists in this pane
*
* @param string $title The pane
* @param string $id The pane
* @return Pane $this
*/
public function removeComponent($title)
public function removeComponent($id)
{
if ($this->hasComponent($title)) {
unset($this->components[$title]);
if ($this->hasComponent($id)) {
unset($this->components[$id]);
}
return $this;
}
@ -146,6 +146,7 @@ class Pane extends AbstractWidget
/**
* Add a component to this pane, optionally creating it if $component is a string
*
* @param string $id An unique Identifier
* @param string|Component $component The component object or title
* (if a new component will be created)
* @param string|null $url An Url to be used when component is a string
@ -153,12 +154,12 @@ class Pane extends AbstractWidget
* @return self
* @throws \Icinga\Exception\ConfigurationError
*/
public function addComponent($component, $url = null)
public function addComponent($id, $component, $url = null)
{
if ($component instanceof Component) {
$this->components[$component->getTitle()] = $component;
} elseif (is_string($component) && $url !== null) {
$this->components[$component] = new Component($component, $url, $this);
$this->components[$component->getId()] = $component;
} elseif (is_string($id) && is_string($component) && $url !== null) {
$this->components[$id] = new Component($id, $component, $url, $this);
} else {
throw new ConfigurationError('Invalid component added: %s', $component);
}
@ -175,15 +176,15 @@ class Pane extends AbstractWidget
{
/* @var $component Component */
foreach ($components as $component) {
if (array_key_exists($component->getTitle(), $this->components)) {
if (preg_match('/_(\d+)$/', $component->getTitle(), $m)) {
$name = preg_replace('/_\d+$/', $m[1]++, $component->getTitle());
if (array_key_exists($component->getId(), $this->components)) {
if (preg_match('/-(\d+)$/', $component->getId(), $m)) {
$name = preg_replace('/-\d+$/', $m[1]++, $component->getId());
} else {
$name = $component->getTitle() . '_2';
$name = $component->getId() . '-2';
}
$this->components[$name] = $component;
} else {
$this->components[$component->getTitle()] = $component;
$this->components[$component->getId()] = $component;
}
}
@ -193,17 +194,18 @@ class Pane extends AbstractWidget
/**
* Add a component to the current pane
*
* @param $id
* @param $title
* @param $url
* @return Component
* @param null $url
* @return mixed
*
* @see addComponent()
*/
public function add($title, $url = null)
public function add($id, $title, $url = null)
{
$this->addComponent($title, $url);
$this->addComponent($id, $title, $url);
return $this->components[$title];
return $this->components[$id];
}
/**

View File

@ -2,7 +2,7 @@
// {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}}
use \Zend_Controller_Action_Exception;
use Zend_Controller_Action_Exception;
use Icinga\Application\Icinga;
use Icinga\Module\Doc\DocController;

View File

@ -2,7 +2,7 @@
// {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}}
use \Zend_Controller_Action_Exception;
use Zend_Controller_Action_Exception;
use Icinga\Application\Icinga;
use Icinga\Module\Doc\DocController;
use Icinga\Module\Doc\Exception\DocException;

View File

@ -4,8 +4,7 @@
/* @var $this \Icinga\Application\Modules\Module */
$section = $this->menuSection($this->translate('Documentation'), array(
'title' => 'Documentation',
$section = $this->menuSection('documentation', $this->translate('Documentation'), array(
'icon' => 'img/icons/comment.png',
'url' => 'doc',
'priority' => 80

View File

@ -25,6 +25,7 @@ use Icinga\Module\Monitoring\Form\Command\DelayNotificationForm;
use Icinga\Module\Monitoring\Form\Command\RescheduleNextCheckForm;
use Icinga\Module\Monitoring\Form\Command\ScheduleDowntimeForm;
use Icinga\Module\Monitoring\Form\Command\SubmitPassiveCheckResultForm;
use Icinga\Exception\IcingaException;
/**
* Class Monitoring_CommandController
@ -238,13 +239,16 @@ class Monitoring_CommandController extends Controller
$given = array_intersect_key($supported, $this->getRequest()->getParams());
if (empty($given)) {
throw new \Exception('Missing parameter, supported: '.implode(', ', array_flip($supported)));
throw new IcingaException(
'Missing parameter, supported: %s',
implode(', ', array_flip($supported))
);
}
if (isset($given['host'])) {
$objects = $this->selectCommandTargets(!in_array("service", $supported));
if (empty($objects)) {
throw new \Exception("No objects found for your command");
throw new IcingaException('No objects found for your command');
}
}

View File

@ -2,7 +2,7 @@
// {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}}
use \Exception;
use Exception;
use Icinga\Config\PreservingIniWriter;
use Icinga\Web\Controller\ModuleActionController;

View File

@ -2,7 +2,7 @@
// {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}}
use \Icinga\Module\Monitoring\Command\Meta;
use Icinga\Module\Monitoring\Command\Meta;
/**
* Class MonitoringCommands

View File

@ -25,6 +25,9 @@ class Monitoring_ShowController extends Controller
*/
protected $backend;
/**
* @var Hook\GrapherHook
*/
protected $grapher;
/**
@ -61,8 +64,8 @@ class Monitoring_ShowController extends Controller
. ' on ' . $o->host_name;
$this->getTabs()->activate('service');
$o->populate();
if ($this->grapher && $this->grapher->hasGraph($o->host_name, $o->service_description)) {
$this->view->grapherHtml = $this->grapher->getPreviewImage($o->host_name, $o->service_description);
if ($this->grapher && $this->grapher->hasPreviews($o->host_name, $o->service_description)) {
$this->view->grapherHtml = $this->grapher->getPreviewHtml($o->host_name, $o->service_description);
}
}
@ -76,8 +79,8 @@ class Monitoring_ShowController extends Controller
$this->getTabs()->activate('host');
$this->view->title = $o->host_name;
$o->populate();
if ($this->grapher && $this->grapher->hasGraph($o->host_name)) {
$this->view->grapherHtml = $this->grapher->getPreviewImage($o->host_name);
if ($this->grapher && $this->grapher->hasPreviews($o->host_name)) {
$this->view->grapherHtml = $this->grapher->getPreviewHtml($o->host_name);
}
}
@ -105,19 +108,22 @@ class Monitoring_ShowController extends Controller
public function contactAction()
{
$contact = $this->getParam('contact');
if (! $contact) {
$contactName = $this->getParam('contact');
if (! $contactName) {
throw new Zend_Controller_Action_Exception(
$this->translate('The parameter `contact\' is required'),
404
);
}
$query = $this->backend->select()->from('contact', array(
'contact_name',
'contact_id',
'contact_alias',
'contact_email',
'contact_pager',
'contact_object_id',
'contact_notify_service_timeperiod',
'contact_notify_service_recovery',
'contact_notify_service_warning',
@ -132,9 +138,36 @@ class Monitoring_ShowController extends Controller
'contact_notify_host_flapping',
'contact_notify_host_downtime',
));
$query->where('contact_name', $contact);
$this->view->contacts = $query->paginate();
$this->view->contact_name = $contact;
$query->where('contact_name', $contactName);
$contact = $query->getQuery()->fetchRow();
if ($contact) {
$commands = $this->backend->select()->from('command', array(
'command_line',
'command_name'
))->where('contact_id', $contact->contact_id);
$this->view->commands = $commands->paginate();
$notifications = $this->backend->select()->from('notification', array(
'host',
'service',
'notification_output',
'notification_contact',
'notification_start_time',
'notification_state'
));
$notifications->where('contact_object_id', $contact->contact_object_id);
$this->view->compact = true;
$this->view->notifications = $notifications->paginate();
}
$this->view->contact = $contact;
$this->view->contactName = $contactName;
}
/**

View File

@ -2,9 +2,9 @@
// {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}}
use \DateTime;
use \DateInterval;
use \Zend_Config;
use DateTime;
use DateInterval;
use Zend_Config;
use Icinga\Web\Url;
use Icinga\Util\Format;
use Icinga\Application\Config;

View File

@ -4,10 +4,10 @@
namespace Icinga\Module\Monitoring\Form\Command;
use \Icinga\Web\Form\Element\DateTimePicker;
use \Icinga\Protocol\Commandpipe\Comment;
use \Icinga\Util\DateTimeFactory;
use \Icinga\Module\Monitoring\Command\AcknowledgeCommand;
use Icinga\Web\Form\Element\DateTimePicker;
use Icinga\Protocol\Commandpipe\Comment;
use Icinga\Util\DateTimeFactory;
use Icinga\Module\Monitoring\Command\AcknowledgeCommand;
/**
* Form for problem acknowledgements

View File

@ -4,10 +4,10 @@
namespace Icinga\Module\Monitoring\Form\Command;
use \Icinga\Web\Form\Element\TriStateCheckbox;
use \Icinga\Web\Form;
use \Zend_Form_Element_Hidden;
use \Zend_Form;
use Icinga\Web\Form\Element\TriStateCheckbox;
use Icinga\Web\Form;
use Zend_Form_Element_Hidden;
use Zend_Form;
/**
* A form to edit multiple command flags of multiple commands at once. When some commands have

View File

@ -5,7 +5,7 @@
namespace Icinga\Module\Monitoring\Form\Command;
use Zend_Controller_Request_Abstract;
use \Zend_Form_Element_Hidden;
use Zend_Form_Element_Hidden;
use Icinga\Module\Monitoring\Command\AcknowledgeCommand;
use Icinga\Module\Monitoring\Command\SingleArgumentCommand;

View File

@ -4,7 +4,7 @@
namespace Icinga\Module\Monitoring\Form\Command;
use \Icinga\Exception\ProgrammingError;
use Icinga\Exception\ProgrammingError;
/**
* Form for submitting passive check results

View File

@ -4,7 +4,7 @@
namespace Icinga\Module\Monitoring\Form\Config\Backend;
use \Zend_Config;
use Zend_Config;
/**
* Extended EditBackendForm for creating new Backends

View File

@ -4,8 +4,8 @@
namespace Icinga\Module\Monitoring\Form\Config\Instance;
use \Icinga\Web\Form;
use \Zend_Config;
use Icinga\Web\Form;
use Zend_Config;
/**
* Form for creating new instances

View File

@ -4,8 +4,8 @@
namespace Icinga\Module\Monitoring\Form\Config\Instance;
use \Zend_Config;
use \Icinga\Web\Form;
use Zend_Config;
use Icinga\Web\Form;
/**
* Form for editing existing instances

View File

@ -2,7 +2,7 @@
$contactHelper = $this->getHelper('ContactFlags');
?>
<div style="margin-top: 0.5em;">
<?php foreach ($contacts as $contact): ?>
<?php if ($contact): ?>
<table style="border-spacing: 0.25em; border-collapse: separate;">
<thead>
<tr>
@ -45,12 +45,18 @@ $contactHelper = $this->getHelper('ContactFlags');
</tr>
</tbody>
</table>
<?php
return;
endforeach;
printf(
'%s: `%s\'',
t('No such contact'), $contact_name
);
?>
<h4><?= $this->translate('Commands'); ?>:</h4>
<ul>
<?php foreach ($commands as $command): ?>
<li><?= $command->command_name; ?></li>
<?php endforeach; ?>
</ul>
<h4><?= $this->translate('Notifications'); ?>:</h4>
<?= $this->render('list/notifications.phtml') ?>
<?php else: ?>
<?= $this->translate('No such contact'); ?>: <?= $contactName; ?>
<?php endif; ?>
</div>

View File

@ -2,7 +2,7 @@
// {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}}
use \Icinga\Module\Monitoring\Backend;
use Icinga\Module\Monitoring\Backend;
use Icinga\Util\Format;
$backend = Backend::getInstance($params->shift('backend'));

View File

@ -22,72 +22,73 @@ $this->provideConfigTab('security', array(
/*
* Problems Section
*/
$section = $this->menuSection($this->translate('Problems'), array(
$section = $this->menuSection('problems', $this->translate('Problems'), array(
'icon' => 'img/icons/error.png',
'priority' => 20
));
$section->add($this->translate('Unhandled Hosts'), array(
$section->add('unhandled hosts', $this->translate('Unhandled Hosts'), array(
'url' => 'monitoring/list/hosts?host_problem=1&host_handled=0',
'priority' => 40
));
$section->add($this->translate('Unhandled Services'), array(
$section->add('unhandled services', $this->translate('Unhandled Services'), array(
'url' => 'monitoring/list/services?service_problem=1&service_handled=0&sort=service_severity',
'priority' => 40
));
$section->add($this->translate('Host Problems'), array(
$section->add('host problems', $this->translate('Host Problems'), array(
'url' => 'monitoring/list/hosts?host_problem=1&sort=host_severity',
'priority' => 50
));
$section->add($this->translate('Service Problems'), array(
$section->add('service prolems', $this->translate('Service Problems'), array(
'url' => 'monitoring/list/services?service_problem=1&sort=service_severity&dir=desc',
'priority' => 50
));
$section->add($this->translate('Current Downtimes'))->setUrl('monitoring/list/downtimes?downtime_is_in_effect=1');
$section->add('current downtimes', $this->translate('Current Downtimes'))
->setUrl('monitoring/list/downtimes?downtime_is_in_effect=1');
/*
* Overview Section
*/
$section = $this->menuSection($this->translate('Overview'), array(
$section = $this->menuSection('overview', $this->translate('Overview'), array(
'icon' => 'img/icons/hostgroup.png',
'priority' => 30
));
$section->add($this->translate('Tactical Overview'), array(
$section->add('tactical overview', $this->translate('Tactical Overview'), array(
'url' => 'monitoring/tactical',
'priority' => 40
));
$section->add($this->translate('Hosts'), array(
$section->add('hosts', $this->translate('Hosts'), array(
'url' => 'monitoring/list/hosts',
'priority' => 50
));
$section->add($this->translate('Services'), array(
$section->add('services', $this->translate('Services'), array(
'url' => 'monitoring/list/services',
'priority' => 50
));
$section->add($this->translate('Servicematrix'), array(
$section->add('servicematrix', $this->translate('Servicematrix'), array(
'url' => 'monitoring/list/servicematrix?service_problem=1',
'priority' => 51
));
$section->add($this->translate('Servicegroups'), array(
$section->add('servicegroups', $this->translate('Servicegroups'), array(
'url' => 'monitoring/list/servicegroups',
'priority' => 60
));
$section->add($this->translate('Hostgroups'), array(
$section->add('hostgroups', $this->translate('Hostgroups'), array(
'url' => 'monitoring/list/hostgroups',
'priority' => 60
));
$section->add($this->translate('Contactgroups'), array(
$section->add('contactgroups', $this->translate('Contactgroups'), array(
'url' => 'monitoring/list/contactgroups',
'priority' => 61
));
$section->add($this->translate('Downtimes'), array(
$section->add('downtimes', $this->translate('Downtimes'), array(
'url' => 'monitoring/list/downtimes',
'priority' => 71
));
$section->add($this->translate('Comments'), array(
$section->add('comments', $this->translate('Comments'), array(
'url' => 'monitoring/list/comments?comment_type=(comment|ack)',
'priority' => 70
));
$section->add($this->translate('Contacts'), array(
$section->add('contacts', $this->translate('Contacts'), array(
'url' => 'monitoring/list/contacts',
'priority' => 70
));
@ -95,31 +96,33 @@ $section->add($this->translate('Contacts'), array(
/*
* History Section
*/
$section = $this->menuSection($this->translate('History'), array(
$section = $this->menuSection('history', $this->translate('History'), array(
'title' => $this->translate('History'),
'icon' => 'img/icons/history.png'
));
$section->add($this->translate('Critical Events'), array(
$section->add('critical events', $this->translate('Critical Events'), array(
'title' => $this->translate('Critical Events'),
'url' => 'monitoring/list/statehistorysummary',
'priority' => 50
));
$section->add($this->translate('Notifications'), array(
$section->add('notifications', $this->translate('Notifications'), array(
'url' => 'monitoring/list/notifications'
));
$section->add($this->translate('Events'), array(
$section->add('events', $this->translate('Events'), array(
'title' => $this->translate('All Events'),
'url' => 'monitoring/list/eventhistory?timestamp>=-7%20days'
));
$section->add($this->translate('Timeline'))->setUrl('monitoring/timeline');
$section->add('timeline', $this->translate('Timeline'))->setUrl('monitoring/timeline');
/*
* System Section
*/
$section = $this->menuSection($this->translate('System'));
$section->add($this->translate('Process Info'), array(
$section = $this->menuSection('system', $this->translate('System'));
$section->add('process info', $this->translate('Process Info'), array(
'url' => 'monitoring/process/info',
'priority' => 120
));
$section->add($this->translate('Performance Info'), array(
$section->add('performance info', $this->translate('Performance Info'), array(
'url' => 'monitoring/process/performance',
'priority' => 130
));
@ -127,16 +130,19 @@ $section->add($this->translate('Performance Info'), array(
/*
* Dashboard
*/
$dashboard = $this->dashboard($this->translate('Current Incidents'));
$dashboard = $this->dashboard('current incidents')->setTitle($this->translate('Current Incidents'));
$dashboard->add(
'service problems',
$this->translate('Service Problems'),
'monitoring/list/services?service_problem=1&limit=10&sort=service_severity'
);
$dashboard->add(
'recently recovered services',
$this->translate('Recently Recovered Services'),
'monitoring/list/services?service_state=0&limit=10&sort=service_last_state_change&dir=desc'
);
$dashboard->add(
'host problems',
$this->translate('Host Problems'),
'monitoring/list/hosts?host_problem=1&sort=host_severity'
);

View File

@ -0,0 +1,60 @@
<?php
// {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}}
namespace Icinga\Module\Monitoring\Backend\Ido\Query;
/**
* Query for commands
*/
class CommandQuery extends IdoQuery
{
/**
* @var array
*/
protected $columnMap = array(
'commands' => array(
'command_id' => 'c.command_id',
'command_instance_id' => 'c.instance_id',
'command_config_type' => 'c.config_type',
'command_line' => 'c.command_line',
'command_name' => 'co.name1'
),
'contacts' => array(
'contact_id' => 'con.contact_id',
'contact_alias' => 'con.contact_alias'
)
);
/**
* Fetch basic information about commands
*/
protected function joinBaseTables()
{
$this->select->from(
array('c' => $this->prefix . 'commands'),
array()
)->join(
array('co' => $this->prefix . 'objects'),
'co.object_id = c.object_id',
array()
);
$this->joinedVirtualTables = array('commands' => true);
}
/**
* Join contacts
*/
protected function joinContacts()
{
$this->select->join(
array('cnc' => $this->prefix . 'contact_notificationcommands'),
'cnc.command_object_id = co.object_id'
)->join(
array('con' => $this->prefix . 'contacts'),
'con.contact_id = cnc.contact_id'
);
}
}

View File

@ -13,6 +13,7 @@ class ContactQuery extends IdoQuery
'contact_alias' => 'c.alias COLLATE latin1_general_ci',
'contact_email' => 'c.email_address COLLATE latin1_general_ci',
'contact_pager' => 'c.pager_address',
'contact_object_id' => 'c.contact_object_id',
'contact_has_host_notfications' => 'c.host_notifications_enabled',
'contact_has_service_notfications' => 'c.service_notifications_enabled',
'contact_can_submit_commands' => 'c.can_submit_commands',

View File

@ -4,6 +4,7 @@
namespace Icinga\Module\Monitoring\Backend\Ido\Query;
use Icinga\Exception\IcingaException;
use Icinga\Logger\Logger;
use Icinga\Data\Db\DbQuery;
use Icinga\Exception\ProgrammingError;
@ -272,7 +273,10 @@ abstract class IdoQuery extends DbQuery
$this->requireColumn($condition);
$col = $this->getMappedField($condition);
if ($col === null) {
throw new \Exception("No such field: $condition");
throw new IcingaException(
'No such field: %s',
$condition
);
}
return parent::where($col, $value);
}

View File

@ -25,7 +25,8 @@ class NotificationQuery extends IdoQuery
'service' => 'o.name2'
),
'contact' => array(
'notification_contact' => 'c_o.name1'
'notification_contact' => 'c_o.name1',
'contact_object_id' => 'c_o.object_id'
),
'command' => array(
'notification_command' => 'cmd_o.name1'

View File

@ -4,7 +4,7 @@
namespace Icinga\Module\Monitoring\Backend\Ido\Query;
use \Zend_Db_Select;
use Zend_Db_Select;
class StatusSummaryQuery extends IdoQuery
{

View File

@ -0,0 +1,28 @@
<?php
// {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}}
namespace Icinga\Module\Monitoring\DataView;
/**
* View representation for commands
*/
class Command extends DataView
{
/**
* Retrieve columns provided by this view
*
* @return array
*/
public function getColumns()
{
return array(
'command_id',
'command_instance_id',
'command_config_type',
'command_line',
'command_name'
);
}
}

View File

@ -38,6 +38,7 @@ class Contact extends DataView
'contact_notify_host_unreachable',
'contact_notify_host_flapping',
'contact_notify_host_downtime',
'contact_object_id',
'host_object_id',
'host_name',
'service_object_id',

View File

@ -4,8 +4,9 @@
namespace Icinga\Module\Monitoring\Exception;
use \Exception;
class UnsupportedBackendException extends Exception
use Icinga\Exception\IcingaException;
class UnsupportedBackendException extends IcingaException
{
}
}

View File

@ -4,7 +4,7 @@
namespace Icinga\Module\Monitoring\Timeline;
use \DateTime;
use DateTime;
use Icinga\Web\Url;
use Icinga\Exception\ProgrammingError;

View File

@ -4,10 +4,11 @@
namespace Icinga\Module\Monitoring\Timeline;
use \DateTime;
use \Exception;
use \ArrayIterator;
use \IteratorAggregate;
use DateTime;
use Exception;
use ArrayIterator;
use Icinga\Exception\IcingaException;
use IteratorAggregate;
use Icinga\Data\Filter\Filter;
use Icinga\Web\Hook;
use Icinga\Web\Session;
@ -166,7 +167,10 @@ class TimeLine implements IteratorAggregate
$this->circleDiameter = floatval($matches[1]);
$this->diameterUnit = $matches[2];
} else {
throw new Exception('Width "' . $width . '" is not a valid width');
throw new IcingaException(
'Width "%s" is not a valid width',
$width
);
}
}
@ -184,10 +188,16 @@ class TimeLine implements IteratorAggregate
if ($matches[2] === $this->diameterUnit) {
$this->minCircleDiameter = floatval($matches[1]);
} else {
throw new Exception('Unit needs to be in "' . $this->diameterUnit . '"');
throw new IcingaException(
'Unit needs to be in "%s"',
$this->diameterUnit
);
}
} else {
throw new Exception('Width "' . $width . '" is not a valid width');
throw new IcingaException(
'Width "%s" is not a valid width',
$width
);
}
}

View File

@ -9,7 +9,7 @@ use Icinga\Module\Monitoring\Timeline\TimeRange;
/**
* Base class for TimeLine providers
*/
abstract class TimelineProvider
abstract class TimelineProviderHook
{
/**
* Return the names by which to group entries

View File

@ -4,7 +4,7 @@
namespace Icinga\Module\Monitoring\Web\Hook;
use Icinga\Web\Hook\TopBar as IcingaTopBar;
use Icinga\Web\Hook\TopBarHook;
use Icinga\Module\Monitoring\DataView\StatusSummary as StatusSummaryView;
use Icinga\Web\Request;
use Zend_View;
@ -12,17 +12,16 @@ use Zend_View;
/**
* Render status summary into the topbar of icinga
*/
class TopBar implements IcingaTopBar
class TopBar extends TopBarHook
{
/**
* Function to generate top bar content
*
* @param Request $request
* @param Zend_View $view
*
* @return string
*/
public function getHtml($request, $view)
public function getHtml($request)
{
$hostSummary = StatusSummaryView::fromRequest(
$request,
@ -50,7 +49,7 @@ class TopBar implements IcingaTopBar
)
)->getQuery()->fetchRow();
return $view->partial(
return $this->getView()->partial(
'layout/topbar.phtml',
'monitoring',
array(

View File

@ -4,7 +4,7 @@
namespace Tests\Icinga\Module\Monitoring\Application\Views\Helpers;
use \Zend_View_Helper_MonitoringFlags;
use Zend_View_Helper_MonitoringFlags;
use Icinga\Test\BaseTestCase;
require_once realpath(BaseTestCase::$moduleDir . '/monitoring/application/views/helpers/MonitoringFlags.php');

View File

@ -4,7 +4,7 @@
namespace Test\Modules\Monitoring\Application\Views\Helpers;
use \Zend_View_Helper_MonitoringProperties;
use Zend_View_Helper_MonitoringProperties;
use Icinga\Test\BaseTestCase;
require_once realpath(BaseTestCase::$moduleDir . '/monitoring/application/views/helpers/MonitoringProperties.php');

View File

@ -4,8 +4,8 @@
namespace Tests\Icinga\Modules\Monitoring\Application\Views\Helpers;
use \Mockery;
use \Zend_View_Helper_ResolveMacros;
use Mockery;
use Zend_View_Helper_ResolveMacros;
use Icinga\Test\BaseTestCase;
require_once realpath(BaseTestCase::$moduleDir . '/monitoring/application/views/helpers/ResolveMacros.php');

View File

@ -4,8 +4,9 @@
namespace Icinga\Module\Translation\Cli;
use \Exception;
use Exception;
use Icinga\Cli\Command;
use Icinga\Exception\IcingaException;
/**
* Base class for translation commands
@ -24,7 +25,10 @@ class TranslationCommand extends Command
public function validateLocaleCode($code)
{
if (! preg_match('@[a-z]{2}_[A-Z]{2}@', $code)) {
throw new Exception("Locale code '$code' is not valid. Expected format is: ll_CC");
throw new IcingaException(
'Locale code \'%s\' is not valid. Expected format is: ll_CC',
$code
);
}
return $code;
@ -44,7 +48,10 @@ class TranslationCommand extends Command
$enabledModules = $this->app->getModuleManager()->listEnabledModules();
if (!in_array($name, $enabledModules)) {
throw new Exception("Module with name '$name' not found or is not enabled");
throw new IcingaException(
'Module with name \'%s\' not found or is not enabled',
$name
);
}
return $name;

View File

@ -5,6 +5,7 @@
namespace Icinga\Module\Translation\Util;
use Exception;
use Icinga\Exception\IcingaException;
use Icinga\Util\File;
use Icinga\Application\Modules\Manager;
use Icinga\Application\ApplicationBootstrap;
@ -215,7 +216,10 @@ class GettextTranslationHelper
} else {
if ((!is_dir(dirname($this->tablePath)) && !@mkdir(dirname($this->tablePath), 0755, true)) ||
!rename($this->templatePath, $this->tablePath)) {
throw new Exception('Unable to create ' . $this->tablePath);
throw new IcingaException(
'Unable to create %s',
$this->tablePath
);
}
}
$this->updateHeader($this->tablePath);
@ -364,7 +368,10 @@ class GettextTranslationHelper
{
$directoryHandle = opendir($directory);
if (!$directoryHandle) {
throw new Exception('Unable to read files from ' . $directory);
throw new IcingaException(
'Unable to read files from %s',
$directory
);
}
$subdirs = array();

View File

@ -4,8 +4,8 @@
namespace Tests\Icinga\Form\Config\Authentication;
use \Mockery;
use \Zend_Config;
use Mockery;
use Zend_Config;
use Icinga\Test\BaseTestCase;
use Icinga\Form\Config\Authentication\ReorderForm;

Some files were not shown because too many files have changed in this diff Show More