Skip to content

Commit

Permalink
fix CS
Browse files Browse the repository at this point in the history
  • Loading branch information
stonebuzz committed Oct 13, 2020
1 parent 39ec843 commit dee5848
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 18 deletions.
30 changes: 14 additions & 16 deletions inc/inventory.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,50 +9,49 @@ static function updateInventory($params = []) {
&& isset($params['inventory_data']) && !empty($params['inventory_data'])) {

$availaibleItemType = ["Computer","Printer","NetworkEquipment"];
foreach($params['inventory_data'] as $itemtype => $inventories){
foreach ($params['inventory_data'] as $itemtype => $inventories) {

if(in_array($itemtype,$availaibleItemType)){
if (in_array($itemtype,$availaibleItemType)) {
//retrive items id switch itemtype
switch ($itemtype) {
case Computer::getType():
$items_id = $params['computers_id'];
break;

case NetworkEquipment::getType():
case NetworkEquipment::getType():
$items_id = $params['networkequipments_id'];
break;

case Printer::getType():
case Printer::getType():
$items_id = $params['printers_id'];
break;
}

//load inventory from DB because
//FI not update XML file if computer is not update
if($itemtype == Computer::getType()){
if ($itemtype == Computer::getType()) {
$db_info = new PluginFusioninventoryInventoryComputerComputer();
if ($db_info->getFromDBByCrit(['computers_id' => $items_id])) {

$arrayinventory = unserialize(gzuncompress($db_info->fields['serialized_inventory']));
if(isset($arrayinventory['custom'])){
if(isset($arrayinventory['custom']['container']['ID'])){
if (isset($arrayinventory['custom'])) {
if (isset($arrayinventory['custom']['container']['ID'])) {
$customData['container'][0] = $arrayinventory['custom']['container'];
}else{
} else {
$customData = $arrayinventory['custom'];
}
self::updateFields($customData, $itemtype, $items_id);
}
}
//Load XML file because FI
//always update XML file and don't store inventory into DB
}else{
//Load XML file because FI always update XML file and don't store inventory into DB
} else {
$file = self::loadXMLFile($itemtype, $items_id);
if($file !== false){
if ($file !== false) {
$arrayinventory = PluginFusioninventoryFormatconvert::XMLtoArray($file);
if(isset($arrayinventory['CUSTOM'])){
if(isset($arrayinventory['CUSTOM']['CONTAINER']['ID'])){
if (isset($arrayinventory['CUSTOM'])) {
if (isset($arrayinventory['CUSTOM']['CONTAINER']['ID'])) {
$customData['container'][0] = $arrayinventory['CUSTOM']['CONTAINER'];
}else{
} else {
$customData['container'] = $arrayinventory['CUSTOM']['CONTAINER'];
}
self::updateFields($customData, $itemtype, $items_id);
Expand All @@ -64,7 +63,6 @@ static function updateInventory($params = []) {
}
}


static function updateFields($customData, $itemtype, $items_id){
foreach ($customData['container'] as $key => $dataContainers) {
$container = new PluginFieldsContainer();
Expand Down
2 changes: 0 additions & 2 deletions setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,11 @@ function plugin_init_fields() {
}
}


if ($plugin->isActivated('fusioninventory')) {
$PLUGIN_HOOKS['fusioninventory_inventory']['fields']
= ['PluginFieldsInventory', 'updateInventory'];
}


// complete rule engine
$PLUGIN_HOOKS['use_rules']['fields'] = ['PluginFusioninventoryTaskpostactionRule'];
$PLUGIN_HOOKS['rule_matched']['fields'] = 'plugin_fields_rule_matched';
Expand Down

0 comments on commit dee5848

Please sign in to comment.