Skip to content

Commit

Permalink
fix(entityconfig): do not show Formcreator tab if no right
Browse files Browse the repository at this point in the history
Signed-off-by: Thierry Bugier <tbugier@teclib.com>
  • Loading branch information
btry committed Jul 29, 2021
1 parent 31ccd9b commit 452f682
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion front/entityconfig.form.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')) {
Expand Down
2 changes: 1 addition & 1 deletion inc/entityconfig.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}
Expand Down
7 changes: 7 additions & 0 deletions tests/3-unit/PluginFormcreatorEntityConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 [
[
Expand Down

0 comments on commit 452f682

Please sign in to comment.