icingaweb2/modules/monitoring/application/views/scripts/show/components/comments.phtml

69 lines
2.6 KiB
PHTML

<tr>
<th><?= $this->translate('Comments'); ?></th>
<td>
<?php if ($this->hasPermission('monitoring/command/comment/add')) {
/** @type \Icinga\Module\Monitoring\Object\MonitoredObject $object */
if ($object->getType() === $object::TYPE_HOST) {
echo $this->qlink(
$this->icon('comment') . ' ' . $this->translate('Add comment'),
'monitoring/host/add-comment',
array('host' => $object->getName()),
array(
'data-base-target' => '_self',
'title' => $this->translate('Add a new comment to this host')
),
false
);
} else {
echo $this->qlink(
$this->icon('comment') . ' ' . $this->translate('Add comment'),
'monitoring/service/add-comment',
array('host' => $object->getHost()->getName(), 'service' => $object->getName()),
array(
'data-base-target' => '_self',
'title' => $this->translate('Add a new comment to this service')
),
false
);
}
} else {
echo '&#45;';
} ?>
</td>
</tr>
<?php
foreach ($object->comments as $comment) {
// Ticket hook sample
$commentText = $this->tickets ? preg_replace_callback(
$this->tickets->getPattern(),
array($this->tickets, 'createLink'),
$this->escape($comment->comment)
) : $this->escape($comment->comment);
?>
<tr>
<th><?= $this->escape($comment->author) ?> (<?= $this->timeSince($comment->timestamp) ?>)</th>
<td>
<table>
<tr>
<td style="vertical-align: top;" data-base-target="_self">
<?php if (isset($delCommentForm)) { // Form is unset if the current user lacks the respective permission
$delCommentForm = clone $delCommentForm;
$delCommentForm->populate(array('comment_id' => $comment->id));
echo $delCommentForm;
} ?>
(<?= ucfirst($comment->type) ?>):
</td>
<td style="padding-left: .5em;">
<?= nl2br($commentText) ?>
</td>
</tr>
</table>
</td>
</tr>
<?php } // endforeach ?>