From a2e1663e342b86bdfb0dde436143b1a76686e6b8 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 20 Oct 2014 13:27:33 +0200 Subject: [PATCH 01/29] index: Don't drop query parameters when redirecting to dashboard --- application/controllers/IndexController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/controllers/IndexController.php b/application/controllers/IndexController.php index 83ec0dd1d..05e66504b 100644 --- a/application/controllers/IndexController.php +++ b/application/controllers/IndexController.php @@ -19,7 +19,7 @@ class IndexController extends ActionController public function preDispatch() { if ($this->getRequest()->getActionName() !== 'welcome') { - $this->redirectNow('dashboard'); + $this->redirectNow(Url::fromRequest()->setPath('dashboard')); } } From 53608c83d0c8a652367a34005c4690375a792644 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 20 Oct 2014 13:27:56 +0200 Subject: [PATCH 02/29] iframe: Load JavaScript even when 'isIframe' is true --- application/layouts/scripts/layout.phtml | 2 -- 1 file changed, 2 deletions(-) diff --git a/application/layouts/scripts/layout.phtml b/application/layouts/scripts/layout.phtml index c4354cee2..d801f060e 100644 --- a/application/layouts/scripts/layout.phtml +++ b/application/layouts/scripts/layout.phtml @@ -52,7 +52,6 @@ $iframeClass = $isIframe ? ' iframe' : '';
render('body.phtml') ?>
- @@ -64,6 +63,5 @@ var icinga = new Icinga({ baseUrl: 'href('/') ?>' }); - From cee261bf7ef286368febb03c78a344924e607266 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 20 Oct 2014 13:36:37 +0200 Subject: [PATCH 03/29] Use lowercase username and user groups for loading user permissions and restrictions --- .../Icinga/Authentication/AdmissionLoader.php | 79 ++++++++++++------- 1 file changed, 52 insertions(+), 27 deletions(-) diff --git a/library/Icinga/Authentication/AdmissionLoader.php b/library/Icinga/Authentication/AdmissionLoader.php index 098afda81..50624003c 100644 --- a/library/Icinga/Authentication/AdmissionLoader.php +++ b/library/Icinga/Authentication/AdmissionLoader.php @@ -6,6 +6,7 @@ namespace Icinga\Authentication; use Icinga\Application\Config; use Icinga\Exception\NotReadableError; +use Icinga\User; use Icinga\Util\String; /** @@ -14,73 +15,97 @@ use Icinga\Util\String; class AdmissionLoader { /** - * Match against groups - * - * @param string $section * @param string $username - * @param array $groups + * @param array $userGroups + * @param mixed $section * * @return bool */ - private function match($section, $username, array $groups) + protected function match($username, $userGroups, $section) { - if ($section->users && in_array($username, String::trimSplit($section->users)) === true) { - return true; + $username = strtolower($username); + if (! empty($section->users)) { + $users = array_map('strtolower', String::trimSplit($section->users)); + if (in_array($username, $users)) { + return true; + } } - - if ($section->groups && count(array_intersect(String::trimSplit($section->groups), $groups)) > 0) { - return true; + if (! empty($section->groups)) { + $groups = array_map('strtolower', String::trimSplit($section->groups)); + foreach ($userGroups as $userGroup) { + if (in_array(strtolower($userGroup), $groups)) { + return true; + } + } } - return false; } /** - * Retrieve permissions + * Get user permissions * - * @param string $username - * @param array $groups + * @param User $user * * @return array */ - public function getPermissions($username, array $groups) + public function getPermissions(User $user) { $permissions = array(); try { $config = Config::app('permissions'); } catch (NotReadableError $e) { + Logger::error( + 'Can\'t get permissions for user \'%s\'. An exception was thrown:', + $user->getUsername(), + $e + ); return $permissions; } + $username = $user->getUsername(); + $userGroups = $user->getGroups(); foreach ($config as $section) { - if ($this->match($section, $username, $groups) && isset($section->permissions)) { - $permissions += String::trimSplit($section->permissions); + if (! empty($section->permissions) + && $this->match($username, $userGroups, $section) + ) { + $permissions = array_merge( + $permissions, + array_diff(String::trimSplit($section->permissions), $permissions) + ); } } return $permissions; } /** - * Retrieve restrictions + * Get user restrictions * - * @param $username - * @param array $groups + * @param User $user * * @return array */ - public function getRestrictions($username, array $groups) + public function getRestrictions(User $user) { $restrictions = array(); try { $config = Config::app('restrictions'); } catch (NotReadableError $e) { + Logger::error( + 'Can\'t get restrictions for user \'%s\'. An exception was thrown:', + $user->getUsername(), + $e + ); return $restrictions; } - foreach ($config as $name => $section) { - if ($this->match($section, $username, $groups)) { - if (!array_key_exists($section->name, $restrictions)) { - $restrictions[$section->name] = array(); - } - $restrictions[$section->name][$name] = $section->restriction; + $username = $user->getUsername(); + $userGroups = $user->getGroups(); + foreach ($config as $section) { + if (! empty($section->restriction) + && $this->match($username, $userGroups, $section) + ) { + $restrictions = array_merge( + $restrictions, + array_diff(String::trimSplit($section->restriction), $restrictions) + ); } } return $restrictions; From 79ade944ded06ebebb30a2df386dee25fc719022 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 20 Oct 2014 13:40:35 +0200 Subject: [PATCH 04/29] Resources: Support type 'ini' yet only in the resources.ini Configuring the resource type 'ini' via the web interface is not yet possible. --- library/Icinga/Data/ResourceFactory.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/library/Icinga/Data/ResourceFactory.php b/library/Icinga/Data/ResourceFactory.php index e85413615..1c443f9d0 100644 --- a/library/Icinga/Data/ResourceFactory.php +++ b/library/Icinga/Data/ResourceFactory.php @@ -4,8 +4,9 @@ namespace Icinga\Data; -use Icinga\Exception\ProgrammingError; use Zend_Config; +use Icinga\Application\Config; +use Icinga\Exception\ProgrammingError; use Icinga\Util\ConfigAwareFactory; use Icinga\Exception\ConfigurationError; use Icinga\Data\Db\DbConnection; @@ -120,6 +121,9 @@ class ResourceFactory implements ConfigAwareFactory case 'file': $resource = new FileReader($config); break; + case 'ini': + $resource = Config::fromIni($config->ini); + break; default: throw new ConfigurationError( 'Unsupported resource type "%s"', From d1228deef22263c2a129c04186303bd48df13416 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 20 Oct 2014 13:41:33 +0200 Subject: [PATCH 05/29] lib: Add UserGroupBackend as base class and factory for user group backends --- .../Authentication/UserGroupBackend.php | 113 ++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 library/Icinga/Authentication/UserGroupBackend.php diff --git a/library/Icinga/Authentication/UserGroupBackend.php b/library/Icinga/Authentication/UserGroupBackend.php new file mode 100644 index 000000000..e411aee03 --- /dev/null +++ b/library/Icinga/Authentication/UserGroupBackend.php @@ -0,0 +1,113 @@ +name = (string) $name; + return $this; + } + + /** + * Get the backend name + * + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Create a user group backend + * + * @param string $name + * @param Zend_Config $backendConfig + * + * @return DbUserGroupBackend|IniUserGroupBackend + * @throws ConfigurationError If the backend configuration is invalid + */ + public static function create($name, Zend_Config $backendConfig) + { + if ($backendConfig->name !== null) { + $name = $backendConfig->name; + } + if (($backendType = $backendConfig->backend) === null) { + throw new ConfigurationError( + 'Configuration for user group backend \'%s\' is missing the \'backend\' directive', + $name + ); + } + $backendType = strtolower($backendType); + if (($resourceName = $backendConfig->resource) === null) { + throw new ConfigurationError( + 'Configuration for user group backend \'%s\' is missing the \'resource\' directive', + $name + ); + } + $resourceName = strtolower($resourceName); + try { + $resource = ResourceFactory::create($resourceName); + } catch (IcingaException $e) { + throw new ConfigurationError( + 'Can\'t create user group backend \'%s\'. An exception was thrown: %s', + $resourceName, + $e + ); + } + switch ($backendType) { + case 'db': + $backend = new DbUserGroupBackend($resource); + break; + case 'ini': + $backend = new IniUserGroupBackend($resource); + break; + default: + throw new ConfigurationError( + 'Can\'t create user group backend \'%s\'. Invalid backend type \'%s\'.', + $name, + $backendType + ); + } + $backend->setName($name); + return $backend; + } + + /** + * Get the groups the given user is a member of + * + * @param User $user + * + * @return array + */ + abstract public function getMemberships(User $user); +} From d170cf0c9d3407d7725c356907f5054e0d1f5161 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 20 Oct 2014 13:42:15 +0200 Subject: [PATCH 06/29] lib: Replace Membership with IniUserGroupBackend --- .../Backend/IniUserGroupBackend.php | 65 +++++++++++++++++++ library/Icinga/Authentication/Membership.php | 39 ----------- 2 files changed, 65 insertions(+), 39 deletions(-) create mode 100644 library/Icinga/Authentication/Backend/IniUserGroupBackend.php delete mode 100644 library/Icinga/Authentication/Membership.php diff --git a/library/Icinga/Authentication/Backend/IniUserGroupBackend.php b/library/Icinga/Authentication/Backend/IniUserGroupBackend.php new file mode 100644 index 000000000..45d36e833 --- /dev/null +++ b/library/Icinga/Authentication/Backend/IniUserGroupBackend.php @@ -0,0 +1,65 @@ +config = $config; + } + + /** + * (non-PHPDoc) + * @see UserGroupBackend::getMemberships() For the method documentation. + */ + public function getMemberships(User $user) + { + $username = strtolower($user->getUsername()); + $groups = array(); + foreach ($this->config as $name => $section) { + if (empty($section->users)) { + throw new ConfigurationError( + 'Membership section \'%s\' in \'%s\' is missing the \'users\' section', + $name, + $this->config->getConfigFile() + ); + } + if (empty($section->groups)) { + throw new ConfigurationError( + 'Membership section \'%s\' in \'%s\' is missing the \'groups\' section', + $name, + $this->config->getConfigFile() + ); + } + $users = array_map('strtolower', String::trimSplit($section->users)); + if (in_array($username, $users)) { + $groups = array_merge($groups, array_diff(String::trimSplit($section->groups), $groups)); + } + } + return $groups; + } +} diff --git a/library/Icinga/Authentication/Membership.php b/library/Icinga/Authentication/Membership.php deleted file mode 100644 index 2f6e83710..000000000 --- a/library/Icinga/Authentication/Membership.php +++ /dev/null @@ -1,39 +0,0 @@ -users); - if (in_array($username, $users)) { - $groups = array_merge($groups, String::trimSplit($section->groups)); - } - } - return $groups; - } -} From aa56f3010c73578ec54318141a1d2c3d4a27b13d Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 20 Oct 2014 13:42:33 +0200 Subject: [PATCH 07/29] lib: Add DbUserGroupBackend --- .../Backend/DbUserGroupBackend.php | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 library/Icinga/Authentication/Backend/DbUserGroupBackend.php diff --git a/library/Icinga/Authentication/Backend/DbUserGroupBackend.php b/library/Icinga/Authentication/Backend/DbUserGroupBackend.php new file mode 100644 index 000000000..15a77d77d --- /dev/null +++ b/library/Icinga/Authentication/Backend/DbUserGroupBackend.php @@ -0,0 +1,63 @@ +conn = $conn; + } + + /** + * (non-PHPDoc) + * @see UserGroupBackend::getMemberships() For the method documentation. + */ + public function getMemberships(User $user) + { + $groups = array(); + $groupsStmt = $this->conn->getDbAdapter() + ->select() + ->from($this->conn->getTablePrefix() . 'group', array('name', 'parent')) + ->query(); + foreach ($groupsStmt as $group) { + $groups[$group->name] = $group->parent; + } + $memberships = array(); + $membershipsStmt = $this->conn->getDbAdapter() + ->select() + ->from($this->conn->getTablePrefix() . 'group_membership', array('group_name')) + ->where('username = ?', $user->getUsername()) + ->query(); + foreach ($membershipsStmt as $membership) { + $memberships[] = $membership->group_name; + $parent = $groups[$membership->group_name]; + while (isset($parent)) { + $memberships[] = $parent; + $parent = $groups[$parent]; + } + } + return $memberships; + } +} From 2b67683e00603e8105974986ab31982331ffff39 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 20 Oct 2014 13:43:03 +0200 Subject: [PATCH 08/29] DbConnection::__construct(): Set prefix if configured --- library/Icinga/Data/Db/DbConnection.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/library/Icinga/Data/Db/DbConnection.php b/library/Icinga/Data/Db/DbConnection.php index da05a429f..0157bcd72 100644 --- a/library/Icinga/Data/Db/DbConnection.php +++ b/library/Icinga/Data/Db/DbConnection.php @@ -64,6 +64,9 @@ class DbConnection implements Selectable public function __construct(Zend_Config $config = null) { $this->config = $config; + if (isset($config->prefix)) { + $this->tablePrefix = $config->prefix; + } $this->connect(); } From 424cee6b4ac9053aa0f9691ff691fd04b28c069a Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 20 Oct 2014 13:43:40 +0200 Subject: [PATCH 09/29] Auth: Load user groups using the new user group backends --- library/Icinga/Authentication/Manager.php | 44 +++++++++++++++-------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/library/Icinga/Authentication/Manager.php b/library/Icinga/Authentication/Manager.php index efe9b5815..fa974546d 100644 --- a/library/Icinga/Authentication/Manager.php +++ b/library/Icinga/Authentication/Manager.php @@ -6,14 +6,14 @@ namespace Icinga\Authentication; use Exception; use Zend_Config; -use Icinga\User; -use Icinga\Web\Session; -use Icinga\Logger\Logger; +use Icinga\Application\Config; +use Icinga\Exception\IcingaException; use Icinga\Exception\NotReadableError; -use Icinga\Application\Config as IcingaConfig; +use Icinga\Logger\Logger; +use Icinga\User; use Icinga\User\Preferences; use Icinga\User\Preferences\PreferencesStore; -use Icinga\Exception\IcingaException; +use Icinga\Web\Session; class Manager { @@ -53,7 +53,7 @@ class Manager { $username = $user->getUsername(); try { - $config = IcingaConfig::app(); + $config = Config::app(); } catch (NotReadableError $e) { Logger::error( new IcingaException( @@ -85,18 +85,32 @@ class Manager $preferences = new Preferences(); } $user->setPreferences($preferences); - $membership = new Membership(); - $groups = $membership->getGroupsByUsername($username); + $groups = array(); + foreach (Config::app('groups') as $name => $config) { + try { + $groupBackend = UserGroupBackend::create($name, $config); + $groupsFromBackend = $groupBackend->getMemberships($user); + } catch (Exception $e) { + Logger::error( + 'Can\'t get group memberships for user \'%s\' from backend \'%s\'. An exception was thrown:', + $username, + $name, + $e + ); + continue; + } + if (empty($groupsFromBackend)) { + continue; + } + $groupsFromBackend = array_values($groupsFromBackend); + $groups = array_merge($groups, array_combine($groupsFromBackend, $groupsFromBackend)); + } $user->setGroups($groups); $admissionLoader = new AdmissionLoader(); - $user->setPermissions( - $admissionLoader->getPermissions($username, $groups) - ); - $user->setRestrictions( - $admissionLoader->getRestrictions($username, $groups) - ); + $user->setPermissions($admissionLoader->getPermissions($user)); + $user->setRestrictions($admissionLoader->getRestrictions($user)); $this->user = $user; - if ($persist == true) { + if ($persist) { $this->persistCurrentUser(); } } From 1bb3a58e8f74c128ca9e5982ce20b1ec3745c668 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 20 Oct 2014 15:37:50 +0200 Subject: [PATCH 10/29] schema/mysql: Add group and group_membership tables --- etc/schema/mysql.schema.sql | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 etc/schema/mysql.schema.sql diff --git a/etc/schema/mysql.schema.sql b/etc/schema/mysql.schema.sql new file mode 100644 index 000000000..6107e6959 --- /dev/null +++ b/etc/schema/mysql.schema.sql @@ -0,0 +1,15 @@ +CREATE TABLE `icingaweb_group`( + `name` varchar(64) COLLATE utf8_unicode_ci NOT NULL, + `parent` varchar(64) COLLATE utf8_unicode_ci NULL DEFAULT NULL, + `ctime` timestamp NULL DEFAULT NULL, + `mtime` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (`name`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE `icingaweb_group_membership`( + `group_name` varchar(64) COLLATE utf8_unicode_ci NOT NULL, + `username` varchar(64) COLLATE utf8_unicode_ci NOT NULL, + `ctime` timestamp NULL DEFAULT NULL, + `mtime` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (`group_name`,`username`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; From c2a3770869f7e8c987070971d8a8dd8499eb431b Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 20 Oct 2014 16:32:31 +0200 Subject: [PATCH 11/29] schema/mysql: Add user and user_preference tables --- etc/schema/mysql.schema.sql | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/etc/schema/mysql.schema.sql b/etc/schema/mysql.schema.sql index 6107e6959..7867796b4 100644 --- a/etc/schema/mysql.schema.sql +++ b/etc/schema/mysql.schema.sql @@ -11,5 +11,25 @@ CREATE TABLE `icingaweb_group_membership`( `username` varchar(64) COLLATE utf8_unicode_ci NOT NULL, `ctime` timestamp NULL DEFAULT NULL, `mtime` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP, - PRIMARY KEY (`group_name`,`username`) + PRIMARY KEY (`group_name`,`username`), + CONSTRAINT `fk_icingaweb_group_membership_icingaweb_group` FOREIGN KEY (`group_name`) + REFERENCES `icingaweb_group` (`name`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE `icingaweb_user`( + `name` varchar(64) COLLATE utf8_unicode_ci NOT NULL, + `active` tinyint(1) NOT NULL, + `password_hash` varbinary(255) NOT NULL, + `ctime` timestamp NULL DEFAULT NULL, + `mtime` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (`name`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE `icingaweb_user_preference`( + `username` varchar(64) COLLATE utf8_unicode_ci NOT NULL, + `name` varchar(64) COLLATE utf8_unicode_ci NOT NULL, + `value` varchar(255) NOT NULL, + `ctime` timestamp NULL DEFAULT NULL, + `mtime` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (`username`,`name`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; From ba12d7b46ce3e059b0a7291ec514cda9d03829a1 Mon Sep 17 00:00:00 2001 From: Alexander Klimov Date: Tue, 21 Oct 2014 17:22:16 +0200 Subject: [PATCH 12/29] Use mt() in the monitoring module instead of just t() fixes #7330 --- .../controllers/AlertsummaryController.php | 14 ++-- .../controllers/ChartController.php | 64 +++++++++---------- .../controllers/ConfigController.php | 4 +- .../controllers/HostsController.php | 2 +- .../controllers/ListController.php | 6 +- .../controllers/MultiController.php | 6 +- .../controllers/ServicesController.php | 2 +- .../controllers/TimelineController.php | 24 +++---- .../forms/Config/BackendConfigForm.php | 40 ++++++------ .../Config/Instance/LocalInstanceForm.php | 4 +- .../Config/Instance/RemoteInstanceForm.php | 16 ++--- .../forms/Config/InstanceConfigForm.php | 36 +++++------ .../forms/Config/SecurityConfigForm.php | 8 +-- .../application/forms/StatehistoryForm.php | 42 ++++++------ .../views/scripts/command/list.phtml | 2 +- .../views/scripts/list/contactgroups.phtml | 2 +- .../views/scripts/list/contacts.phtml | 10 +-- .../views/scripts/list/hostgroups.phtml | 2 +- .../views/scripts/list/notifications.phtml | 2 +- .../views/scripts/list/servicegroups.phtml | 2 +- .../views/scripts/list/services.phtml | 2 +- .../scripts/list/statehistorysummary.phtml | 16 ++--- .../views/scripts/multi/host.phtml | 2 +- .../views/scripts/multi/service.phtml | 2 +- .../views/scripts/show/contact.phtml | 8 +-- .../monitoring/library/Monitoring/Backend.php | 6 +- .../library/Monitoring/DataView/DataView.php | 4 +- 27 files changed, 164 insertions(+), 164 deletions(-) diff --git a/modules/monitoring/application/controllers/AlertsummaryController.php b/modules/monitoring/application/controllers/AlertsummaryController.php index 02c8bb3db..e90bc1c5e 100644 --- a/modules/monitoring/application/controllers/AlertsummaryController.php +++ b/modules/monitoring/application/controllers/AlertsummaryController.php @@ -342,7 +342,7 @@ class Monitoring_AlertsummaryController extends Controller $gridChart = new GridChart(); $gridChart->alignTopLeft(); - $gridChart->setAxisLabel('', t('Notifications')) + $gridChart->setAxisLabel('', mt('monitoring', 'Notifications')) ->setXAxis(new StaticAxis()) ->setAxisMin(null, 0) ->setYAxis(new LinearUnit(10)); @@ -470,7 +470,7 @@ class Monitoring_AlertsummaryController extends Controller $gridChart = new GridChart(); $gridChart->alignTopLeft(); - $gridChart->setAxisLabel('', t('Notifications')) + $gridChart->setAxisLabel('', mt('monitoring', 'Notifications')) ->setXAxis(new StaticAxis()) ->setAxisMin(null, 0) ->setYAxis(new LinearUnit(10)); @@ -530,12 +530,12 @@ class Monitoring_AlertsummaryController extends Controller $box = new SelectBox( 'intervalBox', array( - '1d' => t('One day'), - '1w' => t('One week'), - '1m' => t('One month'), - '1y' => t('One year') + '1d' => mt('monitoring', 'One day'), + '1w' => mt('monitoring', 'One week'), + '1m' => mt('monitoring', 'One month'), + '1y' => mt('monitoring', 'One year') ), - t('Report interval'), + mt('monitoring', 'Report interval'), 'interval' ); $box->applyRequest($this->getRequest()); diff --git a/modules/monitoring/application/controllers/ChartController.php b/modules/monitoring/application/controllers/ChartController.php index 0fffcbab7..2024f83f4 100644 --- a/modules/monitoring/application/controllers/ChartController.php +++ b/modules/monitoring/application/controllers/ChartController.php @@ -143,35 +143,35 @@ class Monitoring_ChartController extends Controller } $this->view->chart = new GridChart(); $this->view->chart->alignTopLeft(); - $this->view->chart->setAxisLabel('', t('Services')) + $this->view->chart->setAxisLabel('', mt('monitoring', 'Services')) ->setXAxis(new StaticAxis()) ->setAxisMin(null, 0); - $tooltip = t('{title}:
{value} of {sum} services are {label}'); + $tooltip = mt('monitoring', '{title}:
{value} of {sum} services are {label}'); $this->view->chart->drawBars( array( - 'label' => t('Ok'), + 'label' => mt('monitoring', 'Ok'), 'color' => '#44bb77', 'stack' => 'stack1', 'data' => $okBars, 'tooltip' => $tooltip ), array( - 'label' => t('Warning'), + 'label' => mt('monitoring', 'Warning'), 'color' => '#ffaa44', 'stack' => 'stack1', 'data' => $warningBars, 'tooltip' => $tooltip ), array( - 'label' => t('Critical'), + 'label' => mt('monitoring', 'Critical'), 'color' => '#ff5566', 'stack' => 'stack1', 'data' => $critBars, 'tooltip' => $tooltip ), array( - 'label' => t('Unknown'), + 'label' => mt('monitoring', 'Unknown'), 'color' => '#dd66ff', 'stack' => 'stack1', 'data' => $unknownBars, @@ -199,29 +199,29 @@ class Monitoring_ChartController extends Controller $hostgroup->hosts_unreachable_unhandled ); } - $tooltip = t('{title}:
{value} of {sum} hosts are {label}'); + $tooltip = mt('monitoring', '{title}:
{value} of {sum} hosts are {label}'); $this->view->chart = new GridChart(); $this->view->chart->alignTopLeft(); - $this->view->chart->setAxisLabel('', t('Hosts')) + $this->view->chart->setAxisLabel('', mt('monitoring', 'Hosts')) ->setXAxis(new StaticAxis()) ->setAxisMin(null, 0); $this->view->chart->drawBars( array( - 'label' => t('Up'), + 'label' => mt('monitoring', 'Up'), 'color' => '#44bb77', 'stack' => 'stack1', 'data' => $upBars, 'tooltip' => $tooltip ), array( - 'label' => t('Down'), + 'label' => mt('monitoring', 'Down'), 'color' => '#ff5566', 'stack' => 'stack1', 'data' => $downBars, 'tooltip' => $tooltip ), array( - 'label' => t('Unreachable'), + 'label' => mt('monitoring', 'Unreachable'), 'color' => '#dd66ff', 'stack' => 'stack1', 'data' => $unreachableBars, @@ -248,13 +248,13 @@ class Monitoring_ChartController extends Controller 'colors' => array('#44bb77', '#ff4444', '#ff0000', '#ffff00', '#ffff33', '#E066FF', '#f099FF', '#fefefe'), 'labels'=> array( $query->services_ok . ' Up Services', - $query->services_warning_handled . t(' Warning Services (Handled)'), - $query->services_warning_unhandled . t(' Warning Services (Unhandled)'), - $query->services_critical_handled . t(' Down Services (Handled)'), - $query->services_critical_unhandled . t(' Down Services (Unhandled)'), - $query->services_unknown_handled . t(' Unreachable Services (Handled)'), - $query->services_unknown_unhandled . t(' Unreachable Services (Unhandled)'), - $query->services_pending . t(' Pending Services') + $query->services_warning_handled . mt('monitoring', ' Warning Services (Handled)'), + $query->services_warning_unhandled . mt('monitoring', ' Warning Services (Unhandled)'), + $query->services_critical_handled . mt('monitoring', ' Down Services (Handled)'), + $query->services_critical_unhandled . mt('monitoring', ' Down Services (Unhandled)'), + $query->services_unknown_handled . mt('monitoring', ' Unreachable Services (Handled)'), + $query->services_unknown_unhandled . mt('monitoring', ' Unreachable Services (Unhandled)'), + $query->services_pending . mt('monitoring', ' Pending Services') ) )); } @@ -274,12 +274,12 @@ class Monitoring_ChartController extends Controller ), 'colors' => array('#44bb77', '#ff4444', '#ff0000', '#E066FF', '#f099FF', '#fefefe'), 'labels'=> array( - (int) $query->hosts_up . t(' Up Hosts'), - (int) $query->hosts_down_handled . t(' Down Hosts (Handled)'), - (int) $query->hosts_down_unhandled . t(' Down Hosts (Unhandled)'), - (int) $query->hosts_unreachable_handled . t(' Unreachable Hosts (Handled)'), - (int) $query->hosts_unreachable_unhandled . t(' Unreachable Hosts (Unhandled)'), - (int) $query->hosts_pending . t(' Pending Hosts') + (int) $query->hosts_up . mt('monitoring', ' Up Hosts'), + (int) $query->hosts_down_handled . mt('monitoring', ' Down Hosts (Handled)'), + (int) $query->hosts_down_unhandled . mt('monitoring', ' Down Hosts (Unhandled)'), + (int) $query->hosts_unreachable_handled . mt('monitoring', ' Unreachable Hosts (Handled)'), + (int) $query->hosts_unreachable_unhandled . mt('monitoring', ' Unreachable Hosts (Unhandled)'), + (int) $query->hosts_pending . mt('monitoring', ' Pending Hosts') ) ), array( 'data' => array( @@ -294,14 +294,14 @@ class Monitoring_ChartController extends Controller ), 'colors' => array('#44bb77', '#ff4444', '#ff0000', '#ffff00', '#ffff33', '#E066FF', '#f099FF', '#fefefe'), 'labels'=> array( - $query->services_ok . t(' Up Services'), - $query->services_warning_handled . t(' Warning Services (Handled)'), - $query->services_warning_unhandled . t(' Warning Services (Unhandled)'), - $query->services_critical_handled . t(' Down Services (Handled)'), - $query->services_critical_unhandled . t(' Down Services (Unhandled)'), - $query->services_unknown_handled . t(' Unreachable Services (Handled)'), - $query->services_unknown_unhandled . t(' Unreachable Services (Unhandled)'), - $query->services_pending . t(' Pending Services') + $query->services_ok . mt('monitoring', ' Up Services'), + $query->services_warning_handled . mt('monitoring', ' Warning Services (Handled)'), + $query->services_warning_unhandled . mt('monitoring', ' Warning Services (Unhandled)'), + $query->services_critical_handled . mt('monitoring', ' Down Services (Handled)'), + $query->services_critical_unhandled . mt('monitoring', ' Down Services (Unhandled)'), + $query->services_unknown_handled . mt('monitoring', ' Unreachable Services (Handled)'), + $query->services_unknown_unhandled . mt('monitoring', ' Unreachable Services (Unhandled)'), + $query->services_pending . mt('monitoring', ' Pending Services') ) )); } diff --git a/modules/monitoring/application/controllers/ConfigController.php b/modules/monitoring/application/controllers/ConfigController.php index de9c65b04..cfdd73360 100644 --- a/modules/monitoring/application/controllers/ConfigController.php +++ b/modules/monitoring/application/controllers/ConfigController.php @@ -73,7 +73,7 @@ class Monitoring_ConfigController extends ModuleActionController } if ($configForm->save()) { - Notification::success(sprintf(t('Backend "%s" successfully removed.'), $backendName)); + Notification::success(sprintf(mt('monitoring', 'Backend "%s" successfully removed.'), $backendName)); } else { return false; } @@ -105,7 +105,7 @@ class Monitoring_ConfigController extends ModuleActionController } if ($configForm->save()) { - Notification::success(sprintf(t('Instance "%s" successfully removed.'), $instanceName)); + Notification::success(sprintf(mt('monitoring', 'Instance "%s" successfully removed.'), $instanceName)); } else { return false; } diff --git a/modules/monitoring/application/controllers/HostsController.php b/modules/monitoring/application/controllers/HostsController.php index 48b068705..d34a8ba2f 100644 --- a/modules/monitoring/application/controllers/HostsController.php +++ b/modules/monitoring/application/controllers/HostsController.php @@ -46,7 +46,7 @@ class Monitoring_HostsController extends Controller $this->getTabs()->add( 'show', array( - 'title' => t('Hosts'), + 'title' => mt('monitoring', 'Hosts'), 'url' => Url::fromRequest() ) )->activate('show'); diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index 1c8f671a0..e537496f9 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -395,10 +395,10 @@ class Monitoring_ListController extends Controller $orientationBox = new SelectBox( 'orientation', array( - '0' => t('Vertical'), - '1' => t('Horizontal') + '0' => mt('monitoring', 'Vertical'), + '1' => mt('monitoring', 'Horizontal') ), - t('Orientation'), + mt('monitoring', 'Orientation'), 'horizontal' ); $orientationBox->applyRequest($this->getRequest()); diff --git a/modules/monitoring/application/controllers/MultiController.php b/modules/monitoring/application/controllers/MultiController.php index 3cb15082a..52dfcf07f 100644 --- a/modules/monitoring/application/controllers/MultiController.php +++ b/modules/monitoring/application/controllers/MultiController.php @@ -54,7 +54,7 @@ class Monitoring_MultiController extends Controller $this->view->pie = $this->createPie( $this->view->states, $this->view->getHelper('MonitoringState')->getHostStateColors(), - t('Host State') + mt('monitoring', 'Host State') ); // Handle configuration changes @@ -117,12 +117,12 @@ class Monitoring_MultiController extends Controller $this->view->service_pie = $this->createPie( $this->view->service_states, $this->view->getHelper('MonitoringState')->getServiceStateColors(), - t('Service State') + mt('monitoring', 'Service State') ); $this->view->host_pie = $this->createPie( $this->view->host_states, $this->view->getHelper('MonitoringState')->getHostStateColors(), - t('Host State') + mt('monitoring', 'Host State') ); $this->view->errors = $errors; diff --git a/modules/monitoring/application/controllers/ServicesController.php b/modules/monitoring/application/controllers/ServicesController.php index c421ed881..11b983d45 100644 --- a/modules/monitoring/application/controllers/ServicesController.php +++ b/modules/monitoring/application/controllers/ServicesController.php @@ -46,7 +46,7 @@ class Monitoring_ServicesController extends Controller $this->getTabs()->add( 'show', array( - 'title' => t('Services'), + 'title' => mt('monitoring', 'Services'), 'url' => Url::fromRequest() ) )->activate('show'); diff --git a/modules/monitoring/application/controllers/TimelineController.php b/modules/monitoring/application/controllers/TimelineController.php index f78caafa6..061765f1c 100644 --- a/modules/monitoring/application/controllers/TimelineController.php +++ b/modules/monitoring/application/controllers/TimelineController.php @@ -35,32 +35,32 @@ class Monitoring_TimelineController extends Controller array( 'notify' => array( 'detailUrl' => $detailUrl, - 'label' => t('Notifications'), + 'label' => mt('monitoring', 'Notifications'), 'color' => '#3a71ea' ), 'hard_state' => array( 'detailUrl' => $detailUrl, - 'label' => t('Hard state changes'), + 'label' => mt('monitoring', 'Hard state changes'), 'color' => '#ff7000' ), 'comment' => array( 'detailUrl' => $detailUrl, - 'label' => t('Comments'), + 'label' => mt('monitoring', 'Comments'), 'color' => '#79bdba' ), 'ack' => array( 'detailUrl' => $detailUrl, - 'label' => t('Acknowledgements'), + 'label' => mt('monitoring', 'Acknowledgements'), 'color' => '#a2721d' ), 'dt_start' => array( 'detailUrl' => $detailUrl, - 'label' => t('Started downtimes'), + 'label' => mt('monitoring', 'Started downtimes'), 'color' => '#8e8e8e' ), 'dt_end' => array( 'detailUrl' => $detailUrl, - 'label' => t('Ended downtimes'), + 'label' => mt('monitoring', 'Ended downtimes'), 'color' => '#d5d6ad' ) ) @@ -88,13 +88,13 @@ class Monitoring_TimelineController extends Controller $box = new SelectBox( 'intervalBox', array( - '4h' => t('4 Hours'), - '1d' => t('One day'), - '1w' => t('One week'), - '1m' => t('One month'), - '1y' => t('One year') + '4h' => mt('monitoring', '4 Hours'), + '1d' => mt('monitoring', 'One day'), + '1w' => mt('monitoring', 'One week'), + '1m' => mt('monitoring', 'One month'), + '1y' => mt('monitoring', 'One year') ), - t('TimeLine interval'), + mt('monitoring', 'TimeLine interval'), 'interval' ); $box->applyRequest($this->getRequest()); diff --git a/modules/monitoring/application/forms/Config/BackendConfigForm.php b/modules/monitoring/application/forms/Config/BackendConfigForm.php index 079ea538a..472046636 100644 --- a/modules/monitoring/application/forms/Config/BackendConfigForm.php +++ b/modules/monitoring/application/forms/Config/BackendConfigForm.php @@ -29,7 +29,7 @@ class BackendConfigForm extends ConfigForm public function init() { $this->setName('form_config_monitoring_backends'); - $this->setSubmitLabel(t('Save Changes')); + $this->setSubmitLabel(mt('monitoring', 'Save Changes')); } /** @@ -51,7 +51,7 @@ class BackendConfigForm extends ConfigForm } if (empty($resources)) { - throw new ConfigurationError(t('Could not find any valid monitoring backend resources')); + throw new ConfigurationError(mt('monitoring', 'Could not find any valid monitoring backend resources')); } $this->resources = $resources; @@ -73,9 +73,9 @@ class BackendConfigForm extends ConfigForm { $name = isset($values['name']) ? $values['name'] : ''; if (! $name) { - throw new InvalidArgumentException(t('Monitoring backend name missing')); + throw new InvalidArgumentException(mt('monitoring', 'Monitoring backend name missing')); } elseif ($this->config->get($name) !== null) { - throw new InvalidArgumentException(t('Monitoring backend already exists')); + throw new InvalidArgumentException(mt('monitoring', 'Monitoring backend already exists')); } unset($values['name']); @@ -96,11 +96,11 @@ class BackendConfigForm extends ConfigForm public function edit($name, array $values) { if (! $name) { - throw new InvalidArgumentException(t('Old monitoring backend name missing')); + throw new InvalidArgumentException(mt('monitoring', 'Old monitoring backend name missing')); } elseif (! ($newName = isset($values['name']) ? $values['name'] : '')) { - throw new InvalidArgumentException(t('New monitoring backend name missing')); + throw new InvalidArgumentException(mt('monitoring', 'New monitoring backend name missing')); } elseif (($backendConfig = $this->config->get($name)) === null) { - throw new InvalidArgumentException(t('Unknown monitoring backend provided')); + throw new InvalidArgumentException(mt('monitoring', 'Unknown monitoring backend provided')); } unset($values['name']); @@ -121,9 +121,9 @@ class BackendConfigForm extends ConfigForm public function remove($name) { if (! $name) { - throw new InvalidArgumentException(t('Monitoring backend name missing')); + throw new InvalidArgumentException(mt('monitoring', 'Monitoring backend name missing')); } elseif (($backendConfig = $this->config->get($name)) === null) { - throw new InvalidArgumentException(t('Unknown monitoring backend provided')); + throw new InvalidArgumentException(mt('monitoring', 'Unknown monitoring backend provided')); } unset($this->config->{$name}); @@ -141,10 +141,10 @@ class BackendConfigForm extends ConfigForm try { if ($monitoringBackend === null) { // create new backend $this->add($this->getValues()); - $message = t('Monitoring backend "%s" has been successfully created'); + $message = mt('monitoring', 'Monitoring backend "%s" has been successfully created'); } else { // edit existing backend $this->edit($monitoringBackend, $this->getValues()); - $message = t('Monitoring backend "%s" has been successfully changed'); + $message = mt('monitoring', 'Monitoring backend "%s" has been successfully changed'); } } catch (InvalidArgumentException $e) { Notification::error($e->getMessage()); @@ -170,9 +170,9 @@ class BackendConfigForm extends ConfigForm $monitoringBackend = $request->getQuery('backend'); if ($monitoringBackend !== null) { if ($monitoringBackend === '') { - throw new ConfigurationError(t('Monitoring backend name missing')); + throw new ConfigurationError(mt('monitoring', 'Monitoring backend name missing')); } elseif (false === isset($this->config->{$monitoringBackend})) { - throw new ConfigurationError(t('Unknown monitoring backend provided')); + throw new ConfigurationError(mt('monitoring', 'Unknown monitoring backend provided')); } $backendConfig = $this->config->{$monitoringBackend}->toArray(); @@ -201,7 +201,7 @@ class BackendConfigForm extends ConfigForm 'disabled', array( 'required' => true, - 'label' => t('Disable This Backend') + 'label' => mt('monitoring', 'Disable This Backend') ) ); $this->addElement( @@ -209,8 +209,8 @@ class BackendConfigForm extends ConfigForm 'name', array( 'required' => true, - 'label' => t('Backend Name'), - 'description' => t('The identifier of this backend') + 'label' => mt('monitoring', 'Backend Name'), + 'description' => mt('monitoring', 'The identifier of this backend') ) ); $this->addElement( @@ -219,8 +219,8 @@ class BackendConfigForm extends ConfigForm array( 'required' => true, 'autosubmit' => true, - 'label' => t('Backend Type'), - 'description' => t('The data source used for retrieving monitoring information'), + 'label' => mt('monitoring', 'Backend Type'), + 'description' => mt('monitoring', 'The data source used for retrieving monitoring information'), 'multiOptions' => $resourceTypes, 'value' => $resourceType ) @@ -230,8 +230,8 @@ class BackendConfigForm extends ConfigForm 'resource', array( 'required' => true, - 'label' => t('Resource'), - 'description' => t('The resource to use'), + 'label' => mt('monitoring', 'Resource'), + 'description' => mt('monitoring', 'The resource to use'), 'multiOptions' => $this->resources[$resourceType] ) ); diff --git a/modules/monitoring/application/forms/Config/Instance/LocalInstanceForm.php b/modules/monitoring/application/forms/Config/Instance/LocalInstanceForm.php index 513ba2433..7af9b1bb3 100644 --- a/modules/monitoring/application/forms/Config/Instance/LocalInstanceForm.php +++ b/modules/monitoring/application/forms/Config/Instance/LocalInstanceForm.php @@ -26,9 +26,9 @@ class LocalInstanceForm extends Form 'path', array( 'required' => true, - 'label' => t('Local Filepath'), + 'label' => mt('monitoring', 'Local Filepath'), 'value' => '/usr/local/icinga/var/rw/icinga.cmd', - 'description' => t('The file path where the icinga commandpipe can be found') + 'description' => mt('monitoring', 'The file path where the icinga commandpipe can be found') ) ); diff --git a/modules/monitoring/application/forms/Config/Instance/RemoteInstanceForm.php b/modules/monitoring/application/forms/Config/Instance/RemoteInstanceForm.php index 0e78a0aec..80bacee24 100644 --- a/modules/monitoring/application/forms/Config/Instance/RemoteInstanceForm.php +++ b/modules/monitoring/application/forms/Config/Instance/RemoteInstanceForm.php @@ -24,8 +24,8 @@ class RemoteInstanceForm extends Form 'host', array( 'required' => true, - 'label' => t('Remote Host'), - 'description' => t( + 'label' => mt('monitoring', 'Remote Host'), + 'description' => mt('monitoring', 'Enter the hostname or address of the machine on which the icinga instance is running' ) ) @@ -35,8 +35,8 @@ class RemoteInstanceForm extends Form array( 'required' => true, 'name' => 'port', - 'label' => t('Remote SSH Port'), - 'description' => t('Enter the ssh port to use for connecting to the remote icinga instance'), + 'label' => mt('monitoring', 'Remote SSH Port'), + 'description' => mt('monitoring', 'Enter the ssh port to use for connecting to the remote icinga instance'), 'value' => 22 ) ) @@ -46,8 +46,8 @@ class RemoteInstanceForm extends Form 'user', array( 'required' => true, - 'label' => t('Remote SSH User'), - 'description' => t( + 'label' => mt('monitoring', 'Remote SSH User'), + 'description' => mt('monitoring', 'Enter the username to use for connecting to the remote machine or leave blank for default' ) ) @@ -57,9 +57,9 @@ class RemoteInstanceForm extends Form 'path', array( 'required' => true, - 'label' => t('Remote Filepath'), + 'label' => mt('monitoring', 'Remote Filepath'), 'value' => '/usr/local/icinga/var/rw/icinga.cmd', - 'description' => t('The file path where the icinga commandpipe can be found') + 'description' => mt('monitoring', 'The file path where the icinga commandpipe can be found') ) ); diff --git a/modules/monitoring/application/forms/Config/InstanceConfigForm.php b/modules/monitoring/application/forms/Config/InstanceConfigForm.php index 6f8d04764..598a6cea1 100644 --- a/modules/monitoring/application/forms/Config/InstanceConfigForm.php +++ b/modules/monitoring/application/forms/Config/InstanceConfigForm.php @@ -23,7 +23,7 @@ class InstanceConfigForm extends ConfigForm public function init() { $this->setName('form_config_monitoring_instance'); - $this->setSubmitLabel(t('Save Changes')); + $this->setSubmitLabel(mt('monitoring', 'Save Changes')); } /** @@ -42,7 +42,7 @@ class InstanceConfigForm extends ConfigForm } elseif ($type === 'remote') { return new RemoteInstanceForm(); } else { - throw new InvalidArgumentException(sprintf(t('Invalid instance type "%s" provided'), $type)); + throw new InvalidArgumentException(sprintf(mt('monitoring', 'Invalid instance type "%s" provided'), $type)); } } @@ -61,9 +61,9 @@ class InstanceConfigForm extends ConfigForm { $name = isset($values['name']) ? $values['name'] : ''; if (! $name) { - throw new InvalidArgumentException(t('Instance name missing')); + throw new InvalidArgumentException(mt('monitoring', 'Instance name missing')); } elseif ($this->config->get($name) !== null) { - throw new InvalidArgumentException(t('Instance already exists')); + throw new InvalidArgumentException(mt('monitoring', 'Instance already exists')); } unset($values['name']); @@ -84,11 +84,11 @@ class InstanceConfigForm extends ConfigForm public function edit($name, array $values) { if (! $name) { - throw new InvalidArgumentException(t('Old instance name missing')); + throw new InvalidArgumentException(mt('monitoring', 'Old instance name missing')); } elseif (! ($newName = isset($values['name']) ? $values['name'] : '')) { - throw new InvalidArgumentException(t('New instance name missing')); + throw new InvalidArgumentException(mt('monitoring', 'New instance name missing')); } elseif (! ($instanceConfig = $this->config->get($name))) { - throw new InvalidArgumentException(t('Unknown instance name provided')); + throw new InvalidArgumentException(mt('monitoring', 'Unknown instance name provided')); } unset($values['name']); @@ -109,9 +109,9 @@ class InstanceConfigForm extends ConfigForm public function remove($name) { if (! $name) { - throw new InvalidArgumentException(t('Instance name missing')); + throw new InvalidArgumentException(mt('monitoring', 'Instance name missing')); } elseif (! ($instanceConfig = $this->config->get($name))) { - throw new InvalidArgumentException(t('Unknown instance name provided')); + throw new InvalidArgumentException(mt('monitoring', 'Unknown instance name provided')); } unset($this->config->{$name}); @@ -128,10 +128,10 @@ class InstanceConfigForm extends ConfigForm try { if ($instanceName === null) { // create new instance $this->add($this->getValues()); - $message = t('Instance "%s" created successfully.'); + $message = mt('monitoring', 'Instance "%s" created successfully.'); } else { // edit existing instance $this->edit($instanceName, $this->getValues()); - $message = t('Instance "%s" edited successfully.'); + $message = mt('monitoring', 'Instance "%s" edited successfully.'); } } catch (InvalidArgumentException $e) { Notification::error($e->getMessage()); @@ -155,9 +155,9 @@ class InstanceConfigForm extends ConfigForm $instanceName = $request->getQuery('instance'); if ($instanceName !== null) { if (! $instanceName) { - throw new ConfigurationError(t('Instance name missing')); + throw new ConfigurationError(mt('monitoring', 'Instance name missing')); } elseif (false === isset($this->config->{$instanceName})) { - throw new ConfigurationError(t('Unknown instance name provided')); + throw new ConfigurationError(mt('monitoring', 'Unknown instance name provided')); } $instanceConfig = $this->config->{$instanceName}->toArray(); @@ -182,7 +182,7 @@ class InstanceConfigForm extends ConfigForm 'name', array( 'required' => true, - 'label' => t('Instance Name') + 'label' => mt('monitoring', 'Instance Name') ) ); $this->addElement( @@ -192,13 +192,13 @@ class InstanceConfigForm extends ConfigForm 'required' => true, 'ignore' => true, 'autosubmit' => true, - 'label' => t('Instance Type'), - 'description' => t( + 'label' => mt('monitoring', 'Instance Type'), + 'description' => mt('monitoring', 'When configuring a remote host, you need to setup passwordless key authentication' ), 'multiOptions' => array( - 'local' => t('Local Command Pipe'), - 'remote' => t('Remote Command Pipe') + 'local' => mt('monitoring', 'Local Command Pipe'), + 'remote' => mt('monitoring', 'Remote Command Pipe') ), 'value' => $instanceType ) diff --git a/modules/monitoring/application/forms/Config/SecurityConfigForm.php b/modules/monitoring/application/forms/Config/SecurityConfigForm.php index e0cc68680..a57e82702 100644 --- a/modules/monitoring/application/forms/Config/SecurityConfigForm.php +++ b/modules/monitoring/application/forms/Config/SecurityConfigForm.php @@ -19,7 +19,7 @@ class SecurityConfigForm extends ConfigForm public function init() { $this->setName('form_config_monitoring_security'); - $this->setSubmitLabel(t('Save Changes')); + $this->setSubmitLabel(mt('monitoring', 'Save Changes')); } /** @@ -30,7 +30,7 @@ class SecurityConfigForm extends ConfigForm $this->config->security = $this->getValues(); if ($this->save()) { - Notification::success(t('New security configuration has successfully been stored')); + Notification::success(mt('monitoring', 'New security configuration has successfully been stored')); } else { return false; } @@ -56,8 +56,8 @@ class SecurityConfigForm extends ConfigForm 'protected_customvars', array( 'required' => true, - 'label' => t('Protected Custom Variables'), - 'description' => t( + 'label' => mt('monitoring', 'Protected Custom Variables'), + 'description' => mt('monitoring', 'Comma separated case insensitive list of protected custom variables.' . ' Use * as a placeholder for zero or more wildcard characters.' . ' Existance of those custom variables will be shown, but their values will be masked.' diff --git a/modules/monitoring/application/forms/StatehistoryForm.php b/modules/monitoring/application/forms/StatehistoryForm.php index ed5710454..bcadeeb66 100644 --- a/modules/monitoring/application/forms/StatehistoryForm.php +++ b/modules/monitoring/application/forms/StatehistoryForm.php @@ -56,14 +56,14 @@ class StatehistoryForm extends Form 'select', 'from', array( - 'label' => t('From'), + 'label' => mt('monitoring', 'From'), 'value' => $this->getRequest()->getParam('from', strtotime('3 months ago')), 'multiOptions' => array( - strtotime('midnight 3 months ago') => t('3 Months'), - strtotime('midnight 4 months ago') => t('4 Months'), - strtotime('midnight 8 months ago') => t('8 Months'), - strtotime('midnight 12 months ago') => t('1 Year'), - strtotime('midnight 24 months ago') => t('2 Years') + strtotime('midnight 3 months ago') => mt('monitoring', '3 Months'), + strtotime('midnight 4 months ago') => mt('monitoring', '4 Months'), + strtotime('midnight 8 months ago') => mt('monitoring', '8 Months'), + strtotime('midnight 12 months ago') => mt('monitoring', '1 Year'), + strtotime('midnight 24 months ago') => mt('monitoring', '2 Years') ), 'class' => 'autosubmit' ) @@ -72,10 +72,10 @@ class StatehistoryForm extends Form 'select', 'to', array( - 'label' => t('To'), + 'label' => mt('monitoring', 'To'), 'value' => $this->getRequest()->getParam('to', time()), 'multiOptions' => array( - time() => t('Today') + time() => mt('monitoring', 'Today') ), 'class' => 'autosubmit' ) @@ -86,11 +86,11 @@ class StatehistoryForm extends Form 'select', 'objecttype', array( - 'label' => t('Object type'), + 'label' => mt('monitoring', 'Object type'), 'value' => $objectType, 'multiOptions' => array( - 'services' => t('Services'), - 'hosts' => t('Hosts') + 'services' => mt('monitoring', 'Services'), + 'hosts' => mt('monitoring', 'Hosts') ), 'class' => 'autosubmit' ) @@ -104,13 +104,13 @@ class StatehistoryForm extends Form 'select', 'state', array( - 'label' => t('State'), + 'label' => mt('monitoring', 'State'), 'value' => $serviceState, 'multiOptions' => array( - 'cnt_critical_hard' => t('Critical'), - 'cnt_warning_hard' => t('Warning'), - 'cnt_unknown_hard' => t('Unknown'), - 'cnt_ok' => t('Ok') + 'cnt_critical_hard' => mt('monitoring', 'Critical'), + 'cnt_warning_hard' => mt('monitoring', 'Warning'), + 'cnt_unknown_hard' => mt('monitoring', 'Unknown'), + 'cnt_ok' => mt('monitoring', 'Ok') ), 'class' => 'autosubmit' ) @@ -124,12 +124,12 @@ class StatehistoryForm extends Form 'select', 'state', array( - 'label' => t('State'), + 'label' => mt('monitoring', 'State'), 'value' => $hostState, 'multiOptions' => array( - 'cnt_up' => t('Up'), - 'cnt_down_hard' => t('Down'), - 'cnt_unreachable_hard' => t('Unreachable') + 'cnt_up' => mt('monitoring', 'Up'), + 'cnt_down_hard' => mt('monitoring', 'Down'), + 'cnt_unreachable_hard' => mt('monitoring', 'Unreachable') ), 'class' => 'autosubmit' ) @@ -143,7 +143,7 @@ class StatehistoryForm extends Form 'escape' => false, 'value' => '1', 'class' => 'btn btn-cta btn-common', - 'label' => t('Apply') + 'label' => mt('monitoring', 'Apply') ) ); } diff --git a/modules/monitoring/application/views/scripts/command/list.phtml b/modules/monitoring/application/views/scripts/command/list.phtml index 8a0340f3b..747dd4b5e 100644 --- a/modules/monitoring/application/views/scripts/command/list.phtml +++ b/modules/monitoring/application/views/scripts/command/list.phtml @@ -1,4 +1,4 @@ -

+

    commands as $command): ?>
  • diff --git a/modules/monitoring/application/views/scripts/list/contactgroups.phtml b/modules/monitoring/application/views/scripts/list/contactgroups.phtml index c110bf011..f25548c52 100644 --- a/modules/monitoring/application/views/scripts/list/contactgroups.phtml +++ b/modules/monitoring/application/views/scripts/list/contactgroups.phtml @@ -8,7 +8,7 @@ $groupInfo): ?> diff --git a/modules/monitoring/application/views/scripts/list/contacts.phtml b/modules/monitoring/application/views/scripts/list/contacts.phtml index a31a79553..a85506841 100644 --- a/modules/monitoring/application/views/scripts/list/contacts.phtml +++ b/modules/monitoring/application/views/scripts/list/contacts.phtml @@ -13,7 +13,7 @@ $contactHelper = $this->getHelper('ContactFlags');
    @@ -25,12 +25,12 @@ $contactHelper = $this->getHelper('ContactFlags'); ) ?>">contact_name ?> (contact_alias ?>)
    %2$s', - t('Email'), + mt('monitoring', 'Email'), $this->escape($contact->contact_email) ) ?>
    contact_pager): ?>
    - : + : escape($contact->contact_pager) ?>
    @@ -38,13 +38,13 @@ $contactHelper = $this->getHelper('ContactFlags');
    contact_notify_service_timeperiod): ?>
    - : + : escape($contact->contact_notify_service_timeperiod) ?>
    contact_notify_host_timeperiod): ?>
    - : + : escape($contact->contact_notify_host_timeperiod) ?>
    diff --git a/modules/monitoring/application/views/scripts/list/hostgroups.phtml b/modules/monitoring/application/views/scripts/list/hostgroups.phtml index 49d8099ff..5a60c7a68 100644 --- a/modules/monitoring/application/views/scripts/list/hostgroups.phtml +++ b/modules/monitoring/application/views/scripts/list/hostgroups.phtml @@ -8,7 +8,7 @@ diff --git a/modules/monitoring/application/views/scripts/list/notifications.phtml b/modules/monitoring/application/views/scripts/list/notifications.phtml index d1ff9cdad..365d32f56 100644 --- a/modules/monitoring/application/views/scripts/list/notifications.phtml +++ b/modules/monitoring/application/views/scripts/list/notifications.phtml @@ -26,7 +26,7 @@ if (empty($this->notifications)) { diff --git a/modules/monitoring/application/views/scripts/list/services.phtml b/modules/monitoring/application/views/scripts/list/services.phtml index 66cf14c54..815d43074 100644 --- a/modules/monitoring/application/views/scripts/list/services.phtml +++ b/modules/monitoring/application/views/scripts/list/services.phtml @@ -36,7 +36,7 @@ if (!$this->compact): ?> href( diff --git a/modules/monitoring/application/views/scripts/list/statehistorysummary.phtml b/modules/monitoring/application/views/scripts/list/statehistorysummary.phtml index cdb19dba7..eb65b779e 100644 --- a/modules/monitoring/application/views/scripts/list/statehistorysummary.phtml +++ b/modules/monitoring/application/views/scripts/list/statehistorysummary.phtml @@ -23,39 +23,39 @@ use Icinga\Web\Widget\Chart\HistoryColorGrid; $settings = array( 'cnt_up' => array( - 'tooltip' => t('%d ok on %s'), + 'tooltip' => mt('monitoring', '%d ok on %s'), 'color' => '#49DF96', 'opacity' => '0.55' ), 'cnt_unreachable_hard' => array( - 'tooltip' => t('%d unreachable on %s'), + 'tooltip' => mt('monitoring', '%d unreachable on %s'), 'color' => '#77AAFF', 'opacity' => '0.55' ), 'cnt_critical_hard' => array( - 'tooltip' => t('%d critical on %s'), + 'tooltip' => mt('monitoring', '%d critical on %s'), 'color' => '#ff5566', 'opacity' => '0.9' ), 'cnt_warning_hard' => array( - 'tooltip' => t('%d warning on %s'), + 'tooltip' => mt('monitoring', '%d warning on %s'), 'color' => '#ffaa44', 'opacity' => '1.0' ), 'cnt_down_hard' => array( - 'tooltip' => t('%d down on %s'), + 'tooltip' => mt('monitoring', '%d down on %s'), 'color' => '#ff5566', 'opacity' => '0.9' ), 'cnt_unknown_hard' => array( - 'tooltip' => t('%d unknown on %s'), + 'tooltip' => mt('monitoring', '%d unknown on %s'), 'color' => '#cc77ff', 'opacity' => '0.7' ), 'cnt_ok' => array( - 'tooltip' => t('%d ok on %s'), + 'tooltip' => mt('monitoring', '%d ok on %s'), 'color' => '#49DF96', 'opacity' => '0.55' ) @@ -71,7 +71,7 @@ if ($to - $from > 315360000) { $data = array(); if (count($summary) === 0) { - echo t('No state changes in the selected time period.'); + echo mt('monitoring', 'No state changes in the selected time period.'); } foreach ($summary as $entry) { $day = $entry->day; diff --git a/modules/monitoring/application/views/scripts/multi/host.phtml b/modules/monitoring/application/views/scripts/multi/host.phtml index 414609a69..9f61b8fb8 100644 --- a/modules/monitoring/application/views/scripts/multi/host.phtml +++ b/modules/monitoring/application/views/scripts/multi/host.phtml @@ -10,7 +10,7 @@ $this->target = array('host' => $this->hostquery);
    - +

    Summary for hosts

    render('multi/components/objectlist.phtml'); ?> diff --git a/modules/monitoring/application/views/scripts/multi/service.phtml b/modules/monitoring/application/views/scripts/multi/service.phtml index ea71693df..ddab8339f 100644 --- a/modules/monitoring/application/views/scripts/multi/service.phtml +++ b/modules/monitoring/application/views/scripts/multi/service.phtml @@ -14,7 +14,7 @@ $this->target = array(
    - +

    Summary for services

    diff --git a/modules/monitoring/application/views/scripts/show/contact.phtml b/modules/monitoring/application/views/scripts/show/contact.phtml index cdb6af12c..c7eac204c 100644 --- a/modules/monitoring/application/views/scripts/show/contact.phtml +++ b/modules/monitoring/application/views/scripts/show/contact.phtml @@ -19,23 +19,23 @@ contact_email): ?> - + %1$s', $this->escape($contact->contact_email)) ?> contact_pager): ?> - + escape($contact->contact_pager) ?> - + escape($contactHelper->contactFlags($contact, 'host')) ?>
    escape($contact->contact_notify_host_timeperiod) ?> - + escape($contactHelper->contactFlags($contact, 'service')) ?>
    escape($contact->contact_notify_service_timeperiod) ?> diff --git a/modules/monitoring/library/Monitoring/Backend.php b/modules/monitoring/library/Monitoring/Backend.php index 454a33cef..f6aa6b447 100644 --- a/modules/monitoring/library/Monitoring/Backend.php +++ b/modules/monitoring/library/Monitoring/Backend.php @@ -71,7 +71,7 @@ class Backend implements Selectable, Queryable, ConnectionInterface { $config = IcingaConfig::module('monitoring', 'backends'); if ($config->count() === 0) { - throw new ConfigurationError(t('No backend has been configured')); + throw new ConfigurationError(mt('monitoring', 'No backend has been configured')); } if ($backendName !== null) { $backendConfig = $config->get($backendName); @@ -80,7 +80,7 @@ class Backend implements Selectable, Queryable, ConnectionInterface } if ((bool) $backendConfig->get('disabled', false) === true) { throw new ConfigurationError( - t('Configuration for backend %s available but backend is disabled'), + mt('monitoring', 'Configuration for backend %s available but backend is disabled'), $backendName ); } @@ -92,7 +92,7 @@ class Backend implements Selectable, Queryable, ConnectionInterface } } if ($backendName === null) { - throw new ConfigurationError(t('All backends are disabled')); + throw new ConfigurationError(mt('monitoring', 'All backends are disabled')); } } $resource = ResourceFactory::create($backendConfig->resource); diff --git a/modules/monitoring/library/Monitoring/DataView/DataView.php b/modules/monitoring/library/Monitoring/DataView/DataView.php index df331999e..2c4ec5380 100644 --- a/modules/monitoring/library/Monitoring/DataView/DataView.php +++ b/modules/monitoring/library/Monitoring/DataView/DataView.php @@ -245,7 +245,7 @@ abstract class DataView implements Browsable, Countable, Filterable, Sortable foreach ($sortColumns['columns'] as $column) { if (! $this->isValidFilterTarget($column)) { throw new QueryException( - t('The sort column "%s" is not allowed in "%s".'), + mt('monitoring', 'The sort column "%s" is not allowed in "%s".'), $column, get_class($this) ); @@ -336,7 +336,7 @@ abstract class DataView implements Browsable, Countable, Filterable, Sortable if ($filter instanceof FilterMatch) { if (! $this->isValidFilterTarget($filter->getColumn())) { throw new QueryException( - t('The filter column "%s" is not allowed here.'), + mt('monitoring', 'The filter column "%s" is not allowed here.'), $filter->getColumn() ); } From f68c591a4640dd12ae847ce25f466d58042812ad Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 23 Oct 2014 03:46:49 +0200 Subject: [PATCH 13/29] LDAP Auth: Make group loading really optional fixes #7432 --- library/Icinga/Authentication/Backend/LdapUserBackend.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/library/Icinga/Authentication/Backend/LdapUserBackend.php b/library/Icinga/Authentication/Backend/LdapUserBackend.php index 8ef6c89de..3ee3c17dd 100644 --- a/library/Icinga/Authentication/Backend/LdapUserBackend.php +++ b/library/Icinga/Authentication/Backend/LdapUserBackend.php @@ -174,7 +174,10 @@ class LdapUserBackend extends UserBackend $password ); if ($authenticated) { - $user->setGroups($this->getGroups($userDn)); + $groups = $this->getGroups($userDn); + if ($groups !== null) { + $user->setGroups($groups); + } } return $authenticated; } catch (LdapException $e) { From f44b0525d8be403a1c6aebc505612d20043dff34 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 23 Oct 2014 03:48:10 +0200 Subject: [PATCH 14/29] logging: Fix that setting a numeric log level is flawed --- library/Icinga/Logger/Logger.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/library/Icinga/Logger/Logger.php b/library/Icinga/Logger/Logger.php index 1cc820ef7..17f41ecba 100644 --- a/library/Icinga/Logger/Logger.php +++ b/library/Icinga/Logger/Logger.php @@ -84,7 +84,8 @@ class Logger if (($level = $config->level) !== null) { if (is_numeric($level)) { - if (! isset(static::$levels[(int) $level])) { + $level = (int) $level; + if (! isset(static::$levels[$level])) { throw new ConfigurationError( 'Can\'t set logging level %d. Logging level is not defined. Use one of %s or one of the' . ' Logger\'s constants.', @@ -92,7 +93,7 @@ class Logger implode(', ', array_keys(static::$levels)) ); } - $this->level = static::$levels[(int) $level]; + $this->level = $level; } else { $level = strtoupper($level); $levels = array_flip(static::$levels); From 38220afd11ffeab82d5822fd86ddd2ec4cfe404c Mon Sep 17 00:00:00 2001 From: Alexander Klimov Date: Thu, 23 Oct 2014 10:44:54 +0200 Subject: [PATCH 15/29] PHP: avoid short tags title ? $this->escape($this->title) : 'Icinga Web' ?> - +