Skip to content

Commit

Permalink
fix(core): prevent error when check container rights
Browse files Browse the repository at this point in the history
  • Loading branch information
stonebuzz committed Sep 5, 2023
1 parent d5a5f48 commit 3d90d1e
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions inc/container.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1032,11 +1032,18 @@ public static function getEntries($type = 'tab', $full = false)
continue;
}
//profiles restriction
$right = PluginFieldsProfile::getRightOnContainer($_SESSION['glpiactiveprofile']['id'], $item['id']);
if ($right < READ) {
continue;

if (isset($_SESSION['glpiactiveprofile']['id']) && $_SESSION['glpiactiveprofile']['id'] != null && $item['id'] > 0) {
$right = PluginFieldsProfile::getRightOnContainer($_SESSION['glpiactiveprofile']['id'], $item['id']);
if ($right < READ) {
return false;
}
} else {
return false;
}



$jsonitemtypes = json_decode($item['itemtypes']);
//show more info or not
foreach ($jsonitemtypes as $v) {
Expand Down Expand Up @@ -1538,7 +1545,7 @@ public static function findContainer($itemtype, $type = 'tab', $subtype = '')
}

//profiles restriction
if (isset($_SESSION['glpiactiveprofile']['id']) && $id > 0) {
if (isset($_SESSION['glpiactiveprofile']['id']) && $_SESSION['glpiactiveprofile']['id'] != null && $id > 0) {
$right = PluginFieldsProfile::getRightOnContainer($_SESSION['glpiactiveprofile']['id'], $id);
if ($right < READ) {
return false;
Expand Down Expand Up @@ -1630,11 +1637,17 @@ public static function preItem(CommonDBTM $item)
$loc_c->getFromDB($c_id);

// check rights on $c_id
$right = PluginFieldsProfile::getRightOnContainer($_SESSION['glpiactiveprofile']['id'], $c_id);
if (($right > READ) === false) {

if (isset($_SESSION['glpiactiveprofile']['id']) && $_SESSION['glpiactiveprofile']['id'] != null && $c_id > 0) {
$right = PluginFieldsProfile::getRightOnContainer($_SESSION['glpiactiveprofile']['id'], $c_id);
if (($right > READ) === false) {
return;
}
} else {
return;
}


// need to check if container is usable on this object entity
$entities = [$loc_c->fields['entities_id']];
if ($loc_c->fields['is_recursive']) {
Expand Down

0 comments on commit 3d90d1e

Please sign in to comment.