Skip to content

Commit

Permalink
move back to CommonDBTM
Browse files Browse the repository at this point in the history
  • Loading branch information
stonebuzz committed Nov 21, 2024
1 parent 32375cb commit 3be20ed
Showing 1 changed file with 30 additions and 2 deletions.
32 changes: 30 additions & 2 deletions inc/abstractcontainerinstance.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,14 @@
* -------------------------------------------------------------------------
*/

abstract class PluginFieldsAbstractContainerInstance extends CommonDBChild
abstract class PluginFieldsAbstractContainerInstance extends CommonDBTM
{

public static $undisclosedFields = [];

public static $itemtype = 'itemtype';
public static $items_id = 'items_id';


/**
* Checks if the HTTP request targets an object with an ID.
*
Expand Down Expand Up @@ -64,6 +63,35 @@ public static function canView()
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())) {
return false;
}
$right = PluginFieldsProfile::getRightOnContainer($_SESSION['glpiactiveprofile']['id'], $this->fields['plugin_fields_containers_id']);
if ($right < READ) {
return false;
}
return true;
}

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())) {
return false;
}
$right = PluginFieldsProfile::getRightOnContainer($_SESSION['glpiactiveprofile']['id'], $this->fields['plugin_fields_containers_id']);
if ($right > READ) {
return true;
}
return false;
}
public function canPurgeItem()
{
return false;
Expand Down

0 comments on commit 3be20ed

Please sign in to comment.