Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

Fix try detect phone #3423

Open
wants to merge 3 commits into
base: glpi10.0.6
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions inc/inventorynetworkequipmentlib.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -514,11 +514,11 @@ function importConnectionMac($a_portconnection, $networkports_id) {

// Try detect phone + computer on this port
if (count($list_all_ports_found) == 2) {
$phonecase = 0;
$macNotPhone_id = 0;
$phonePort_id = 0;
foreach ($this->found_ports as $itemtype => $ids) {
$phonecase = 0;
$macNotPhone_id = 0;
$phonePort_id = 0;
if ($itemtype == "phone") {
if ($itemtype == "Phone") {
// Connect phone on switch port and other (computer..) in this phone
foreach ($ids as $items_id) {
$phonePort_id = current($items_id);
Expand All @@ -531,8 +531,18 @@ function importConnectionMac($a_portconnection, $networkports_id) {
}
}
if ($phonecase == 1) {
$wire->add(['networkports_id_1'=> $networkports_id,
$opposite_id = $wire->getOppositeContact($networkports_id);
if (isset($opposite_id)) {
if ($opposite_id != $phonePort_id) {
$pfNetworkPort->disconnectDB($networkports_id); // disconnect this port
$pfNetworkPort->disconnectDB($phonePort_id); // disconnect this port
$wire->add(['networkports_id_1'=> $networkports_id,
'networkports_id_2' => $phonePort_id]);
}
} else {
$wire->add(['networkports_id_1'=> $networkports_id,
'networkports_id_2' => $phonePort_id]);
}
$networkPort->getFromDB($phonePort_id);
$portLink_id = 0;
if ($networkPort->fields['name'] == 'Link') {
Expand Down Expand Up @@ -561,11 +571,15 @@ function importConnectionMac($a_portconnection, $networkports_id) {
}
}
$opposite_id = false;
if ($opposite_id == $wire->getOppositeContact($portLink_id)) {
if ($opposite_id = $wire->getOppositeContact($portLink_id)) {
if ($opposite_id != $macNotPhone_id) {
$pfNetworkPort->disconnectDB($portLink_id); // disconnect this port
$pfNetworkPort->disconnectDB($macNotPhone_id); // disconnect destination port
} else { // yet connected
return;
}
} else {
$pfNetworkPort->disconnectDB($macNotPhone_id); // disconnect destination port
}
$wire->add([
'networkports_id_1'=> $portLink_id,
Expand Down