2015-06-03 14:56:23 +02:00
|
|
|
<?php
|
2015-08-03 10:58:57 +02:00
|
|
|
$addLink = false;
|
2015-06-03 14:56:23 +02:00
|
|
|
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(
|
2015-09-24 17:58:33 +02:00
|
|
|
'class' => 'action-link',
|
2015-06-03 14:56:23 +02:00
|
|
|
'data-base-target' => '_self',
|
2015-09-24 17:58:33 +02:00
|
|
|
'icon' => 'comment',
|
2015-06-03 14:56:23 +02:00
|
|
|
'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(
|
2015-09-24 17:58:33 +02:00
|
|
|
'class' => 'action-link',
|
2015-06-03 14:56:23 +02:00
|
|
|
'data-base-target' => '_self',
|
2015-09-24 17:58:33 +02:00
|
|
|
'icon' => 'comment',
|
2015-06-03 14:56:23 +02:00
|
|
|
'title' => $this->translate('Add a new comment to this service')
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (empty($object->comments) && ! $addLink) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
?>
|
2014-09-12 16:52:45 +02:00
|
|
|
<tr>
|
2015-06-03 14:56:23 +02:00
|
|
|
<th><?php
|
|
|
|
echo $this->translate('Comments');
|
|
|
|
if (! empty($object->comments) && $addLink) {
|
2015-10-27 16:05:43 +01:00
|
|
|
echo '<br>' . $addLink;
|
2015-06-03 14:56:23 +02:00
|
|
|
}
|
|
|
|
?></th>
|
|
|
|
<td data-base-target="_self">
|
2015-08-03 10:58:57 +02:00
|
|
|
<?php if (empty($object->comments)):
|
|
|
|
echo $addLink;
|
|
|
|
else: ?>
|
2015-10-27 16:05:43 +01:00
|
|
|
<dl class="comment-list">
|
|
|
|
<?php foreach ($object->comments as $comment): ?>
|
|
|
|
<dt class="comment-header">
|
2015-09-25 10:58:45 +02:00
|
|
|
<?= $this->escape($comment->author) ?>
|
2015-10-27 16:05:43 +01:00
|
|
|
<span class="comment-meta">
|
|
|
|
<?= $this->translate('commented') ?>
|
|
|
|
<?= $this->timeAgo($comment->timestamp) ?>
|
|
|
|
<?php if (isset($delCommentForm)): // Form is unset if the current user lacks the respective permission ?>
|
|
|
|
<span class="meta-icons">
|
|
|
|
<?php
|
|
|
|
$deleteButton = clone($delCommentForm);
|
|
|
|
/** @var \Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm $deleteButton */
|
2015-10-28 09:56:50 +01:00
|
|
|
$deleteButton->setAttrib('class', $deleteButton->getAttrib('class') . ' remove-action');
|
2015-10-27 16:05:43 +01:00
|
|
|
$deleteButton->populate(
|
|
|
|
array(
|
|
|
|
'comment_id' => $comment->id,
|
|
|
|
'comment_is_service' => isset($comment->service_description)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
echo $deleteButton;
|
|
|
|
?>
|
|
|
|
</span>
|
|
|
|
<?php endif ?>
|
|
|
|
</span>
|
2015-09-25 10:58:45 +02:00
|
|
|
</dt>
|
2015-10-01 02:58:29 +02:00
|
|
|
<dd class="comment-text">
|
2015-11-03 10:40:03 +01:00
|
|
|
<p><?= nl2br($this->createTicketLinks($this->escape($comment->comment)), false) ?></p>
|
2015-09-25 10:58:45 +02:00
|
|
|
</dd>
|
2015-08-03 10:58:57 +02:00
|
|
|
<?php endforeach ?>
|
2015-09-25 10:58:45 +02:00
|
|
|
</dl>
|
2015-08-03 10:58:57 +02:00
|
|
|
<?php endif ?>
|
2015-06-03 14:56:23 +02:00
|
|
|
</td>
|
|
|
|
</tr>
|