[icinga-checkins] icinga.org: icingaweb2/master: Respect permission for check now on multiple services

git at icinga.org git at icinga.org
Wed Feb 24 15:02:01 CET 2016


Module: icingaweb2
Branch: master
Commit: d257c71c5403af5bf27bdd693db88beab525ae18
URL:    https://git.icinga.org/?p=icingaweb2.git;a=commit;h=d257c71c5403af5bf27bdd693db88beab525ae18

Author: Alexander A. Klimov <alexander.klimov at netways.de>
Date:   Fri Feb 12 16:39:06 2016 +0100

Respect permission for check now on multiple services

refs #10397

---

 .../application/controllers/ServicesController.php         |   12 +++++++-----
 .../application/views/scripts/services/show.phtml          |   10 ++++++----
 2 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/modules/monitoring/application/controllers/ServicesController.php b/modules/monitoring/application/controllers/ServicesController.php
index 31db675..9d4c9a4 100644
--- a/modules/monitoring/application/controllers/ServicesController.php
+++ b/modules/monitoring/application/controllers/ServicesController.php
@@ -90,11 +90,13 @@ class ServicesController extends Controller
     public function showAction()
     {
         $this->setAutorefreshInterval(15);
-        $checkNowForm = new CheckNowCommandForm();
-        $checkNowForm
-            ->setObjects($this->serviceList)
-            ->handleRequest();
-        $this->view->checkNowForm = $checkNowForm;
+        if ($this->Auth()->hasPermission('monitoring/command/schedule-check')) {
+            $checkNowForm = new CheckNowCommandForm();
+            $checkNowForm
+                ->setObjects($this->serviceList)
+                ->handleRequest();
+            $this->view->checkNowForm = $checkNowForm;
+        }
 
         $acknowledgedObjects = $this->serviceList->getAcknowledgedObjects();
         if (! empty($acknowledgedObjects)) {
diff --git a/modules/monitoring/application/views/scripts/services/show.phtml b/modules/monitoring/application/views/scripts/services/show.phtml
index 167016b..f20a011 100644
--- a/modules/monitoring/application/views/scripts/services/show.phtml
+++ b/modules/monitoring/application/views/scripts/services/show.phtml
@@ -176,10 +176,12 @@
                 </td>
             </tr>
 
-            <tr>
-                <th> <?= $this->translate('Schedule Check') ?> </th>
-                <td> <?= $checkNowForm ?> </td>
-            </tr>
+            <?php if (isset($checkNowForm)): // Form is unset if the current user lacks the respective permission ?>
+                <tr>
+                    <th> <?= $this->translate('Schedule Check') ?> </th>
+                    <td> <?= $checkNowForm ?> </td>
+                </tr>
+            <?php endif ?>
 
             <tr>
                 <th></th>



More information about the icinga-checkins mailing list