From 6b5f8c892761f72fe99904d509aef01976999b27 Mon Sep 17 00:00:00 2001 From: Garrett K Date: Wed, 17 Mar 2021 00:22:59 +0000 Subject: [PATCH] 0.3.14 --- backend/process_cable.php | 137 ++++++++++++++++++-------------------- 1 file changed, 63 insertions(+), 74 deletions(-) diff --git a/backend/process_cable.php b/backend/process_cable.php index b0f91c3..485dee1 100755 --- a/backend/process_cable.php +++ b/backend/process_cable.php @@ -86,79 +86,74 @@ if($_SERVER['REQUEST_METHOD'] == 'POST'){ $peerDepth = $cable['remote_object_depth']; $peerPort = $cable['remote_object_port']; $localAttrPrefix = $cable['localAttrPrefix']; + + // Remove any populated port entries that may exist + $qls->SQL->delete( + 'app_populated_port', + array( + 'object_id' => array('=', $elementID), + 'AND', + 'object_face' => array('=', $elementFace), + 'AND', + 'object_depth' => array('=', $elementDepth), + 'AND', + 'port_id' => array('=', $elementPort) + ) + ); - if($qls->App->loopDetected2($peerID, $peerFace, $peerDepth, $peerPort, $elementID, $elementFace, $elementDepth, $elementPort)) { - $errMsg = 'Loop detected.'; - array_push($validate->returnData['error'], $errMsg); - } else { - - // Remove any populated port entries that may exist - $qls->SQL->delete( - 'app_populated_port', - array( - 'object_id' => array('=', $elementID), - 'AND', - 'object_face' => array('=', $elementFace), - 'AND', - 'object_depth' => array('=', $elementDepth), - 'AND', - 'port_id' => array('=', $elementPort) - ) - ); - - // Clear any inventory entries - if (isset($qls->App->inventoryArray[$elementID][$elementFace][$elementDepth][$elementPort])) { - foreach($qls->App->inventoryArray[$elementID][$elementFace][$elementDepth][$elementPort] as $inventoryEntry) { - $rowID = $inventoryEntry['rowID']; - $localAttrPrefix = $inventoryEntry['localAttrPrefix']; + // Clear any inventory entries + if (isset($qls->App->inventoryArray[$elementID][$elementFace][$elementDepth][$elementPort])) { + foreach($qls->App->inventoryArray[$elementID][$elementFace][$elementDepth][$elementPort] as $inventoryEntry) { + $rowID = $inventoryEntry['rowID']; + $localAttrPrefix = $inventoryEntry['localAttrPrefix']; + + if ($inventoryEntry['localEndID'] == 0) { - if ($inventoryEntry['localEndID'] == 0) { - - // Found entry is not a managed cable... delete - $qls->SQL->delete('app_inventory', array('id' => array('=', $rowID))); - } else { - - // Found entry is a managed cable... zeroize - $qls->SQL->update( - 'app_inventory', - array( - $localAttrPrefix.'_object_id' => 0, - $localAttrPrefix.'_port_id' => 0, - $localAttrPrefix.'_object_face' => 0, - $localAttrPrefix.'_object_depth' => 0 - ), - array( - 'id' => array('=', $rowID) - ) - ); - } + // Found entry is not a managed cable... delete + $qls->SQL->delete('app_inventory', array('id' => array('=', $rowID))); + } else { + + // Found entry is a managed cable... zeroize + $qls->SQL->update( + 'app_inventory', + array( + $localAttrPrefix.'_object_id' => 0, + $localAttrPrefix.'_port_id' => 0, + $localAttrPrefix.'_object_face' => 0, + $localAttrPrefix.'_object_depth' => 0 + ), + array( + 'id' => array('=', $rowID) + ) + ); } } - - // Update connection in database - $qls->SQL->update( - 'app_inventory', - array( - $localAttrPrefix.'_object_id' => $elementID, - $localAttrPrefix.'_port_id' => $elementPort, - $localAttrPrefix.'_object_face' => $elementFace, - $localAttrPrefix.'_object_depth' => $elementDepth - ), - array( - 'id' => array('=', $cable['rowID']) - ) - ); - - $qls->App->inventoryByIDArray[$connectorID]['local_object_id'] = $elementID; - $qls->App->inventoryByIDArray[$connectorID]['local_object_face'] = $elementFace; - $qls->App->inventoryByIDArray[$connectorID]['local_object_depth'] = $elementDepth; - $qls->App->inventoryByIDArray[$connectorID]['local_object_port'] = $elementPort; - $cable = $qls->App->inventoryByIDArray[$connectorID]; - - // Retrieve connector path - $connectorFlatPath = $qls->App->buildConnectorFlatPath($cable, 'local'); - $validate->returnData['success']['connectorFlatPath'] = $connectorFlatPath; } + + // Update connection in database + $qls->SQL->update( + 'app_inventory', + array( + $localAttrPrefix.'_object_id' => $elementID, + $localAttrPrefix.'_port_id' => $elementPort, + $localAttrPrefix.'_object_face' => $elementFace, + $localAttrPrefix.'_object_depth' => $elementDepth + ), + array( + 'id' => array('=', $cable['rowID']) + ) + ); + + $qls->App->inventoryByIDArray[$connectorID]['local_object_id'] = $elementID; + $qls->App->inventoryByIDArray[$connectorID]['local_object_face'] = $elementFace; + $qls->App->inventoryByIDArray[$connectorID]['local_object_depth'] = $elementDepth; + $qls->App->inventoryByIDArray[$connectorID]['local_object_port'] = $elementPort; + $cable = $qls->App->inventoryByIDArray[$connectorID]; + + // Retrieve connector path + $connectorFlatPath = $qls->App->buildConnectorFlatPath($cable, 'local'); + $validate->returnData['success']['connectorFlatPath'] = $connectorFlatPath; + break; case 'connectionExploreClear': @@ -436,12 +431,6 @@ function validate($data, &$validate, &$qls){ ); $validate->validateTrunkedEndpoint($connectionPeerArray); - // Validate no loops will result - if($qls->App->loopDetected2($localID, $localFace, $localDepth, $localPort, $remoteID, $remoteFace, $remoteDepth, $remotePort)) { - $errMsg = 'Loop detected.'; - array_push($validate->returnData['error'], $errMsg); - } - // Does this action need to be confirmed? if(!isset($data['confirmed'])) { if (isset($qls->App->inventoryArray[$remoteID][$remoteFace][$remoteDepth][$remotePort])) {