From 5c89f0ebfd5cb5e7e6de02b3fea2c1c89deac978 Mon Sep 17 00:00:00 2001 From: Pierre Renaudet <53604301+PR-gh@users.noreply.github.com> Date: Tue, 6 Aug 2019 09:07:48 +0200 Subject: [PATCH] Tagged vlan --- inc/formatconvert.class.php | 5 +++-- inc/inventorynetworkequipmentlib.class.php | 9 +++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/inc/formatconvert.class.php b/inc/formatconvert.class.php index 30004cd0f5..6a0fe03dce 100644 --- a/inc/formatconvert.class.php +++ b/inc/formatconvert.class.php @@ -1901,7 +1901,7 @@ static function addValues($array, $a_key) { 'pages_n_b_copy', 'pages_color_copy', 'pages_total_fax', 'cpu', 'trunk', 'is_active', 'uptodate', 'nbthreads', 'vcpu', 'ram', 'ifinerrors', 'ifinoctets', 'ifouterrors', 'ifoutoctets', 'ifmtu', 'speed', - 'nbcores', 'nbthreads', 'frequency']; + 'nbcores', 'nbthreads', 'frequency', 'tagged']; foreach ($a_key as $key=>$value) { if (!isset($a_return[$value]) @@ -2278,7 +2278,8 @@ static function networkequipmentInventoryTransformation($array) { $array_tmp = $thisc->addValues($a_vlan, [ 'NAME' => 'name', - 'NUMBER' => 'tag']); + 'NUMBER' => 'tag', + 'TAGGED' => 'tagged']); if (isset($array_tmp['tag'])) { $a_inventory['vlans'][$a_port['IFNUMBER']][$array_tmp['tag']] = $array_tmp; } diff --git a/inc/inventorynetworkequipmentlib.class.php b/inc/inventorynetworkequipmentlib.class.php index 16fed851f9..d7ea13bde1 100644 --- a/inc/inventorynetworkequipmentlib.class.php +++ b/inc/inventorynetworkequipmentlib.class.php @@ -618,13 +618,13 @@ function importPortVlan($a_vlans, $networkports_id) { $networkPort_Vlan = new NetworkPort_Vlan(); $db_vlans = []; - $query = "SELECT `glpi_networkports_vlans`.`id`, `glpi_vlans`.`name`, `glpi_vlans`.`tag` + $query = "SELECT `glpi_networkports_vlans`.`id`, `glpi_vlans`.`name`, `glpi_vlans`.`tag`, `glpi_networkports_vlans`.`tagged` FROM `glpi_networkports_vlans` LEFT JOIN `glpi_vlans` ON `vlans_id`=`glpi_vlans`.`id` WHERE `networkports_id` = '$networkports_id'"; foreach ($DB->request($query) as $data) { - $db_vlans[$data['name']."$$$$".$data['tag']] = $data['id']; + $db_vlans[$data['id']] = $data; } if (count($db_vlans) == 0) { @@ -634,7 +634,7 @@ function importPortVlan($a_vlans, $networkports_id) { } else { foreach ($a_vlans as $key => $arrays) { foreach ($db_vlans as $keydb => $arraydb) { - if ($arrays['name']."$$$$".$arrays['tag'] == $keydb) { + if ($arrays['name'] == $arraydb['name'] && $arrays['tag'] == $arraydb['tag'] && $arrays['tagged'] == $arraydb['tagged']) { unset($a_vlans[$key]); unset($db_vlans[$keydb]); break; @@ -645,7 +645,7 @@ function importPortVlan($a_vlans, $networkports_id) { if (count($a_vlans) || count($db_vlans)) { if (count($db_vlans) != 0) { // Delete vlan in DB - foreach ($db_vlans as $id) { + foreach (array_keys($db_vlans) as $id) { $networkPort_Vlan->delete(['id'=>$id]); } } @@ -685,6 +685,7 @@ function addVlan($a_vlan, $networkports_id) { $input = []; $input['networkports_id'] = $networkports_id; $input['vlans_id'] = $vlans_id; + $input['tagged'] = $a_vlan['tagged']; $networkPort_Vlan->add($input); }