Skip to content

Commit

Permalink
Remove items_name and itemtype option
Browse files Browse the repository at this point in the history
  • Loading branch information
Lainow committed Oct 14, 2024
1 parent a4922d9 commit a5ca8a3
Showing 1 changed file with 6 additions and 29 deletions.
35 changes: 6 additions & 29 deletions inc/databaseinstanceinjection.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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"]
]
);
}
Expand Down

0 comments on commit a5ca8a3

Please sign in to comment.