monitoring/security: Hide 'Check Now' action if user lacks the respective permission

This commit is contained in:
Eric Lippmann 2015-01-22 17:13:35 +01:00
parent 44de790cc9
commit a09ba15859
2 changed files with 11 additions and 6 deletions

View File

@ -23,7 +23,9 @@ if ($object->getType() === $object::TYPE_HOST) {
<tr>
<th><?= $this->translate('Last check') ?></th>
<td data-base-target="_self">
<?= $checkNowForm ?>
<?php if (isset($checkNowForm)) { // Form is unset if the current user lacks the respective permission
echo $checkNowForm;
} ?>
<?= $this->timeSince($object->last_check) ?>
</td>
</tr>

View File

@ -57,11 +57,14 @@ abstract class MonitoredObjectController extends Controller
public function showAction()
{
$this->setAutorefreshInterval(10);
$checkNowForm = new CheckNowCommandForm();
$checkNowForm
->setObjects($this->object)
->handleRequest();
$this->view->checkNowForm = $checkNowForm;
$auth = $this->Auth();
if ($auth->hasPermission('monitoring/command/schedule-check')) {
$checkNowForm = new CheckNowCommandForm();
$checkNowForm
->setObjects($this->object)
->handleRequest();
$this->view->checkNowForm = $checkNowForm;
}
if ( ! in_array((int) $this->object->state, array(0, 99))) {
if ((bool) $this->object->acknowledged) {
$removeAckForm = new RemoveAcknowledgementCommandForm();