Skip to content

Commit

Permalink
Small enhancements
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickpr committed Aug 22, 2019
1 parent 30c98c9 commit 9fadb5c
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 16 deletions.
2 changes: 1 addition & 1 deletion application/controllers/ReceivedController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
10 changes: 4 additions & 6 deletions application/controllers/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion application/views/scripts/handler/index.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
'title' => $this->translate('Create a new trap service')
))
?>
<?php //$this->filterEditor // TODO : implement filters ?> <br />
<br />
<?= $this->table->getPaginator(); ?>

</div>
Expand Down
14 changes: 13 additions & 1 deletion application/views/scripts/settings/index.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@
}
?>
<br/>


<?php
// **************** If user has no config permission, don't display form & install instructions *************
if ($this->configPermission)
{
?>

<?= /** @var \Icinga\Module\Trapdirector\Forms\TrapsConfigForm $form */ $form ?>
<hr>

Expand Down Expand Up @@ -93,6 +101,10 @@ object ApiUser "trapdirector" {
</li>
</ul>
<p> Enjoy ! </p>


<?php
// **************** End of user configuration permission test *************
}
?>

</div>
2 changes: 1 addition & 1 deletion library/Trapdirector/Tables/TrapTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 2 additions & 3 deletions library/Trapdirector/Tables/TrapTableHostList.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -141,7 +140,7 @@ public function render()
}

public function count()
{ // TODO : not tested
{
$db=$this->db();

$query = $this->getBaseQuery();
Expand Down
16 changes: 13 additions & 3 deletions library/Trapdirector/TrapsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 **********************/
Expand Down

0 comments on commit 9fadb5c

Please sign in to comment.