HostsController: Don't allow to reschedule checks if no objects have active ones

refs #3665
This commit is contained in:
Johannes Meyer 2019-02-01 13:31:35 +01:00
parent 3d4fa0bcae
commit f45b4640b0
2 changed files with 12 additions and 3 deletions

View File

@ -85,7 +85,12 @@ class HostsController extends Controller
public function showAction()
{
$this->setAutorefreshInterval(15);
if ($this->Auth()->hasPermission('monitoring/command/schedule-check')) {
$activeChecksEnabled = $this->hostList->getFeatureStatus()['active_checks_enabled'] !== 0;
if ($this->Auth()->hasPermission('monitoring/command/schedule-check')
|| ($this->Auth()->hasPermission('monitoring/command/schedule-check/active-only')
&& $activeChecksEnabled
)
) {
$checkNowForm = new CheckNowCommandForm();
$checkNowForm
->setObjects($this->hostList)
@ -114,8 +119,10 @@ class HostsController extends Controller
$hostStates = $this->hostList->getStateSummary();
$this->setAutorefreshInterval(15);
$this->view->rescheduleAllLink = Url::fromRequest()->setPath('monitoring/hosts/reschedule-check');
if ($activeChecksEnabled) {
$this->view->rescheduleAllLink = Url::fromRequest()->setPath('monitoring/hosts/reschedule-check');
}
$this->view->downtimeAllLink = Url::fromRequest()->setPath('monitoring/hosts/schedule-downtime');
$this->view->processCheckResultAllLink = Url::fromRequest()->setPath('monitoring/hosts/process-check-result');
$this->view->addCommentLink = Url::fromRequest()->setPath('monitoring/hosts/add-comment');

View File

@ -181,6 +181,7 @@
</tr>
<?php endif ?>
<?php if (isset($rescheduleAllLink)): ?>
<tr>
<th></th>
<td>
@ -195,6 +196,7 @@
) ?>
</td>
</tr>
<?php endif ?>
</tbody>
</table>
<h2><?= $this->translate('Feature Commands') ?></h2>