Skip to content

Commit

Permalink
Merge branch 'master' into feature/setup-wizard-7163
Browse files Browse the repository at this point in the history
  • Loading branch information
Johannes Meyer committed Sep 29, 2014
2 parents c3e3a41 + 3ee9cd2 commit cbadaa7
Show file tree
Hide file tree
Showing 28 changed files with 325 additions and 230 deletions.
4 changes: 2 additions & 2 deletions application/controllers/ConfigController.php
Expand Up @@ -96,7 +96,7 @@ public function moduleenableAction()
try {
$manager->enableModule($module);
$manager->loadModule($module);
Notification::success('Module "' . $module . '" enabled');
Notification::success(sprintf($this->translate('Module "%s" enabled'), $module));
$this->rerenderLayout()->reloadCss()->redirectNow('config/modules');
} catch (Exception $e) {
$this->view->exceptionMesssage = $e->getMessage();
Expand All @@ -115,7 +115,7 @@ public function moduledisableAction()
$manager = Icinga::app()->getModuleManager();
try {
$manager->disableModule($module);
Notification::success('Module "' . $module . '" disabled');
Notification::success(sprintf($this->translate('Module "%s" disabled'), $module));
$this->rerenderLayout()->reloadCss()->redirectNow('config/modules');
} catch (Exception $e) {
$this->view->exceptionMessage = $e->getMessage();
Expand Down
6 changes: 3 additions & 3 deletions application/views/scripts/config/modules.phtml
@@ -1,6 +1,6 @@
<div class="controls">
<?= $this->tabs ?>
<h1>Installed Modules</h1>
<h1><?= $this->translate('Installed Modules') ?></h1>
<?= $this->paginationControl($modules) ?>
</div>

Expand All @@ -11,9 +11,9 @@
<tr>
<td>
<?php if ($module->enabled): ?>
<?= $this->icon('success.png', 'Module is enabled') ?>
<?= $this->icon('success.png', $this->translate('Module is enabled')) ?>
<?php else: ?>
<?= $this->icon('remove.png', 'Module is disabled') ?>
<?= $this->icon('remove.png', $this->translate('Module is disabled')) ?>
<? endif ?>
<a href="<?= $this->url(
'config/module/',
Expand Down
5 changes: 3 additions & 2 deletions library/Icinga/Application/Web.php
Expand Up @@ -278,7 +278,8 @@ protected function setupTimezone()

if ($this->user !== null && $this->user->getPreferences() !== null) {
$detect = new TimezoneDetect();
$userTimezone = $this->user->getPreferences()->get('app.timezone', $detect->getTimezoneName());
$userTimezone = $this->user->getPreferences()
->getValue('icingaweb', 'timezone', $detect->getTimezoneName());
}

try {
Expand All @@ -302,7 +303,7 @@ protected function setupInternationalization()
{
parent::setupInternationalization();
if ($this->user !== null && $this->user->getPreferences() !== null
&& (($locale = $this->user->getPreferences()->get('app.language')) !== null)
&& (($locale = $this->user->getPreferences()->getValue('icingaweb', 'language')) !== null)
) {
try {
Translator::setupLocale($locale);
Expand Down
27 changes: 23 additions & 4 deletions library/Icinga/User/Preferences.php
Expand Up @@ -79,19 +79,38 @@ public function __set($name, $value)
}

/**
* Retrieve a preference and return $default if the preference is not set
* Retrieve a preference section
*
* @param string $name
* @param mixed $default
*
* @return mixed
* @return array|null
*/
public function get($name, $default = null)
public function get($name)
{
if (array_key_exists($name, $this->preferences)) {
return $this->preferences[$name];
}

return null;
}

/**
* Retrieve a value from a specific section
*
* @param string $section
* @param string $name
* @param null $default
*
* @return array|null
*/
public function getValue($section, $name, $default = null)
{
if (array_key_exists($section, $this->preferences)
&& array_key_exists($name, $this->preferences[$section])
) {
return $this->preferences[$section][$name];
}

return $default;
}

Expand Down
2 changes: 1 addition & 1 deletion library/Icinga/Web/Controller/ActionController.php
Expand Up @@ -370,7 +370,7 @@ public function postDispatch()
if ($user = $req->getUser()) {
// Cast preference app.show_benchmark to bool because preferences loaded from a preferences storage are
// always strings
if ((bool) $user->getPreferences()->get('app.show_benchmark', false) === true) {
if ((bool) $user->getPreferences()->getValue('icingaweb', 'show_benchmark', false) === true) {
if (!$this->_helper->viewRenderer->getNoRender()) {
$layout->benchmark = $this->renderBenchmark();
}
Expand Down
31 changes: 31 additions & 0 deletions library/Icinga/Web/Form/Element/Note.php
@@ -0,0 +1,31 @@
<?php
// {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}}

namespace Icinga\Web\Form\Element;

use Zend_Form_Element_Xhtml;

/**
* Implements note element for Zend forms
*/
class Note extends Zend_Form_Element_Xhtml
{
/**
* Name of the view helper
*
* @var string
*/
public $helper = 'formNote';

/**
* Return true to ensure redrawing
*
* @param mixed $value The value of to validate (ignored)
* @return bool Always true
*/
public function isValid($value)
{
return true;
}
}
Expand Up @@ -274,7 +274,7 @@ private function drawHostGroupPie($query)
),
'colors' => array('#44bb77', '#ff4444', '#ff0000', '#E066FF', '#f099FF', '#fefefe'),
'labels'=> array(
(int) $query->hosts_up . ' Up Hosts',
(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)'),
Expand All @@ -294,7 +294,7 @@ private function drawHostGroupPie($query)
),
'colors' => array('#44bb77', '#ff4444', '#ff0000', '#ffff00', '#ffff33', '#E066FF', '#f099FF', '#fefefe'),
'labels'=> array(
$query->services_ok . ' Up Services',
$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)'),
Expand Down
Expand Up @@ -115,14 +115,17 @@ public function init()
if ($targetConfig->get($instance)) {
$this->target = new CommandPipe($targetConfig->get($instance));
} else {
throw new ConfigurationError('Instance is not configured: %s', $instance);
throw new ConfigurationError(
$this->translate('Instance is not configured: %s'),
$instance
);
}
} else {
if ($targetConfig && $targetInfo = $targetConfig->current()) {
// Take the very first section
$this->target = new CommandPipe($targetInfo);
} else {
throw new ConfigurationError('No instances are configured yet');
throw new ConfigurationError($this->translate('No instances are configured yet'));
}
}
}
Expand Down
84 changes: 44 additions & 40 deletions modules/monitoring/application/controllers/ListController.php
Expand Up @@ -143,12 +143,12 @@ public function hostsAction()
$this->applyFilters($query);

$this->setupSortControl(array(
'host_last_check' => 'Last Check',
'host_severity' => 'Severity',
'host_name' => 'Hostname',
'host_address' => 'Address',
'host_state' => 'Current State',
'host_state' => 'Hard State'
'host_last_check' => $this->translate('Last Check'),
'host_severity' => $this->translate('Severity'),
'host_name' => $this->translate('Hostname'),
'host_address' => $this->translate('Address'),
'host_state' => $this->translate('Current State'),
'host_state' => $this->translate('Hard State')
));
$this->view->hosts = $query->paginate();
}
Expand Down Expand Up @@ -220,16 +220,16 @@ public function servicesAction()

$this->applyFilters($query);
$this->setupSortControl(array(
'service_last_check' => 'Last Service Check',
'service_severity' => 'Severity',
'service_state' => 'Current Service State',
'service_description' => 'Service Name',
'service_state_type' => 'Hard State',
'host_severity' => 'Host Severity',
'host_state' => 'Current Host State',
'host_name' => 'Host Name',
'host_address' => 'Host Address',
'host_last_check' => 'Last Host Check'
'service_last_check' => $this->translate('Last Service Check'),
'service_severity' => $this->translate('Severity'),
'service_state' => $this->translate('Current Service State'),
'service_description' => $this->translate('Service Name'),
'service_state_type' => $this->translate('Hard State'),
'host_severity' => $this->translate('Host Severity'),
'host_state' => $this->translate('Current Host State'),
'host_name' => $this->translate('Host Name'),
'host_address' => $this->translate('Host Address'),
'host_last_check' => $this->translate('Last Host Check')
));
$limit = $this->params->get('limit');
$this->view->limit = $limit;
Expand Down Expand Up @@ -291,15 +291,15 @@ public function downtimesAction()
$this->applyFilters($query);
$this->view->downtimes = $query->paginate();
$this->setupSortControl(array(
'downtime_is_in_effect' => 'Is In Effect',
'downtime_host' => 'Host / Service',
'downtime_entry_time' => 'Entry Time',
'downtime_author' => 'Author',
'downtime_start' => 'Start Time',
'downtime_start' => 'End Time',
'downtime_scheduled_start' => 'Scheduled Start',
'downtime_scheduled_end' => 'Scheduled End',
'downtime_duration' => 'Duration',
'downtime_is_in_effect' => $this->translate('Is In Effect'),
'downtime_host' => $this->translate('Host / Service'),
'downtime_entry_time' => $this->translate('Entry Time'),
'downtime_author' => $this->translate('Author'),
'downtime_start' => $this->translate('Start Time'),
'downtime_start' => $this->translate('End Time'),
'downtime_scheduled_start' => $this->translate('Scheduled Start'),
'downtime_scheduled_end' => $this->translate('Scheduled End'),
'downtime_duration' => $this->translate('Duration'),
));
$this->view->delDowntimeForm = new DeleteDowntimeCommandForm();
}
Expand All @@ -322,7 +322,7 @@ public function notificationsAction()
$this->applyFilters($query);
$this->view->notifications = $query->paginate();
$this->setupSortControl(array(
'notification_start_time' => 'Notification Start'
'notification_start_time' => $this->translate('Notification Start')
));
}

Expand Down Expand Up @@ -353,12 +353,12 @@ public function contactsAction()
$this->view->contacts = $query->paginate();

$this->setupSortControl(array(
'contact_name' => 'Name',
'contact_alias' => 'Alias',
'contact_email' => 'Email',
'contact_pager' => 'Pager Address / Number',
'contact_notify_service_timeperiod' => 'Service Notification Timeperiod',
'contact_notify_host_timeperiod' => 'Host Notification Timeperiod'
'contact_name' => $this->translate('Name'),
'contact_alias' => $this->translate('Alias'),
'contact_email' => $this->translate('Email'),
'contact_pager' => $this->translate('Pager Address / Number'),
'contact_notify_service_timeperiod' => $this->translate('Service Notification Timeperiod'),
'contact_notify_host_timeperiod' => $this->translate('Host Notification Timeperiod')
));
}

Expand Down Expand Up @@ -453,10 +453,10 @@ public function commentsAction()

$this->setupSortControl(
array(
'comment_timestamp' => 'Comment Timestamp',
'comment_host' => 'Host / Service',
'comment_type' => 'Comment Type',
'comment_expiration' => 'Expiration',
'comment_timestamp' => $this->translate('Comment Timestamp'),
'comment_host' => $this->translate('Host / Service'),
'comment_type' => $this->translate('Comment Type'),
'comment_expiration' => $this->translate('Expiration'),
)
);
$this->view->delCommentForm = new DeleteCommentCommandForm();
Expand Down Expand Up @@ -489,7 +489,7 @@ public function servicegroupsAction()
$this->applyFilters($query);
$this->view->servicegroups = $query->paginate();
$this->setupSortControl(array(
'servicegroup_name' => 'Servicegroup Name'
'servicegroup_name' => $this->translate('Servicegroup Name')
));
}

Expand Down Expand Up @@ -520,12 +520,16 @@ public function hostgroupsAction()
$this->applyFilters($query);
$this->view->hostgroups = $query->paginate();
$this->setupSortControl(array(
'hostgroup_name' => 'Hostgroup Name'
'hostgroup_name' => $this->translate('Hostgroup Name')
));
}

public function eventhistoryAction()
{
if ($url = $this->hasBetterUrl()) {
return $this->redirectNow($url);
}

$this->addTitleTab('eventhistory');
$query = $this->backend->select()->from('eventHistory', array(
'host_name',
Expand Down Expand Up @@ -561,8 +565,8 @@ public function servicematrixAction()
));
$this->applyFilters($query);
$this->setupSortControl(array(
'host_name' => 'Hostname',
'service_description' => 'Service description'
'host_name' => $this->translate('Hostname'),
'service_description' => $this->translate('Service description')
));
$pivot = $query->pivot('service_description', 'host_name');
$this->view->pivot = $pivot;
Expand Down
24 changes: 12 additions & 12 deletions modules/monitoring/application/controllers/MultiController.php
Expand Up @@ -59,12 +59,12 @@ public function hostAction()

// Handle configuration changes
$this->handleConfigurationForm(array(
'host_passive_checks_enabled' => 'Passive Checks',
'host_active_checks_enabled' => 'Active Checks',
'host_notifications_enabled' => 'Notifications',
'host_event_handler_enabled' => 'Event Handler',
'host_flap_detection_enabled' => 'Flap Detection',
'host_obsessing' => 'Obsessing'
'host_passive_checks_enabled' => $this->translate('Passive Checks'),
'host_active_checks_enabled' => $this->translate('Active Checks'),
'host_notifications_enabled' => $this->translate('Notifications'),
'host_event_handler_enabled' => $this->translate('Event Handler'),
'host_flap_detection_enabled' => $this->translate('Flap Detection'),
'host_obsessing' => $this->translate('Obsessing')
));
}

Expand Down Expand Up @@ -127,12 +127,12 @@ public function serviceAction()
$this->view->errors = $errors;

$this->handleConfigurationForm(array(
'service_passive_checks_enabled' => 'Passive Checks',
'service_active_checks_enabled' => 'Active Checks',
'service_notifications_enabled' => 'Notifications',
'service_event_handler_enabled' => 'Event Handler',
'service_flap_detection_enabled' => 'Flap Detection',
'service_obsessing' => 'Obsessing',
'service_passive_checks_enabled' => $this->translate('Passive Checks'),
'service_active_checks_enabled' => $this->translate('Active Checks'),
'service_notifications_enabled' => $this->translate('Notifications'),
'service_event_handler_enabled' => $this->translate('Event Handler'),
'service_flap_detection_enabled' => $this->translate('Flap Detection'),
'service_obsessing' => $this->translate('Obsessing'),
));
}

Expand Down
Expand Up @@ -9,6 +9,7 @@
use Icinga\Module\Monitoring\Command\Instance\DisableNotificationsExpireCommand;
use Icinga\Module\Monitoring\Form\Command\CommandForm;
use Icinga\Web\Form\Element\DateTimePicker;
use Icinga\Web\Form\Element\Note;
use Icinga\Web\Notification;
use Icinga\Web\Request;

Expand All @@ -33,12 +34,13 @@ public function init()
public function createElements(array $formData = array())
{
$this->addElement(
'note',
'command-info',
array(
'value' => mt(
'monitoring',
'This command is used to disable host and service notifications for a specific time.'
new Note(
'command-info',
array(
'value' => mt(
'monitoring',
'This command is used to disable host and service notifications for a specific time.'
)
)
)
);
Expand Down

0 comments on commit cbadaa7

Please sign in to comment.