From 452f6825d431acf148583cbc7987a48b286f0903 Mon Sep 17 00:00:00 2001 From: Thierry Bugier Date: Thu, 29 Jul 2021 15:51:17 +0200 Subject: [PATCH] fix(entityconfig): do not show Formcreator tab if no right Signed-off-by: Thierry Bugier --- front/entityconfig.form.php | 2 +- inc/entityconfig.class.php | 2 +- tests/3-unit/PluginFormcreatorEntityConfig.php | 7 +++++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/front/entityconfig.form.php b/front/entityconfig.form.php index f618cb782..3f786db13 100644 --- a/front/entityconfig.form.php +++ b/front/entityconfig.form.php @@ -31,7 +31,7 @@ include ('../../../inc/includes.php'); -Session::checkRight("entity", UPDATE); +Session::checkRight('entity', UPDATE); // Check if plugin is activated... if (!(new Plugin())->isActivated('formcreator')) { diff --git a/inc/entityconfig.class.php b/inc/entityconfig.class.php index 20aa4e851..7acc95f4c 100644 --- a/inc/entityconfig.class.php +++ b/inc/entityconfig.class.php @@ -65,7 +65,7 @@ class PluginFormcreatorEntityconfig extends CommonDBTM { public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) { $tabNames = []; if (!$withtemplate) { - if ($item->getType() == 'Entity') { + if (Session::haveRight(Entity::$rightname, UPDATE) && $item->getType() == Entity::getType()) { $tabNames[1] = _n('Form', 'Forms', 2, 'formcreator'); } } diff --git a/tests/3-unit/PluginFormcreatorEntityConfig.php b/tests/3-unit/PluginFormcreatorEntityConfig.php index de7e052fd..316148d5d 100644 --- a/tests/3-unit/PluginFormcreatorEntityConfig.php +++ b/tests/3-unit/PluginFormcreatorEntityConfig.php @@ -32,6 +32,13 @@ use GlpiPlugin\Formcreator\Tests\CommonTestCase; class PluginFormcreatorEntityconfig extends CommonTestCase { + public function beforeTestMethod($method) { + switch ($method) { + case 'testGetTabNameForItem': + $this->login('glpi', 'glpi'); + } + } + public function providerGetTabNameForItem() { return [ [