monitoring: Do not generate 'Schedule downtime' and 'Add comment' links if user lacks the respective permissions

This commit is contained in:
Eric Lippmann 2015-01-23 10:15:55 +01:00
parent d07e1329e8
commit af2698b075
2 changed files with 32 additions and 42 deletions

View File

@ -1,32 +1,27 @@
<tr>
<th><?= $this->translate('Comments') ?></th>
<td>
<?php
/** @type \Icinga\Module\Monitoring\Object\MonitoredObject $object */
if ($object->getType() === $object::TYPE_HOST) {
$addCommentLink = $this->href(
'monitoring/host/add-comment',
array('host' => $object->getName())
);
} else {
$addCommentLink = $this->href(
'monitoring/service/add-comment',
array('host' => $object->getHost()->getName(), 'service' => $object->getName())
);
}
<?php if ($this->hasPermission('monitoring/command/comment/add')) {
/** @type \Icinga\Module\Monitoring\Object\MonitoredObject $object */
if ($object->getType() === $object::TYPE_HOST) {
$addCommentLink = $this->href(
'monitoring/host/add-comment',
array('host' => $object->getName())
);
} else {
$addCommentLink = $this->href(
'monitoring/service/add-comment',
array('host' => $object->getHost()->getName(), 'service' => $object->getName())
);
}
?>
<?php if ($this->hasPermission('monitoring/command/comment/add')): ?>
<a href="<?= $addCommentLink ?>">
<?= $this->icon('comment') ?>
<?= $this->translate('Add comment') ?>
</a>
<?php else: ?>
<?= '&#45;' ?>
<?php endif ?>
<?php } else {
echo '&#45;';
} ?>
</td>
</tr>

View File

@ -1,32 +1,27 @@
<tr>
<th><?= $this->translate('Downtimes') ?></th>
<td>
<?php
/** @type \Icinga\Module\Monitoring\Object\MonitoredObject $object */
if ($object->getType() === $object::TYPE_HOST) {
$scheduleDowntimeLink = $this->href(
'monitoring/host/schedule-downtime',
array('host' => $object->getName())
);
} else {
$scheduleDowntimeLink = $this->href(
'monitoring/service/schedule-downtime',
array('host' => $object->getHost()->getName(), 'service' => $object->getName())
);
}
<?php if ($this->hasPermission('monitoring/command/downtime/schedule')) {
/** @type \Icinga\Module\Monitoring\Object\MonitoredObject $object */
if ($object->getType() === $object::TYPE_HOST) {
$scheduleDowntimeLink = $this->href(
'monitoring/host/schedule-downtime',
array('host' => $object->getName())
);
} else {
$scheduleDowntimeLink = $this->href(
'monitoring/service/schedule-downtime',
array('host' => $object->getHost()->getName(), 'service' => $object->getName())
);
}
?>
<?php if ($this->hasPermission('monitoring/command/downtime/schedule')): ?>
<a href="<?= $scheduleDowntimeLink ?>">
<?= $this->icon('plug') ?>
<?= $this->translate('Schedule downtime') ?>
</a>
<?php else: ?>
<?= '&#45;' ?>
<?php endif ?>
<?php } else {
echo '&#45;';
} ?>
</td>
</tr>