Skip to content

Commit

Permalink
Do not display Log tab if user do not have right to see logs
Browse files Browse the repository at this point in the history
  • Loading branch information
tsmr authored and cedric-anne committed Nov 15, 2023
1 parent 3a492b4 commit 0fed4fa
Show file tree
Hide file tree
Showing 11 changed files with 9 additions and 12 deletions.
7 changes: 7 additions & 0 deletions src/Log.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ public static function getTypeName($nb = 0)

public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0)
{
if (!self::canView()) {
return '';
}

$nb = 0;
if ($_SESSION['glpishow_count_on_tabs']) {
Expand Down Expand Up @@ -299,6 +302,10 @@ public static function showForItem(CommonDBTM $item, $withtemplate = 0)
/** @var array $CFG_GLPI */
global $CFG_GLPI;

if (!self::canView()) {
return;
}

$itemtype = $item->getType();
$items_id = $item->getField('id');

Expand Down
4 changes: 2 additions & 2 deletions tests/LDAP/AuthLdap.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,8 @@ public function testDefineTabs()
{
$ldap = new \AuthLDAP();
$tabs = $ldap->defineTabs();
$expected = ['AuthLDAP$main' => 'LDAP directory',
'Log$1' => 'Historical'
$expected = [
'AuthLDAP$main' => 'LDAP directory',
];
$this->array($tabs)->isIdenticalTo($expected);
}
Expand Down
1 change: 0 additions & 1 deletion tests/functional/Agent.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ public function testDefineTabs()
$expected = [
'Agent$main' => 'Agent',
'RuleMatchedLog$0' => 'Import information',
'Log$1' => 'Historical'
];
$this
->given($this->newTestedInstance)
Expand Down
1 change: 0 additions & 1 deletion tests/functional/Appliance.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ public function testDefineTabs()
'Appliance$main' => 'Appliance',
'Impact$1' => 'Impact analysis',
'ManualLink$1' => 'Links',
'Log$1' => 'Historical',
];
$this
->given($this->newTestedInstance)
Expand Down
1 change: 0 additions & 1 deletion tests/functional/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ public function testDefineTabs()
'Config$4' => 'Assistance',
'Config$12' => 'Management',
'GLPINetwork$1' => 'GLPI Network',
'Log$1' => 'Historical',
];
$this
->given($this->newTestedInstance)
Expand Down
2 changes: 0 additions & 2 deletions tests/functional/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,6 @@ public function testDefineTabs()
'Document$main' => 'Document',
'Document_Item$1' => 'Associated items',
'Document_Item$2' => 'Documents',
'Log$1' => 'Historical'

];
$this
->given($this->newTestedInstance)
Expand Down
1 change: 0 additions & 1 deletion tests/functional/OperatingSystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ protected function getTabs()
{
return [
'OperatingSystem$main' => 'Operating system',
'Log$1' => 'Historical'
];
}

Expand Down
1 change: 0 additions & 1 deletion tests/functional/OperatingSystemArchitecture.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ protected function getTabs()
{
return [
'OperatingSystemArchitecture$main' => 'Operating system architecture',
'Log$1' => 'Historical'
];
}

Expand Down
1 change: 0 additions & 1 deletion tests/functional/OperatingSystemEdition.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ protected function getTabs()
{
return [
'OperatingSystemEdition$main' => 'Edition',
'Log$1' => 'Historical'
];
}

Expand Down
1 change: 0 additions & 1 deletion tests/functional/OperatingSystemKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ protected function getTabs()
{
return [
'OperatingSystemKernel$main' => 'Kernel',
'Log$1' => 'Historical'
];
}

Expand Down
1 change: 0 additions & 1 deletion tests/functional/OperatingSystemKernelVersion.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ protected function getTabs()
{
return [
'OperatingSystemKernelVersion$main' => 'Kernel version',
'Log$1' => 'Historical'
];
}

Expand Down

0 comments on commit 0fed4fa

Please sign in to comment.