diff --git a/inc/abstractcontainerinstance.class.php b/inc/abstractcontainerinstance.class.php index 2fd73bc1..6a68cb3c 100644 --- a/inc/abstractcontainerinstance.class.php +++ b/inc/abstractcontainerinstance.class.php @@ -31,39 +31,12 @@ abstract class PluginFieldsAbstractContainerInstance extends CommonDBTM { - /** - * Checks if the HTTP request targets an object with an ID. - * - * This function determines whether the path contains an ID as the last segment - * (i.e., a number after the final '/'). - * - * @param string $path The HTTP request path (e.g., $_SERVER['PATH_INFO']). - * @return mixed Returns ID if is present in the path, null otherwise. - */ - public static function hasRequestedObjectId(string $path): ?int - { - if (preg_match('#/(\d+)$#', $path, $matches)) { - return (int)$matches[1]; - } - return null; - } - - public static function canView() - { - $want_all = self::hasRequestedObjectId($_SERVER['PATH_INFO']); - if (isAPI() && ($want_all == null)) { - return false; - } - - return parent::canView(); - } - public function canViewItem() { //check if current user have access to the main item entity $item = new $this->fields['itemtype'](); $item->getFromDB($this->fields['items_id']); - if (!Session::haveAccessToEntity($item->getEntityID(), $item->isRecursive())) { + if ($item->isEntityAssign() && !Session::haveAccessToEntity($item->getEntityID(), $item->isRecursive())) { return false; } $right = PluginFieldsProfile::getRightOnContainer($_SESSION['glpiactiveprofile']['id'], $this->fields['plugin_fields_containers_id']); @@ -78,7 +51,7 @@ public function canUpdateItem() //check if current user have access to the main item entity $item = new $this->fields['itemtype'](); $item->getFromDB($this->fields['items_id']); - if (!Session::haveAccessToEntity($item->getEntityID(), $item->isRecursive())) { + if ($item->isEntityAssign() && !Session::haveAccessToEntity($item->getEntityID(), $item->isRecursive())) { return false; } $right = PluginFieldsProfile::getRightOnContainer($_SESSION['glpiactiveprofile']['id'], $this->fields['plugin_fields_containers_id']);