From a5ca8a331537548ced0d29f3bfbfd862885e399d Mon Sep 17 00:00:00 2001 From: Lainow Date: Mon, 14 Oct 2024 11:17:49 +0200 Subject: [PATCH] Remove items_name and itemtype option --- inc/databaseinstanceinjection.class.php | 35 +++++-------------------- 1 file changed, 6 insertions(+), 29 deletions(-) diff --git a/inc/databaseinstanceinjection.class.php b/inc/databaseinstanceinjection.class.php index ec3ab1b..1d6ad2a 100644 --- a/inc/databaseinstanceinjection.class.php +++ b/inc/databaseinstanceinjection.class.php @@ -66,30 +66,7 @@ public function getOptions($primary_type = '') { $tab = Search::getOptions(get_parent_class($this)); - - $tab[251]['name'] = __('Itemtype'); - $tab[251]['field'] = 'itemtype'; - $tab[251]['table'] = DatabaseInstance::getTable(); - $tab[251]['linkfield'] = "itemtype"; - $tab[251]['injectable'] = true; - $tab[251]['displaytype'] = 'text'; - $tab[251]['checktype'] = 'text'; - - $tab[252]['name'] = __('Item'); - $tab[252]['field'] = 'name'; - $tab[252]['table'] = DatabaseInstance::getTable(); - $tab[252]['linkfield'] = "items_name"; - $tab[252]['injectable'] = true; - $tab[252]['displaytype'] = 'text'; - $tab[252]['checktype'] = 'text'; - - $tab[253]['name'] = __('Path'); - $tab[253]['field'] = 'path'; - $tab[253]['table'] = DatabaseInstance::getTable(); - $tab[253]['linkfield'] = "path"; - $tab[253]['injectable'] = true; - $tab[253]['displaytype'] = 'text'; - $tab[253]['checktype'] = 'text'; + $tab[5]['linkfield'] = 'items_id'; //Remove some options because some fields cannot be imported $blacklist = PluginDatainjectionCommonInjectionLib::getBlacklistedOptions(get_parent_class($this)); @@ -126,21 +103,21 @@ public function processAfterInsertOrUpdate($values, $add = true, $rights = []) //Should the port be connected to another one ? $use_itemtype = (isset($values['DatabaseInstance']["itemtype"]) || !empty($values['DatabaseInstance']["itemtype"])); - $use_items_name = (isset($values['DatabaseInstance']["items_name"]) - || !empty($values['DatabaseInstance']["items_name"])); + $use_items_id = (isset($values['DatabaseInstance']["items_id"]) + || !empty($values['DatabaseInstance']["items_id"])); - if (!$use_itemtype || !$use_items_name) { + if (!$use_itemtype || !$use_items_id) { return false; } $itemtype = new $values['DatabaseInstance']["itemtype"](); - if ($itemtype->getFromDBByCrit(['name' => $values['DatabaseInstance']["items_name"], 'entities_id' => $values['DatabaseInstance']["entities_id"]])) { + if ($itemtype->getFromDBByCrit(['id' => $values['DatabaseInstance']["items_id"], 'entities_id' => $values['DatabaseInstance']["entities_id"]])) { $dbinstance = new DatabaseInstance(); $success = $dbinstance->update( [ 'id' => $values['DatabaseInstance']['id'], 'entities_id' => $values['DatabaseInstance']['entities_id'], - 'items_id' => $itemtype->getID() + 'items_id' => $values['DatabaseInstance']["items_id"] ] ); }