Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): prevent error when check contaier rights #699

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading