function MakePath() { $this->MakeSafe(); //reset PathError $this->PathError = 0; //check devices/ports $device = new Device(); $device->DeviceID = $this->devID1; if (!$device->GetDevice()) { $this->PathError = 1; //dev1 does not exist return false; } $devType1 = $device->DeviceType; if ($device->DeviceType == "Patch Panel") { $this->PathError = 2; //dev1 is a Patch Pannel return false; } $port1 = new DevicePorts(); $port1->DeviceID = $this->devID1; $port1->PortNumber = $this->port1; if (!$port1->getPort()) { $this->PathError = 3; //dev1,port1 is missing return False; } if ($port1->ConnectedDeviceID > 0 && $port1->ConnectedPort > 0) { $this->PathError = 4; //dev1,port1 is connected return False; } $device->DeviceID = $this->devID2; if (!$device->GetDevice()) { $this->PathError = 5; //dev2 does not exist return false; } $devType2 = $device->DeviceType; if ($device->DeviceType == "Patch Panel") { $this->PathError = 6; //dev2 is a Patch Pannel return false; } $port2 = new DevicePorts(); $port2->DeviceID = $this->devID2; $port2->PortNumber = $this->port2; if (!$port2->getPort()) { $this->PathError = 7; //dev2,port2 is missing return False; } if ($port2->ConnectedDeviceID > 0 && $port2->ConnectedPort > 0) { $this->PathError = 8; //dev2,port2 is connected return False; } //get dev2 info $this->cab2 = $device->GetDeviceCabinetID(); //cab2 $cabinet = new Cabinet(); $cabinet->CabinetID = $this->cab2; $cabinet->GetCabinet(); $this->row2 = $cabinet->CabRowID; //row2 //if dev2 is panel protected device (connected to rear connection of a panel) $this->espejo2 = $port2->ConnectedDeviceID > 0 && $port2->ConnectedPort < 0; @unlink('ppath.log'); $this->escribe_log("**** NEW PATH ****"); $this->escribe_log("DEV1: ID=" . $this->devID1 . " PORT=" . $this->port1); $this->escribe_log("DEV2: ID=" . $this->devID2 . " PORT=" . $this->port2 . " CAB_ID=" . $this->cab2 . " ROW_ID=" . $this->row2); $this->escribe_log("-------------------"); //reset Path $this->ClearPath(); //initiate list with device1, port1, weitgh=0, prev_dev=0, prev_port=0 $this->AddNodeToList($this->devID1, $this->port1, 0, 0, 0); while ($this->SelectNode()) { if ($this->DeviceID == $this->devID2) { $this->escribe_log("Target found. Making the PATH..."); //make the path $i = 1; while ($this->DeviceID > 0) { $dev = $this->DeviceID; $port = $this->PortNumber; $Path[$i]["DeviceID"] = $dev; $Path[$i]["PortNumber"] = $port; $this->DeviceID = $this->nodes[$dev][$port]["prev_dev"]; $this->PortNumber = $this->nodes[$dev][$port]["prev_port"]; $i++; } for ($j = 1; $j < $i; $j++) { $this->Path[$j]["DeviceID"] = $Path[$i - $j]["DeviceID"]; $this->Path[$j]["PortNumber"] = $Path[$i - $j]["PortNumber"]; } $this->escribe_log("PATH created."); $this->escribe_log(""); return true; } $this->UpdateList(); } $this->PathError = 9; //not found return false; }
foreach ($dcList as $d) { $dcpicklist .= "<option value={$d->DataCenterID}>{$d->Name}</option>"; } $dcpicklist .= '</select>'; return $dcpicklist; } if (isset($_POST['action']) && $_POST['action'] == 'delete') { $port = new DevicePorts(); $ports = array(); // list of ports we want to remove $rights = "None"; for ($i = 1; $i < count($_POST["PortNumber"]); $i++) { if ($_POST["PortNumber"][$i] > 0) { $port->DeviceID = $_POST["DeviceID"][$i]; $port->PortNumber = $_POST["PortNumber"][$i]; $port->getPort(); $dev = new Device(); $dev->DeviceID = $port->DeviceID; $dev->GetDevice(); $rights = $dev->Rights == "Write" ? "Write" : $rights; //only remove connections between front ports if ($port->ConnectedPort > 0) { // Add to the list $ports[] = $port; } } } if ($rights == "Write") { foreach ($ports as $p) { $p->removeConnection(); }
$fp = ""; //front port Label $cPort = new DevicePorts(); if ($frontDev->DeviceID > 0) { $cPort->DeviceID = $frontDev->DeviceID; $cPort->PortNumber = $portList[$i]->ConnectedPort; $cPort->getPort(); $fp = $cPort->Label != "" ? $cPort->Label : $cPort->PortNumber; } $mt = isset($mediaTypes[$portList[$i]->MediaID]) ? $mediaTypes[$portList[$i]->MediaID]->MediaType : ''; // rear port Label if ($portList[-$i]->ConnectedPort != '') { $p = new DevicePorts(); $p->DeviceID = $portList[-$i]->ConnectedDeviceID; $p->PortNumber = $portList[-$i]->ConnectedPort; $p->getPort(); $rp = $p->Label == '' ? abs($p->PortNumber) : $p->Label; $p->PortNumber < 0 ? $rp .= ' (' . __("Rear") . ')' : ''; } else { $rp = ''; } $portList[$i]->Label = $portList[$i]->Label == '' ? $i : $portList[$i]->Label; print "\n\t\t\t\t<div data-port={$i}>\r\n\t\t\t\t\t<div id=\"fd{$i}\" data-default={$frontDev->DeviceID}><a href=\"devices.php?DeviceID={$frontDev->DeviceID}\">{$frontDev->Label}</a></div>\r\n\t\t\t\t\t<div id=\"fp{$i}\" data-default={$portList[$i]->ConnectedPort}><a href=\"paths.php?deviceid={$frontDev->DeviceID}&portnumber={$portList[$i]->ConnectedPort}\">{$fp}</a></div>\r\n\t\t\t\t\t<div id=\"fn{$i}\" data-default=\"{$portList[$i]->Notes}\">{$portList[$i]->Notes}</div>\r\n\t\t\t\t\t<div id=\"pp{$i}\">{$portList[$i]->Label}</div>\r\n\t\t\t\t\t<div id=\"mt{$i}\" data-default={$portList[$i]->MediaID} data-color={$portList[$i]->ColorID}>{$mt}</div>\r\n\t\t\t\t\t<div id=\"rd{$i}\" data-default={$rearDev->DeviceID}><a href=\"devices.php?DeviceID={$rearDev->DeviceID}\">{$rearDev->Label}</a></div>\r\n\t\t\t\t\t<div id=\"rp{$i}\" data-default={$portList[-$i]->ConnectedPort}><a href=\"paths.php?deviceid={$rearDev->DeviceID}&portnumber={$portList[-$i]->ConnectedPort}\">{$rp}</a></div>\r\n\t\t\t\t\t<div id=\"rn{$i}\" data-default=\"{$portList[-$i]->Notes}\">{$portList[-$i]->Notes}</div>\r\n\t\t\t\t</div>"; } print "\t\t\t</div><!-- END div.table -->\n\t\t</div>\n\t</div>\n"; } ?> <div class="caption"> <?php if ($write) { if ($dev->DeviceID > 0) {