diff --git a/inc/computer_softwarelicenseinjection.class.php b/inc/item_softwarelicenseinjection.class.php similarity index 89% rename from inc/computer_softwarelicenseinjection.class.php rename to inc/item_softwarelicenseinjection.class.php index 3d7ce87b..78a70d9e 100644 --- a/inc/computer_softwarelicenseinjection.class.php +++ b/inc/item_softwarelicenseinjection.class.php @@ -32,19 +32,17 @@ die("Sorry. You can't access directly to this file"); } -class PluginDatainjectionComputer_SoftwareLicenseInjection extends Computer_SoftwareLicense +class PluginDatainjectionItem_SoftwareLicenseInjection extends Item_SoftwareLicense implements PluginDatainjectionInjectionInterface { static function getTypeName($nb = 0) { - return __('Computer'); } static function getTable($classname = null) { - $parenttype = get_parent_class(); return $parenttype::getTable(); @@ -52,14 +50,16 @@ static function getTable($classname = null) { function isPrimaryType() { + return false; + } + function relationSide() { return false; } function connectedTo() { - - return ['SoftwareLicense']; + return ['SoftwareLicense', 'Software']; } @@ -67,7 +67,6 @@ function connectedTo() { * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions() **/ function getOptions($primary_type = '') { - $tab[110]['table'] = 'glpi_computers'; $tab[110]['field'] = 'name'; $tab[110]['linkfield'] = 'name'; @@ -109,7 +108,6 @@ function getOptions($primary_type = '') { * @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::addOrUpdateObject() **/ function addOrUpdateObject($values = [], $options = []) { - $lib = new PluginDatainjectionCommonInjectionLib($this, $values, $options); $lib->processAddOrUpdate(); return $lib->getInjectionResults(); @@ -117,9 +115,10 @@ function addOrUpdateObject($values = [], $options = []) { function addSpecificMandatoryFields() { - - return ['computers_id' => 1, - 'softwarelicenses_id' => 1]; + return [ + 'computers_id' => 1, + 'softwarelicenses_id' => 1 + ]; } @@ -128,10 +127,15 @@ function addSpecificMandatoryFields() { * @param $values **/ function addSpecificNeededFields($primary_type, $values) { - if (isset($values['SoftwareLicense'])) { $fields['softwarelicenses_id'] = $values['SoftwareLicense']['id']; } + + if (isset($values['Item_SoftwareLicense'])) { + $fields['itemtype'] = "Computer"; + $fields['items_id'] = $values['Item_SoftwareLicense']['computers_id']; + } + return $fields; } diff --git a/inc/computer_softwareversioninjection.class.php b/inc/item_softwareversioninjection.class.php similarity index 90% rename from inc/computer_softwareversioninjection.class.php rename to inc/item_softwareversioninjection.class.php index 6c75f22a..39b87613 100644 --- a/inc/computer_softwareversioninjection.class.php +++ b/inc/item_softwareversioninjection.class.php @@ -32,32 +32,32 @@ die("Sorry. You can't access directly to this file"); } -class PluginDatainjectionComputer_SoftwareVersionInjection extends Computer_SoftwareVersion +class PluginDatainjectionItem_SoftwareVersionInjection extends Item_SoftwareVersion implements PluginDatainjectionInjectionInterface { static function getTypeName($nb = 0) { - return __('Computer'); } static function getTable($classname = null) { - $parenttype = get_parent_class(); return $parenttype::getTable(); } function isPrimaryType() { + return false; + } + function relationSide() { return false; } function connectedTo() { - return ['Software', 'SoftwareVersion']; } @@ -116,9 +116,10 @@ function addOrUpdateObject($values = [], $options = []) { function addSpecificMandatoryFields() { - - return ['computers_id' => 1, - 'softwareversions_id' => 1]; + return [ + 'computers_id' => 1, + 'softwareversions_id' => 1 + ]; } @@ -128,10 +129,15 @@ function addSpecificMandatoryFields() { **/ function addSpecificNeededFields($primary_type, $values) { - if (isset($values['SoftwareVersion'])) { $fields['softwareversions_id'] = $values['SoftwareVersion']['id']; } + + if (isset($values['Item_SoftwareVersion'])) { + $fields['itemtype'] = "Computer"; + $fields['items_id'] = $values['Item_SoftwareVersion']['computers_id']; + } + return $fields; } diff --git a/setup.php b/setup.php index a225409e..99197a0e 100644 --- a/setup.php +++ b/setup.php @@ -146,8 +146,8 @@ function getTypesToInject() { 'PluginDatainjectionProfileInjection' => 'datainjection', 'PluginDatainjectionProfile_UserInjection' => 'datainjection', 'PluginDatainjectionSoftwareInjection' => 'datainjection', - 'PluginDatainjectionComputer_SoftwareVersionInjection' => 'datainjection', - 'PluginDatainjectionComputer_SoftwareLicenseInjection' => 'datainjection', + 'PluginDatainjectionItem_SoftwareVersionInjection' => 'datainjection', + 'PluginDatainjectionItem_SoftwareLicenseInjection' => 'datainjection', 'PluginDatainjectionSoftwareLicenseInjection' => 'datainjection', 'PluginDatainjectionSoftwareVersionInjection' => 'datainjection', 'PluginDatainjectionSupplierInjection' => 'datainjection',