From 9fadb5c1d679c4f267b5de0430e7797902c9db40 Mon Sep 17 00:00:00 2001 From: patrickpr Date: Thu, 22 Aug 2019 14:56:44 +0200 Subject: [PATCH] Small enhancements --- application/controllers/ReceivedController.php | 2 +- application/controllers/SettingsController.php | 10 ++++------ application/views/scripts/handler/index.phtml | 2 +- application/views/scripts/settings/index.phtml | 14 +++++++++++++- library/Trapdirector/Tables/TrapTable.php | 2 +- .../Trapdirector/Tables/TrapTableHostList.php | 5 ++--- library/Trapdirector/TrapsController.php | 16 +++++++++++++--- 7 files changed, 35 insertions(+), 16 deletions(-) diff --git a/application/controllers/ReceivedController.php b/application/controllers/ReceivedController.php index d5d2bd8..1b822ee 100644 --- a/application/controllers/ReceivedController.php +++ b/application/controllers/ReceivedController.php @@ -38,7 +38,7 @@ public function indexAction() } - /** TODO : after SQL code from Handler controller put in trapsController, + /** TODO : put SQL code in trapsController, * use the getTrapDetail / getTrapObject functions */ public function trapdetailAction() diff --git a/application/controllers/SettingsController.php b/application/controllers/SettingsController.php index 0e9104a..290465b 100644 --- a/application/controllers/SettingsController.php +++ b/application/controllers/SettingsController.php @@ -19,10 +19,10 @@ class SettingsController extends TrapsController { public function indexAction() { - //TODO : let error DB show without permissions but dont allow configuration form. - //TODO : also check ido database as set on this page. - //TODO : $this->checkModuleConfigPermission(); - + // CHeck permissions : display tests in any case, but no configuration. + $this->view->configPermission=$this->checkModuleConfigPermission(1); + // But check read permission + $this->checkReadPermission(); // Get message : sent on configuration problems detected by controllers $this->view->errorDetected=$this->params->get('dberror'); @@ -94,8 +94,6 @@ public function indexAction() $this->view->form = $form = new TrapsConfigForm(); $this->view->form->setPaths($this->Module()->getBaseDir(),Icinga::app()->getConfigDir()); - //$form->setRedirectUrl('trapdirector/status'); - //echo $form->getRedirectUrl(); // Setup path for mini documentation $this->view->traps_in_config= PHP_BINARY . ' ' . $this->Module()->getBaseDir() . '/bin/trap_in.php'; diff --git a/application/views/scripts/handler/index.phtml b/application/views/scripts/handler/index.phtml index 2b98c73..e309ef9 100644 --- a/application/views/scripts/handler/index.phtml +++ b/application/views/scripts/handler/index.phtml @@ -13,7 +13,7 @@ 'title' => $this->translate('Create a new trap service') )) ?> - filterEditor // TODO : implement filters ?>
+
table->getPaginator(); ?> diff --git a/application/views/scripts/settings/index.phtml b/application/views/scripts/settings/index.phtml index fc1a428..755bdfb 100644 --- a/application/views/scripts/settings/index.phtml +++ b/application/views/scripts/settings/index.phtml @@ -41,6 +41,14 @@ } ?>
+ + + configPermission) + { + ?> +
@@ -93,6 +101,10 @@ object ApiUser "trapdirector" {

Enjoy !

- + + diff --git a/library/Trapdirector/Tables/TrapTable.php b/library/Trapdirector/Tables/TrapTable.php index f98c8f9..bc2ffb2 100644 --- a/library/Trapdirector/Tables/TrapTable.php +++ b/library/Trapdirector/Tables/TrapTable.php @@ -209,7 +209,7 @@ public function getFilterEditor(Request $request) } protected function renderFilter($filter) - { // TODO + { // TODO : create a better filter wher user can choose host/oid to filter } protected function applyFiltersToQuery($query) diff --git a/library/Trapdirector/Tables/TrapTableHostList.php b/library/Trapdirector/Tables/TrapTableHostList.php index 0cd20a5..36f7a35 100644 --- a/library/Trapdirector/Tables/TrapTableHostList.php +++ b/library/Trapdirector/Tables/TrapTableHostList.php @@ -8,9 +8,8 @@ use Icinga\Web\Widget; use Icinga\Web\Widget\Paginator; -use Icinga\Module\Trapdirector\Tables\TrapTable; - +use Icinga\Module\Trapdirector\Tables\TrapTable; class TrapTableHostList extends TrapTable @@ -141,7 +140,7 @@ public function render() } public function count() - { // TODO : not tested + { $db=$this->db(); $query = $this->getBaseQuery(); diff --git a/library/Trapdirector/TrapsController.php b/library/Trapdirector/TrapsController.php index bd0adf3..a652206 100644 --- a/library/Trapdirector/TrapsController.php +++ b/library/Trapdirector/TrapsController.php @@ -188,11 +188,21 @@ protected function checkConfigPermission() } } - protected function checkModuleConfigPermission() + /** + * Check if user has write permission + * @param number $check optional : if set to 1, return true (user has permission) or false instead of displaying error page + * @return boolean : user has permission + */ + protected function checkModuleConfigPermission($check=0) { if (! $this->Auth()->hasPermission('trapdirector/module_config')) { - $this->displayExitError('Permissions','No permission fo configure module'); - } + if ($check == 0) + { + $this->displayExitError('Permissions','No permission fo configure module'); + } + return false; + } + return true; } /************************* Trap class get **********************/