80 lines
2.9 KiB
PHTML
80 lines
2.9 KiB
PHTML
<?php
|
|
$addLink = false;
|
|
if ($this->hasPermission('monitoring/command/comment/add')) {
|
|
/** @var \Icinga\Module\Monitoring\Object\MonitoredObject $object */
|
|
if ($object->getType() === $object::TYPE_HOST) {
|
|
$addLink = $this->qlink(
|
|
$this->translate('Add comment'),
|
|
'monitoring/host/add-comment',
|
|
array('host' => $object->getName()),
|
|
array(
|
|
'class' => 'action-link',
|
|
'data-base-target' => '_self',
|
|
'icon' => 'comment',
|
|
'title' => $this->translate('Add a new comment to this host')
|
|
)
|
|
);
|
|
} else {
|
|
$addLink = $this->qlink(
|
|
$this->translate('Add comment'),
|
|
'monitoring/service/add-comment',
|
|
array('host' => $object->getHost()->getName(), 'service' => $object->getName()),
|
|
array(
|
|
'class' => 'action-link',
|
|
'data-base-target' => '_self',
|
|
'icon' => 'comment',
|
|
'title' => $this->translate('Add a new comment to this service')
|
|
)
|
|
);
|
|
}
|
|
}
|
|
if (empty($object->comments) && ! $addLink) {
|
|
return;
|
|
}
|
|
?>
|
|
<tr>
|
|
<th><?php
|
|
echo $this->translate('Comments');
|
|
if (! empty($object->comments) && $addLink) {
|
|
echo '<br />' . $addLink;
|
|
}
|
|
?></th>
|
|
<td data-base-target="_self">
|
|
<?php if (empty($object->comments)):
|
|
echo $addLink;
|
|
else: ?>
|
|
<dl class="feed-list">
|
|
<?php foreach ($object->comments as $comment):
|
|
// Form is unset if the current user lacks the respective permission
|
|
if (isset($delCommentForm)) {
|
|
$deleteButton = clone($delCommentForm);
|
|
/** @var \Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm $deleteButton */
|
|
$deleteButton->setAttrib('class', $deleteButton->getAttrib('class') . ' pull-right');
|
|
$deleteButton->populate(
|
|
array(
|
|
'comment_id' => $comment->id,
|
|
'comment_is_service' => isset($comment->service_description)
|
|
)
|
|
);
|
|
} else {
|
|
$deleteButton = '';
|
|
}
|
|
?>
|
|
<dt class="feed-author">
|
|
<?= $this->escape($comment->author) ?>
|
|
<?= $this->timeAgo($comment->timestamp) ?>
|
|
<?php if ($deleteButton): ?>
|
|
<span class="clearfix">
|
|
<?= $deleteButton ?>
|
|
</span>
|
|
<?php endif ?>
|
|
</dt>
|
|
<dd>
|
|
<?= str_replace(array('\r\n', '\n'), '<br>', $this->createTicketLinks($comment->comment)) ?>
|
|
</dd>
|
|
<?php endforeach ?>
|
|
</dl>
|
|
<?php endif ?>
|
|
</td>
|
|
</tr>
|