monitoring/security: Hide 'Remove Problem Acknowledgement' action if user lacks the respective permission

This commit is contained in:
Eric Lippmann 2015-01-22 17:25:30 +01:00
parent a09ba15859
commit f46a587266
2 changed files with 14 additions and 6 deletions

View File

@ -22,7 +22,13 @@ if ($object->getType() === $object::TYPE_HOST) {
if ($object->acknowledged): ?> if ($object->acknowledged): ?>
<tr> <tr>
<th><?= $this->translate('Acknowledged') ?></th> <th><?= $this->translate('Acknowledged') ?></th>
<td><?= $removeAckForm ?></td> <td>
<?php if (isset($removeAckForm)) { // Form is unset if the current user lacks the respective permission
echo $removeAckForm;
} else {
echo '&#45;';
} ?>
</td>
</tr> </tr>
<?php else: ?> <?php else: ?>
<tr> <tr>

View File

@ -67,11 +67,13 @@ abstract class MonitoredObjectController extends Controller
} }
if ( ! in_array((int) $this->object->state, array(0, 99))) { if ( ! in_array((int) $this->object->state, array(0, 99))) {
if ((bool) $this->object->acknowledged) { if ((bool) $this->object->acknowledged) {
$removeAckForm = new RemoveAcknowledgementCommandForm(); if ($auth->hasPermission('monitoring/command/remove-acknowledgement')) {
$removeAckForm $removeAckForm = new RemoveAcknowledgementCommandForm();
->setObjects($this->object) $removeAckForm
->handleRequest(); ->setObjects($this->object)
$this->view->removeAckForm = $removeAckForm; ->handleRequest();
$this->view->removeAckForm = $removeAckForm;
}
} else { } else {
$ackForm = new AcknowledgeProblemCommandForm(); $ackForm = new AcknowledgeProblemCommandForm();
$ackForm $ackForm