Behave nicely when showing notifications not sent out to any contact

I noticed that there is no output shown for the history views in case no
contact has been notified, but time is short atm...

refs #9009
refs #9430
This commit is contained in:
Johannes Meyer 2015-06-16 13:32:35 +02:00
parent bf70ec2802
commit d5f7ee3c56
3 changed files with 7 additions and 2 deletions

View File

@ -31,6 +31,7 @@ if (count($history) === 0) {
case 'notify': case 'notify':
$icon = 'bell'; $icon = 'bell';
$title = $this->translate('Notification'); $title = $this->translate('Notification');
$msg = $msg ?: $this->translate('This notification was not sent out to any contact.');
break; break;
case 'comment': case 'comment':
$icon = 'comment'; $icon = 'comment';

View File

@ -52,6 +52,7 @@ if (count($notifications) === 0) {
<br> <br>
<?php if (! $this->contact): ?> <?php if (! $this->contact): ?>
<small> <small>
<?php if ($notification->notification_contact_name): ?>
<?= sprintf( <?= sprintf(
$this->translate('Sent to %s'), $this->translate('Sent to %s'),
$this->qlink( $this->qlink(
@ -60,6 +61,9 @@ if (count($notifications) === 0) {
array('contact_name' => $notification->notification_contact_name) array('contact_name' => $notification->notification_contact_name)
) )
) ?> ) ?>
<?php else: ?>
<?= $this->translate('This notification was not sent out to any contact.'); ?>
<?php endif ?>
</small> </small>
<?php endif ?> <?php endif ?>
</td> </td>

View File

@ -57,11 +57,11 @@ function contactsLink($match, $view) {
$title = $this->translate('Notification'); $title = $this->translate('Notification');
$stateClass = $isService ? Service::getStateText($event->state) : Host::getStateText($event->state); $stateClass = $isService ? Service::getStateText($event->state) : Host::getStateText($event->state);
$msg = preg_replace_callback( $msg = $msg ? preg_replace_callback(
'/^\[([^\]]+)\]/', '/^\[([^\]]+)\]/',
function($match) use ($self) { return contactsLink($match, $self); }, function($match) use ($self) { return contactsLink($match, $self); },
$msg $msg
); ) : $this->translate('This notification was not sent out to any contact.');
break; break;
case 'comment': case 'comment':
$icon = 'comment'; $icon = 'comment';