From 7b50c60b785e7ae29dfdca5294275582b0c5a733 Mon Sep 17 00:00:00 2001 From: Garrett Date: Mon, 21 Dec 2020 05:40:27 +0000 Subject: [PATCH] 0.3.12 --- admin-integration.php | 43 +- admin.php | 51 +- assets/pages/jquery.diagram.js | 2 +- assets/pages/jquery.drawConnections.js | 90 ++- assets/pages/jquery.explore.js | 55 +- backend/process_cable.php | 301 ++++---- cableInventory.php | 2 +- demoInventory.php | 47 -- diagram.php | 47 +- environment.php | 91 +-- explore.php | 152 +--- includes/App.class.php | 128 +++- includes/content-object_tree_modal.php | 37 - includes/header_end.php | 111 --- includes/modals.php | 951 +++++++++++++++++++++++++ index.php | 14 +- profile.php | 2 +- scan.php | 81 +-- settings.php | 2 +- templates.php | 447 +----------- 20 files changed, 1336 insertions(+), 1318 deletions(-) delete mode 100755 demoInventory.php delete mode 100755 includes/content-object_tree_modal.php create mode 100755 includes/modals.php diff --git a/admin-integration.php b/admin-integration.php index 09a1937..8c72596 100755 --- a/admin-integration.php +++ b/admin-integration.php @@ -7,45 +7,12 @@ $qls->Security->check_auth_page('administrator.php'); - - - + + + - - - + +
diff --git a/admin.php b/admin.php index b99744e..99ada2e 100755 --- a/admin.php +++ b/admin.php @@ -7,54 +7,11 @@ $qls->Security->check_auth_page('administrator.php'); - - + + - - - - - + +
diff --git a/assets/pages/jquery.diagram.js b/assets/pages/jquery.diagram.js index f7702d8..39ea2bc 100755 --- a/assets/pages/jquery.diagram.js +++ b/assets/pages/jquery.diagram.js @@ -82,7 +82,7 @@ $( document ).ready(function() { $('#objectTreeModal').modal('show'); }); - $('#buttonObjectTreeModalAdd').click(function(){ + $('#buttonObjectTreeModalSave').click(function(){ var node = $('#objTree').jstree('get_selected', false); var nodeID = node[0]; diff --git a/assets/pages/jquery.drawConnections.js b/assets/pages/jquery.drawConnections.js index ef38e64..ee4d122 100755 --- a/assets/pages/jquery.drawConnections.js +++ b/assets/pages/jquery.drawConnections.js @@ -38,6 +38,7 @@ function drawConnection(elementArray){ context.strokeStyle = 'LightSkyBlue'; context.lineWidth = 3; context.beginPath(); + console.log('Debug (elementArray): '+JSON.stringify(elementArray)); $.each(elementArray, function(index, element){ var elemA = element[0]; @@ -235,49 +236,62 @@ function crawlPath(selectedPort){ } while($(selectedPort).length) { - - // Crawl connection peer - var selectedPortID = $(selectedPort).attr('id'); - var selectedPartition = $(selectedPort).closest('.partition'); - var connectedPortID = $(selectedPort).data('connectedGlobalId'); - var connectedPort = $('#'+connectedPortID); - + console.log('here1'); portArray.push(selectedPort); - if($(connectedPort).length) { - - portArray.push(connectedPort) - connectionArray.push([selectedPort, connectedPort]); - - } else { - if(connectedPortID != 'none') { - connectionArray.push([selectedPort, connectedPortID]); - } - break; - } + // Crawl connection peer + var connectedPortIDString = $(selectedPort).data('connectedGlobalId'); + var connectedPortIDArray = JSON.parse(atob(connectedPortIDString)); - var connectedPartition = $(connectedPort).closest('.partition'); - var connectedPartitionPeerID = $(connectedPartition).data('peerGlobalId'); + console.log('Debug (connectedPortIDString): '+atob(connectedPortIDString)); - if($('#'+connectedPartitionPeerID).length) { - - var connectedPartitionPeer = $('#'+connectedPartitionPeerID); - trunkArray.push([connectedPartition, connectedPartitionPeer]); - partitionArray.push(connectedPartition, connectedPartitionPeer); - - var connectedPartitionPeerIDArray = connectedPartitionPeerID.split('-'); - var peerID = connectedPartitionPeerIDArray[2]; - var peerFace = connectedPartitionPeerIDArray[3]; - var peerDepth = connectedPartitionPeerIDArray[4]; - - var connectedPortIDArray = connectedPortID.split('-'); - var peerPort = connectedPortIDArray[5]; - var selectedPort = $('#port-4-'+peerID+'-'+peerFace+'-'+peerDepth+'-'+peerPort); - } else { - if(connectedPartitionPeerID != 'none') { - trunkArray.push([connectedPartition, connectedPartitionPeerID]); + if(connectedPortIDArray.length) { + var peerPortFound = false; + $.each(connectedPortIDArray, function(index, connectedPortID){ + console.log('Debug (connectedPortID): '+connectedPortID); + var connectedPort = $('#'+connectedPortID); + if($(connectedPort).length) { + + portArray.push(connectedPort) + connectionArray.push([selectedPort, connectedPort]); + + var connectedPartition = $(connectedPort).closest('.partition'); + var connectedPartitionPeerID = $(connectedPartition).data('peerGlobalId'); + + if($('#'+connectedPartitionPeerID).length) { + + var connectedPartitionPeer = $('#'+connectedPartitionPeerID); + trunkArray.push([connectedPartition, connectedPartitionPeer]); + partitionArray.push(connectedPartition, connectedPartitionPeer); + + var connectedPartitionPeerIDArray = connectedPartitionPeerID.split('-'); + var peerID = connectedPartitionPeerIDArray[2]; + var peerFace = connectedPartitionPeerIDArray[3]; + var peerDepth = connectedPartitionPeerIDArray[4]; + + var connectedPortIDArray = connectedPortID.split('-'); + var peerPort = connectedPortIDArray[5]; + selectedPort = $('#port-4-'+peerID+'-'+peerFace+'-'+peerDepth+'-'+peerPort); + peerPortFound = true; + } else { + if(connectedPartitionPeerID != 'none') { + trunkArray.push([connectedPartition, connectedPartitionPeerID]); + } + //selectedPort = false; + //return false; + } + + } else { + connectionArray.push([selectedPort, connectedPortID]); + //selectedPort = false; + //return false; + } + }); + if(peerPortFound == false) { + selectedPort = false; } - break; + } else { + selectedPort = false; } } } diff --git a/assets/pages/jquery.explore.js b/assets/pages/jquery.explore.js index 0a6e326..b1437a5 100755 --- a/assets/pages/jquery.explore.js +++ b/assets/pages/jquery.explore.js @@ -706,6 +706,14 @@ function postProcessCable(){ $( document ).ready(function() { + $('#checkboxBreakoutCable').on('change', function(){ + if($(this).is(':checked')) { + $('#objTree').jstree(true).settings.core.multiple = true; + } else { + $('#objTree').jstree(true).settings.core.multiple = false; + } + }); + $('#printFullPath').on('click', function(event){ event.preventDefault(); $('#containerFullPath').printThis({ @@ -943,7 +951,11 @@ $( document ).ready(function() { $('#buttonObjectTreeModalSave').on('click', function(){ var selectedNode = $('#objTree').jstree('get_selected', true); - var value = selectedNode[0].data.globalID; + var value = []; + $.each(selectedNode, function(index, node){ + value.push(node.data.globalID); + }); + //var value = selectedNode[0].data.globalID; var objID = $(document).data('clickedObjID'); var objFace = $(document).data('clickedObjFace'); var objDepth = $(document).data('clickedObjPartitionDepth'); @@ -959,38 +971,6 @@ $( document ).ready(function() { }; postProcessCable.call(data); - - /* data = JSON.stringify(data); - - $.post('backend/process_cable.php', {data:data}, function(response){ - var responseJSON = JSON.parse(response); - if (responseJSON.active == 'inactive'){ - window.location.replace("/"); - } else if ($(responseJSON.error).size() > 0){ - displayErrorElement(responseJSON.error, $('#alertMsgObjTree')); - } else { - var optionText = $('#selectPort').find(':selected').text(); - $('#port-4-'+objID+'-'+objFace+'-'+objDepth+'-'+objPort).addClass('populated').data('connectedGlobalId', 'port-'+responseJSON.success.peerPortID); - if($('#port-'+responseJSON.success.peerPortID).length) { - $('#port-'+responseJSON.success.peerPortID).addClass('populated').data('connectedGlobalId', '#port-4-'+objID+'-'+objFace+'-'+objDepth+'-'+objPort); - } - if($('#port-'+responseJSON.success.oldPeerPortID).length) { - $('#port-'+responseJSON.success.oldPeerPortID).removeClass('populated').data('connectedGlobalId', 'none'); - } - var interfaceSelectionElem = $('#selectPort').find(':selected'); - portDesignation(interfaceSelectionElem, 'add', 'C'); - $('#checkboxPopulated').prop("checked", true); - $('#checkboxPopulated').prop("disabled", true); - retrievePortPath(objID, objFace, objDepth, objPort); - refreshPathData(); - redraw(); - - $('#objTree').jstree('deselect_all'); - $('#objectTreeModal').modal('hide'); - - $(document).data('peerPortID', value); - } - }); */ }); $('#buttonObjectTreeModalClear').on('click', function(){ @@ -1006,8 +986,7 @@ $( document ).ready(function() { var objPort = $(document).data('clickedObjPortID'); var data = { - property: 'connectionExplore', - value: 'clear', + property: 'connectionExploreClear', objID: objID, objFace: objFace, objDepth: objDepth, @@ -1023,8 +1002,10 @@ $( document ).ready(function() { displayError(responseJSON.error); } else { $('#port-4-'+objID+'-'+objFace+'-'+objDepth+'-'+objPort).removeClass('populated').data('connectedGlobalId', 'none'); - if($('#port-'+responseJSON.success.peerPortID).length) { - $('#port-'+responseJSON.success.peerPortID).removeClass('populated').data('connectedGlobalId', 'none'); + if(responseJSON.success.oldPeerPortID) { + if($('#port-'+responseJSON.success.oldPeerPortID).length) { + $('#port-'+responseJSON.success.oldPeerPortID).removeClass('populated').data('connectedGlobalId', 'none'); + } } var interfaceSelectionElem = $('#selectPort').find(':selected'); diff --git a/backend/process_cable.php b/backend/process_cable.php index 8b45244..135df02 100755 --- a/backend/process_cable.php +++ b/backend/process_cable.php @@ -165,7 +165,51 @@ if($_SERVER['REQUEST_METHOD'] == 'POST'){ $validate->returnData['success']['connectorFlatPath'] = $connectorFlatPath; } break; + + case 'connectionExploreClear': + + $validate->returnData['success'] = array(); + + // Retrieve object data + $objID = $data['objID']; + $objFace = $data['objFace']; + $objDepth = $data['objDepth']; + $objPort = $data['objPort']; + $obj = (isset($qls->App->inventoryArray[$objID][$objFace][$objDepth][$objPort])) ? $qls->App->inventoryArray[$objID][$objFace][$objDepth][$objPort] : false; + // Retrieve old peer port ID so it can have the "populated" class cleared + if($obj) { + $oldPeerPortID = '4-'.$obj['id'].'-'.$obj['face'].'-'.$obj['depth'].'-'.$obj['port']; + } else { + $oldPeerPortID = false; + } + + // Clear inventory table entry + $objRowID = $obj['rowID']; + if($obj['localEndID'] or $obj['remoteEndID']) { + clearTableInventory($qls, $obj['localAttrPrefix'], $objRowID); + } else { + $qls->SQL->delete('app_inventory', array('id' => array('=', $objRowID))); + } + + // Clear populated port entry + clearTablePopulated($qls, $objID, $objFace, $objDepth, $objPort); + + // Log history + $localPort = $qls->App->generateObjectPortName($objID, $objFace, $objDepth, $objPort); + $remotePortData = $qls->App->inventoryArray[$objID][$objFace][$objDepth][$objPort]; + $remoteObjID = $remotePortData['id']; + $remoteObjFace = $remotePortData['face']; + $remoteObjDepth = $remotePortData['depth']; + $remoteObjPort = $remotePortData['port']; + $remotePort = $qls->App->generateObjectPortName($remoteObjID, $remoteObjFace, $remoteObjDepth, $remoteObjPort); + $actionString = 'Deleted connection: '.$localPort.' to '.$remotePort.''; + $qls->App->logAction(3, 3, $actionString); + + $validate->returnData['success']['oldPeerPortID'] = $oldPeerPortID; + + break; + case 'connectionExplore': require_once '../includes/path_functions.php'; $validate->returnData['success'] = array(); @@ -173,55 +217,36 @@ if($_SERVER['REQUEST_METHOD'] == 'POST'){ $clear = $value == 'clear' ? true : false; $peerPortID = ''; - if($clear) { - $elementID = $elementFace = $elementDepth = $elementPort = 0; - } else { - $valueArray = explode('-', $value); - $elementID = $valueArray[1]; - $elementFace = $valueArray[2]; - $elementDepth = $valueArray[3]; - $elementPort = $valueArray[4]; - } + foreach($value as $peerPortString) { - $objID = $data['objID']; - $objFace = $data['objFace']; - $objDepth = $data['objDepth']; - $objPort = $data['objPort']; + $peerPortArray = explode('-', $peerPortString); - if(loopDetected($qls, $objID, $objFace, $objDepth, $objPort, $elementID, $elementFace, $elementDepth, $elementPort)) { - $errMsg = 'Loop detected.'; - array_push($validate->returnData['error'], $errMsg); - } else { + $elementID = $peerPortArray[1]; + $elementFace = $peerPortArray[2]; + $elementDepth = $peerPortArray[3]; + $elementPort = $peerPortArray[4]; + $element = (isset($qls->App->inventoryArray[$elementID][$elementFace][$elementDepth][$elementPort])) ? $qls->App->inventoryArray[$elementID][$elementFace][$elementDepth][$elementPort] : false; - $query = $qls->SQL->select('*', 'app_inventory', '(a_object_id = '.$objID.' AND a_object_face = '.$objFace.' AND a_object_depth = '.$objDepth.' AND a_port_id = '.$objPort.') OR (b_object_id = '.$objID.' AND b_object_face = '.$objFace.' AND b_object_depth = '.$objDepth.' AND b_port_id = '.$objPort.')'); - $objEntry = $qls->SQL->num_rows($query) ? $qls->SQL->fetch_assoc($query) : false; + $objID = $data['objID']; + $objFace = $data['objFace']; + $objDepth = $data['objDepth']; + $objPort = $data['objPort']; + $obj = (isset($qls->App->inventoryArray[$objID][$objFace][$objDepth][$objPort])) ? $qls->App->inventoryArray[$objID][$objFace][$objDepth][$objPort] : false; + + $peerPortID = '4-'.$elementID.'-'.$elementFace.'-'.$elementDepth.'-'.$elementPort; - if($clear) { - $elementEntry = false; - if($objEntry) { - $elementAttr = ($objEntry['a_object_id'] == $objID and $objEntry['a_object_face'] == $objFace and $objEntry['a_object_depth'] == $objDepth and $objEntry['a_port_id'] == $objPort) ? 'b' : 'a'; - $peerPortID = '4-'.$objEntry[$elementAttr.'_object_id'].'-'.$objEntry[$elementAttr.'_object_face'].'-'.$objEntry[$elementAttr.'_object_depth'].'-'.$objEntry[$elementAttr.'_port_id']; - } else { - $peerPortID = '4-0-0-0-0'; - } - } else { - $query = $qls->SQL->select('*', 'app_inventory', '(a_object_id = '.$elementID.' AND a_object_face = '.$elementFace.' AND a_object_depth = '.$elementDepth.' AND a_port_id = '.$elementPort.') OR (b_object_id = '.$elementID.' AND b_object_face = '.$elementFace.' AND b_object_depth = '.$elementDepth.' AND b_port_id = '.$elementPort.')'); - $elementEntry = $qls->SQL->num_rows($query) ? $qls->SQL->fetch_assoc($query) : false; - $peerPortID = '4-'.$elementID.'-'.$elementFace.'-'.$elementDepth.'-'.$elementPort; - - // Clear trunk if this is a trunked floorplan object - $objIDArray = array($elementID, $objID); - foreach($objIDArray as $objID) { - $templateID = $qls->App->objectArray[$objID]['template_id']; - $templateType = $qls->App->templateArray[$templateID]['templateType']; - if(isset($qls->App->floorplanObjDetails[$templateType])) { - $templateFunction = $qls->App->templateArray[$templateID]['templateFunction']; - if($templateFunction == 'Endpoint') { - if(isset($qls->App->peerArrayWalljack[$objID])) { - foreach($qls->App->peerArrayWalljack[$objID] as $peerEntry) { - $rowID = $peerEntry['rowID']; - $qls->SQL->delete('app_object_peer', array('id' => array('=', $rowID))); - } + // Clear trunk if this is a trunked floorplan object + $objIDArray = array($elementID, $objID); + foreach($objIDArray as $objID) { + $templateID = $qls->App->objectArray[$objID]['template_id']; + $templateType = $qls->App->templateArray[$templateID]['templateType']; + if(isset($qls->App->floorplanObjDetails[$templateType])) { + $templateFunction = $qls->App->templateArray[$templateID]['templateFunction']; + if($templateFunction == 'Endpoint') { + if(isset($qls->App->peerArrayWalljack[$objID])) { + foreach($qls->App->peerArrayWalljack[$objID] as $peerEntry) { + $rowID = $peerEntry['rowID']; + $qls->SQL->delete('app_object_peer', array('id' => array('=', $rowID))); } } } @@ -229,94 +254,78 @@ if($_SERVER['REQUEST_METHOD'] == 'POST'){ } // Retrieve old peer port ID so it can have the "populated" class cleared - if(isset($qls->App->inventoryArray[$objID][$objFace][$objDepth][$objPort])) { - $inventoryEntry = $qls->App->inventoryArray[$objID][$objFace][$objDepth][$objPort]; - $oldPeerPortID = '4-'.$inventoryEntry['id'].'-'.$inventoryEntry['face'].'-'.$inventoryEntry['depth'].'-'.$inventoryEntry['port']; + if($obj) { + $oldPeerPortID = '4-'.$obj['id'].'-'.$obj['face'].'-'.$obj['depth'].'-'.$obj['port']; } else { $oldPeerPortID = false; } - // Find which ports are already connected - if($objEntry and $elementEntry) { - $objAttr = ($objEntry['a_object_id'] == $objID and $objEntry['a_object_face'] == $objFace and $objEntry['a_object_depth'] == $objDepth and $objEntry['a_port_id'] == $objPort) ? 'a' : 'b'; - $elementAttr = ($elementEntry['a_object_id'] == $elementID) ? 'a' : 'b'; + // Clear existing connections + if($obj and $element) { + + $objRowID = $obj['rowID']; + $elementRowID = $element['rowID']; // Are the ports connected to each other? - if($objEntry['id'] == $elementEntry['id']) { - $entryID = $objEntry['id']; - if($objEntry['a_id'] or $objEntry['b_id']) { - clearTableInventory($qls, 'a', $entryID); - clearTableInventory($qls, 'b', $entryID); + if($obj['rowID'] == $element['rowID']) { + if($obj['localEndID'] or $obj['remoteEndID']) { + clearTableInventory($qls, 'a', $objRowID); + clearTableInventory($qls, 'b', $objRowID); } else { - $qls->SQL->delete('app_inventory', array('id' => array('=', $entryID))); + $qls->SQL->delete('app_inventory', array('id' => array('=', $objRowID))); } } else { - if($objEntry['a_id'] or $objEntry['b_id']) { - clearTableInventory($qls, $objAttr, $objEntry['id']); + if($obj['localEndID'] or $obj['remoteEndID']) { + clearTableInventory($qls, $obj['localAttrPrefix'], $objRowID); } else { - $qls->SQL->delete('app_inventory', array('id' => array('=', $objEntry['id']))); + $qls->SQL->delete('app_inventory', array('id' => array('=', $objRowID))); } - if($elementEntry['a_id'] or $elementEntry['b_id']) { - clearTableInventory($qls, $elementAttr, $elementEntry['id']); + if($element['localEndID'] or $element['remoteEndID']) { + clearTableInventory($qls, $element['localAttrPrefix'], $elementRowID); } else { - $qls->SQL->delete('app_inventory', array('id' => array('=', $elementEntry['id']))); + $qls->SQL->delete('app_inventory', array('id' => array('=', $elementRowID))); } } - } else if($objEntry) { - $objAttr = ($objEntry['a_object_id'] == $objID and $objEntry['a_object_face'] == $objFace and $objEntry['a_object_depth'] == $objDepth and $objEntry['a_port_id'] == $objPort) ? 'a' : 'b'; + } else if($obj) { - if($objEntry['a_id'] or $objEntry['b_id']) { - clearTableInventory($qls, $objAttr, $objEntry['id']); + $objRowID = $obj['rowID']; + + if($obj['localEndID'] or $obj['remoteEndID']) { + clearTableInventory($qls, $obj['localAttrPrefix'], $objRowID); } else { - $qls->SQL->delete('app_inventory', array('id' => array('=', $objEntry['id']))); + $qls->SQL->delete('app_inventory', array('id' => array('=', $objRowID))); } - } else if($elementEntry) { - $elementAttr = ($elementEntry['a_object_id'] == $elementID and $elementEntry['a_object_face'] == $elementFace and $elementEntry['a_object_depth'] == $elementDepth and $elementEntry['a_port_id'] == $elementPort) ? 'a' : 'b'; + } else if($element) { - if($elementEntry['a_id'] or $elementEntry['b_id']) { - clearTableInventory($qls, $elementAttr, $elementEntry['id']); + $elementRowID = $element['rowID']; + + if($element['localEndID'] or $element['remoteEndID']) { + clearTableInventory($qls, $element['localAttrPrefix'], $elementRowID); } else { - $qls->SQL->delete('app_inventory', array('id' => array('=', $elementEntry['id']))); + $qls->SQL->delete('app_inventory', array('id' => array('=', $elementRowID))); } } + // Clear populated port entry clearTablePopulated($qls, $objID, $objFace, $objDepth, $objPort); clearTablePopulated($qls, $elementID, $elementFace, $elementDepth, $elementPort); - if(!$clear) { - insertTableInventory($qls, $objID, $objFace, $objDepth, $objPort, $elementID, $elementFace, $elementDepth, $elementPort); + // Insert new connection + insertTableInventory($qls, $objID, $objFace, $objDepth, $objPort, $elementID, $elementFace, $elementDepth, $elementPort); - // Log history - $localPort = $qls->App->generateObjectPortName($objID, $objFace, $objDepth, $objPort); - $remotePort = $qls->App->generateObjectPortName($elementID, $elementFace, $elementDepth, $elementPort); - $actionString = 'Added connection: '.$localPort.' to '.$remotePort.''; - $qls->App->logAction(3, 1, $actionString); - - } else { - - // Log history - $localPort = $qls->App->generateObjectPortName($objID, $objFace, $objDepth, $objPort); - $remotePortData = $qls->App->inventoryArray[$objID][$objFace][$objDepth][$objPort]; - $remoteObjID = $remotePortData['id']; - $remoteObjFace = $remotePortData['face']; - $remoteObjDepth = $remotePortData['depth']; - $remoteObjPort = $remotePortData['port']; - $remotePort = $qls->App->generateObjectPortName($remoteObjID, $remoteObjFace, $remoteObjDepth, $remoteObjPort); - $actionString = 'Deleted connection: '.$localPort.' to '.$remotePort.''; - $qls->App->logAction(3, 3, $actionString); - - } - - //include_once $_SERVER['DOCUMENT_ROOT'].'/includes/content-path.php'; + // Log history + $localPort = $qls->App->generateObjectPortName($objID, $objFace, $objDepth, $objPort); + $remotePort = $qls->App->generateObjectPortName($elementID, $elementFace, $elementDepth, $elementPort); + $actionString = 'Added connection: '.$localPort.' to '.$remotePort.''; + $qls->App->logAction(3, 1, $actionString); - //$validate->returnData['success']['pathFull'] = $qls->App->buildPathFull($path, false); - $validate->returnData['success']['peerPortID'] = $peerPortID; - $validate->returnData['success']['oldPeerPortID'] = $oldPeerPortID; - } + $validate->returnData['success']['peerPortID'] = $peerPortID; + $validate->returnData['success']['oldPeerPortID'] = $oldPeerPortID; + break; } } @@ -324,7 +333,7 @@ if($_SERVER['REQUEST_METHOD'] == 'POST'){ } function validate($data, &$validate, &$qls){ - $propertiesArray = array('connectorType', 'cableLength', 'cableMediaType', 'cableEditable', 'connectionScan', 'connectionExplore'); + $propertiesArray = array('connectorType', 'cableLength', 'cableMediaType', 'cableEditable', 'connectionScan', 'connectionExplore', 'connectionExploreClear'); //Validate property if($validate->validateInArray($data['property'], $propertiesArray, 'property type')) { @@ -377,48 +386,74 @@ function validate($data, &$validate, &$qls){ } } + } else if ($data['property'] == 'connectionExploreClear') { + } else if ($data['property'] == 'connectionExplore') { - $remotePortArray = explode('-', $data['value']); - $remoteID = $remotePortArray[1]; - $remoteFace = $remotePortArray[2]; - $remoteDepth = $remotePortArray[3]; - $remotePort = $remotePortArray[4]; + $remotePortDataArray = $data['value']; + $remotePortArray = array(); + if(is_array($remotePortDataArray)) { + foreach($remotePortDataArray as $remotePortDataString) { + $remotePortData = explode('-', $remotePortDataString); + $workingArray = array( + 'remoteID' => $remotePortData[1], + 'remoteFace' => $remotePortData[2], + 'remoteDepth' => $remotePortData[3], + 'remotePort' => $remotePortData[4] + ); + array_push($remotePortArray, $workingArray); + } + } $localID = $data['objID']; $localFace = $data['objFace']; $localDepth = $data['objDepth']; $localPort = $data['objPort']; - if($remoteID == $localID and $remoteFace == $localFace and $remoteDepth == $localDepth and $remotePort == $localPort) { - $errMsg = 'Cannot connect port to itself.'; - array_push($validate->returnData['error'], $errMsg); - } + foreach($remotePortArray as $remotePortData) { + + $remoteID = $remotePortData['remoteID']; + $remoteFace = $remotePortData['remoteFace']; + $remoteDepth = $remotePortData['remoteDepth']; + $remotePort = $remotePortData['remotePort']; + + // Validate port is not connected to itself + if($remoteID == $localID and $remoteFace == $localFace and $remoteDepth == $localDepth and $remotePort == $localPort) { + $errMsg = 'Cannot connect port to itself.'; + array_push($validate->returnData['error'], $errMsg); + } - // Validate connection peers are not endpoints which are trunked - $connectionPeerArray = array( - array($localID, $localFace, $localDepth, $localPort), - array($remoteID, $remoteFace, $remoteDepth, $remotePort) - ); - $validate->validateTrunkedEndpoint($connectionPeerArray); - - // Validate entitlement - $query = $qls->SQL->select('id', 'app_inventory', array('a_object_id' => array('>', 0), 'AND', 'b_object_id' => array('>', 0))); - $conNum = $qls->SQL->num_rows($query) + 1; - - if(!$qls->App->checkEntitlement('connection', $conNum)) { - $errMsg = 'Exceeded entitled connection count.'; - array_push($validate->returnData['error'], $errMsg); - } - - if(!isset($data['confirmed'])) { - if (isset($qls->App->inventoryArray[$remoteID][$remoteFace][$remoteDepth][$remotePort])) { - $validate->returnData['data']['confirmMsg'] = 'Overwrite existing connection?'; - $validate->returnData['confirm'] = true; + // Validate connection peers are not endpoints which are trunked + $connectionPeerArray = array( + array($localID, $localFace, $localDepth, $localPort), + array($remoteID, $remoteFace, $remoteDepth, $remotePort) + ); + $validate->validateTrunkedEndpoint($connectionPeerArray); + + // Validate no loops will result + if($qls->App->loopDetected($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])) { + $validate->returnData['data']['confirmMsg'] = 'Overwrite existing connection?'; + $validate->returnData['confirm'] = true; + } + } + + // Validate entitlement + $query = $qls->SQL->select('id', 'app_inventory', array('a_object_id' => array('>', 0), 'AND', 'b_object_id' => array('>', 0))); + $conNum = $qls->SQL->num_rows($query) + 1; + + if(!$qls->App->checkEntitlement('connection', $conNum)) { + $errMsg = 'Exceeded entitled connection count.'; + array_push($validate->returnData['error'], $errMsg); } } } - } return; } diff --git a/cableInventory.php b/cableInventory.php index 8de60f4..57bed2d 100755 --- a/cableInventory.php +++ b/cableInventory.php @@ -14,7 +14,7 @@ $qls->Security->check_auth_page('operator.php'); - +
diff --git a/demoInventory.php b/demoInventory.php deleted file mode 100755 index 6cf8fc2..0000000 --- a/demoInventory.php +++ /dev/null @@ -1,47 +0,0 @@ -Security->check_auth_page('administrator.php'); -?> - - - - - - - - - - - - - -
-
-

Cable Inventory

-
-
- -
-
-
- -
-
-
- - - - - - - - - - - - - - - diff --git a/diagram.php b/diagram.php index 657cefc..e1e670d 100755 --- a/diagram.php +++ b/diagram.php @@ -7,50 +7,13 @@ $qls->Security->check_auth_page('user.php'); - - - - + + + + - - - + diff --git a/environment.php b/environment.php index a2164d9..c2ac7b2 100755 --- a/environment.php +++ b/environment.php @@ -24,96 +24,7 @@ $qls->Security->check_auth_page('operator.php'); - - - - - - - + diff --git a/explore.php b/explore.php index 4f903af..290b797 100755 --- a/explore.php +++ b/explore.php @@ -7,151 +7,23 @@ $qls->Security->check_auth_page('user.php'); - - - - + + + + - - + + - - + + - - - + + + - - - - + diff --git a/includes/App.class.php b/includes/App.class.php index 41cedc1..712ab1d 100755 --- a/includes/App.class.php +++ b/includes/App.class.php @@ -289,7 +289,10 @@ var $qls; while($row = $this->qls->SQL->fetch_assoc($query)) { $this->inventoryAllArray[$row['id']] = $row; if($row['a_object_id'] != 0) { - $this->inventoryArray[$row['a_object_id']][$row['a_object_face']][$row['a_object_depth']][$row['a_port_id']] = array( + if(!isset($this->inventoryArray[$row['a_object_id']][$row['a_object_face']][$row['a_object_depth']][$row['a_port_id']])) { + $this->inventoryArray[$row['a_object_id']][$row['a_object_face']][$row['a_object_depth']][$row['a_port_id']] = array(); + } + array_push($this->inventoryArray[$row['a_object_id']][$row['a_object_face']][$row['a_object_depth']][$row['a_port_id']], array( 'rowID' => $row['id'], 'id' => $row['b_object_id'], 'face' => $row['b_object_face'], @@ -299,10 +302,13 @@ var $qls; 'localAttrPrefix' => 'a', 'remoteEndID' => $row['b_id'], 'remoteAttrPrefix' => 'b' - ); + )); } if($row['b_object_id'] != 0) { - $this->inventoryArray[$row['b_object_id']][$row['b_object_face']][$row['b_object_depth']][$row['b_port_id']] = array( + if(!isset($this->inventoryArray[$row['b_object_id']][$row['b_object_face']][$row['b_object_depth']][$row['b_port_id']])) { + $this->inventoryArray[$row['b_object_id']][$row['b_object_face']][$row['b_object_depth']][$row['b_port_id']] = array(); + } + array_push($this->inventoryArray[$row['b_object_id']][$row['b_object_face']][$row['b_object_depth']][$row['b_port_id']], array( 'rowID' => $row['id'], 'id' => $row['a_object_id'], 'face' => $row['a_object_face'], @@ -312,7 +318,7 @@ var $qls; 'localAttrPrefix' => 'b', 'remoteEndID' => $row['a_id'], 'remoteAttrPrefix' => 'a' - ); + )); } if($row['a_id'] != 0) { $this->inventoryByIDArray[$row['a_id']] = array( @@ -1846,26 +1852,28 @@ var $qls; } function clearInventoryTable($objID, $objFace, $objDepth, $objPort){ - if($inventoryEntry = $this->inventoryArray[$objID][$objFace][$objDepth][$objPort]) { - $rowID = $inventoryEntry['rowID']; - if($inventoryEntry['localEndID'] === 0 and $inventoryEntry['remoteEndID'] === 0) { - // If this is an unmanaged connection, delete the entry - $this->qls->SQL->delete('app_inventory', array('id' => array('=', $rowID))); - } else { - // If this is a managed connection, just clear the data - $attrPrefix = $inventoryEntry['localAttrPrefix']; - $set = array( - $attrPrefix.'_object_id' => 0, - $attrPrefix.'_object_face' => 0, - $attrPrefix.'_object_depth' => 0, - $attrPrefix.'_port_id' => 0 - ); - $this->qls->SQL->update('app_inventory', $set, array('id' => array('=', $rowID))); - if(isset($this->inventoryArray[$inventoryEntry['id']][$inventoryEntry['face']][$inventoryEntry['depth']][$inventoryEntry['port']])) { - $this->inventoryArray[$inventoryEntry['id']][$inventoryEntry['face']][$inventoryEntry['depth']][$inventoryEntry['port']]['id'] = 0; - $this->inventoryArray[$inventoryEntry['id']][$inventoryEntry['face']][$inventoryEntry['depth']][$inventoryEntry['port']]['face'] = 0; - $this->inventoryArray[$inventoryEntry['id']][$inventoryEntry['face']][$inventoryEntry['depth']][$inventoryEntry['port']]['depth'] = 0; - $this->inventoryArray[$inventoryEntry['id']][$inventoryEntry['face']][$inventoryEntry['depth']][$inventoryEntry['port']]['port'] = 0; + if($inventory = $this->inventoryArray[$objID][$objFace][$objDepth][$objPort]) { + foreach($inventory as $inventoryEntryIndex => $inventoryEntry) { + $rowID = $inventoryEntry['rowID']; + if($inventoryEntry['localEndID'] === 0 and $inventoryEntry['remoteEndID'] === 0) { + // If this is an unmanaged connection, delete the entry + $this->qls->SQL->delete('app_inventory', array('id' => array('=', $rowID))); + } else { + // If this is a managed connection, just clear the data + $attrPrefix = $inventoryEntry['localAttrPrefix']; + $set = array( + $attrPrefix.'_object_id' => 0, + $attrPrefix.'_object_face' => 0, + $attrPrefix.'_object_depth' => 0, + $attrPrefix.'_port_id' => 0 + ); + $this->qls->SQL->update('app_inventory', $set, array('id' => array('=', $rowID))); + if(isset($this->inventoryArray[$inventoryEntry['id']][$inventoryEntry['face']][$inventoryEntry['depth']][$inventoryEntry['port']][$inventoryEntryIndex])) { + $this->inventoryArray[$inventoryEntry['id']][$inventoryEntry['face']][$inventoryEntry['depth']][$inventoryEntry['port']][$inventoryEntryIndex]['id'] = 0; + $this->inventoryArray[$inventoryEntry['id']][$inventoryEntry['face']][$inventoryEntry['depth']][$inventoryEntry['port']][$inventoryEntryIndex]['face'] = 0; + $this->inventoryArray[$inventoryEntry['id']][$inventoryEntry['face']][$inventoryEntry['depth']][$inventoryEntry['port']][$inventoryEntryIndex]['depth'] = 0; + $this->inventoryArray[$inventoryEntry['id']][$inventoryEntry['face']][$inventoryEntry['depth']][$inventoryEntry['port']][$inventoryEntryIndex]['port'] = 0; + } } } unset($this->inventoryArray[$objID][$objFace][$objDepth][$objPort]); @@ -2532,19 +2540,21 @@ var $qls; } // Attr - code39 + $code39 = 0; + $connectionArray = array(); if(isset($this->inventoryArray[$objID][$objFace][$objDepth][$portIndex])) { - $connection = $this->inventoryArray[$objID][$objFace][$objDepth][$portIndex]; - $inventoryID = $connection['localEndID']; - $code39 = $this->inventoryByIDArray[$inventoryID]['localEndCode39']; - $attrAssocArray['data-code39'] = $code39; - - // Connected Object GlobalID - $connectedGlobalID = 'port-4-'.$connection['id'].'-'.$connection['face'].'-'.$connection['depth'].'-'.$connection['port']; - $attrAssocArray['data-connected-global-id'] = $connectedGlobalID; - } else { - $attrAssocArray['data-code39'] = 0; - $attrAssocArray['data-connected-global-id'] = 'none'; + $connectionArray = array(); + foreach($this->inventoryArray[$objID][$objFace][$objDepth][$portIndex] as $connection) { + $inventoryID = $connection['localEndID']; + $code39 = $this->inventoryByIDArray[$inventoryID]['localEndCode39']; + + // Connected Object GlobalID + $connectedGlobalID = 'port-4-'.$connection['id'].'-'.$connection['face'].'-'.$connection['depth'].'-'.$connection['port']; + array_push($connectionArray, $connectedGlobalID); + } } + $attrAssocArray['data-code39'] = $code39; + $attrAssocArray['data-connected-global-id'] = base64_encode(json_encode($connectionArray)); // Attr - title $attrAssocArray['title'] = $this->generatePortName($portNameFormat, $portIndex, $portTotal); @@ -3109,5 +3119,51 @@ var $qls; function unConvertHyphens($string){ return str_replace('‑', '-', $string); } - + + function loopDetected($aID, $aFace, $aDepth, $aPort, $bID, $bFace, $bDepth, $bPort){ + + // If cable is connected to an object + if($aID != 0) { + + // If object is trunked + if(isset($this->peerArray[$aID][$aFace][$aDepth])) { + $peerRecord = $this->peerArray[$aID][$aFace][$aDepth]; + + // If object's peer is not an endpoint + if(!$peerRecord['peerEndpoint']) { + $objID = $peerRecord['peerID']; + $objFace = $peerRecord['peerFace']; + $objDepth = $peerRecord['peerDepth']; + + // If peer has cable connected + if(isset($this->inventoryArray[$objID][$objFace][$objDepth][$aPort])) { + + foreach($this->inventoryArray[$objID][$objFace][$objDepth][$aPort] as $peerCable) { + $peerID = $peerCable['id']; + $peerFace = $peerCable['face']; + $peerDepth = $peerCable['depth']; + $peerPort = $peerCable['port']; + + $loopDetected = $this->loopDetected($peerID, $peerFace, $peerDepth, $peerPort, $objID, $objFace, $objDepth, $aPort); + if($loopDetected) { + return true; + } + } + + return false; + } else if($objID == $bID and $objFace == $bFace and $objDepth == $bDepth and $aPort == $bPort) { + return true; + } else { + return false; + } + } else { + return false; + } + } else { + return false; + } + } else { + return false; + } + } } \ No newline at end of file diff --git a/includes/content-object_tree_modal.php b/includes/content-object_tree_modal.php deleted file mode 100755 index 8bf1742..0000000 --- a/includes/content-object_tree_modal.php +++ /dev/null @@ -1,37 +0,0 @@ - - \ No newline at end of file diff --git a/includes/header_end.php b/includes/header_end.php index fb0c8e8..2f71cde 100755 --- a/includes/header_end.php +++ b/includes/header_end.php @@ -32,114 +32,3 @@
- - - - - - - - - - diff --git a/includes/modals.php b/includes/modals.php new file mode 100755 index 0000000..d938e8f --- /dev/null +++ b/includes/modals.php @@ -0,0 +1,951 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/index.php b/index.php index 200a042..e283712 100755 --- a/index.php +++ b/index.php @@ -6,13 +6,15 @@ $qls->Security->check_auth_page('user.php'); ?> - - - - - - + + + + + + + +
diff --git a/profile.php b/profile.php index a23061d..b6ae5b6 100755 --- a/profile.php +++ b/profile.php @@ -7,7 +7,7 @@ $qls->Security->check_auth_page('user.php'); - +
diff --git a/scan.php b/scan.php index 1011f8b..b046dea 100755 --- a/scan.php +++ b/scan.php @@ -6,84 +6,15 @@ $qls->Security->check_auth_page('operator.php'); ?> - - - - + + + + + - - - - +
diff --git a/settings.php b/settings.php index fa634a5..967bf3e 100755 --- a/settings.php +++ b/settings.php @@ -7,7 +7,7 @@ $qls->Security->check_auth_page('user.php'); - +
diff --git a/templates.php b/templates.php index 7ed88ed..75822ef 100755 --- a/templates.php +++ b/templates.php @@ -8,446 +8,19 @@ require_once './includes/content-templates.php'; - - - - - - + + + + + + - - - + + + - - - - - - - - - - - - - - - - - - +