Skip to content

Commit

Permalink
fix import of versions/license from software main type
Browse files Browse the repository at this point in the history
  • Loading branch information
orthagh authored and cedric-anne committed Jan 21, 2021
1 parent ea6eafc commit f67de7f
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,42 +32,41 @@
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();

}


function isPrimaryType() {
return false;
}

function relationSide() {
return false;
}


function connectedTo() {

return ['SoftwareLicense'];
return ['SoftwareLicense', 'Software'];
}


/**
* @see plugins/datainjection/inc/PluginDatainjectionInjectionInterface::getOptions()
**/
function getOptions($primary_type = '') {

$tab[110]['table'] = 'glpi_computers';
$tab[110]['field'] = 'name';
$tab[110]['linkfield'] = 'name';
Expand Down Expand Up @@ -109,17 +108,17 @@ 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();
}


function addSpecificMandatoryFields() {

return ['computers_id' => 1,
'softwarelicenses_id' => 1];
return [
'computers_id' => 1,
'softwarelicenses_id' => 1
];
}


Expand All @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
}

Expand Down Expand Up @@ -116,9 +116,10 @@ function addOrUpdateObject($values = [], $options = []) {


function addSpecificMandatoryFields() {

return ['computers_id' => 1,
'softwareversions_id' => 1];
return [
'computers_id' => 1,
'softwareversions_id' => 1
];
}


Expand All @@ -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;
}

Expand Down
4 changes: 2 additions & 2 deletions setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit f67de7f

Please sign in to comment.