function deleteVlan() { genericAssertion('vlan_ck', 'uint-vlan'); $confports = getVLANConfiguredPorts($_REQUEST['vlan_ck']); if (!empty($confports)) { throw new RackTablesError("You can not delete VLAN that has assosiated ports"); } list($vdom_id, $vlan_id) = decodeVLANCK($_REQUEST['vlan_ck']); usePreparedDeleteBlade('VLANDescription', array('domain_id' => $vdom_id, 'vlan_id' => $vlan_id)); showSuccess("VLAN {$vlan_id} has been deleted"); return buildRedirectURL('vlandomain', 'default', array('vdom_id' => $vdom_id)); }
function renderEditVlan($vlan_ck) { global $vtoptions; $vlan = getVLANInfo($vlan_ck); startPortlet('Modify'); printOpFormIntro('upd'); // static attributes echo '<table border=0 cellspacing=0 cellpadding=2 align=center>'; echo '<tr><th class=tdright>Name:</th><td class=tdleft>' . "<input type=text size=40 name=vlan_descr value='{$vlan['vlan_descr']}'>" . '</td></tr>'; echo '<tr><th class=tdright>Type:</th><td class=tdleft>' . getSelect($vtoptions, array('name' => 'vlan_type', 'tabindex' => 102), $vlan['vlan_prop']) . '</td></tr>'; echo '</table>'; echo '<p>'; echo '<input type="hidden" name="vdom_id" value="' . htmlspecialchars($vlan['domain_id'], ENT_QUOTES) . '">'; echo '<input type="hidden" name="vlan_id" value="' . htmlspecialchars($vlan['vlan_id'], ENT_QUOTES) . '">'; printImageHREF('SAVE', 'Update VLAN', TRUE); echo '</form><p>'; // get configured ports count $portc = 0; foreach (getVLANConfiguredPorts($vlan_ck) as $subarray) { $portc += count($subarray); } $clear_line = ''; $delete_line = ''; if ($portc) { $clear_line .= '<p>'; $clear_line .= getOpLink(array('op' => 'clear'), 'remove', 'clear', "remove this VLAN from {$portc} ports") . ' this VLAN from ' . mkA("{$portc} ports", 'vlan', $vlan_ck); } $reason = ''; if ($vlan['vlan_id'] == VLAN_DFL_ID) { $reason = "You can not delete default VLAN"; } elseif ($portc) { $reason = "Can not delete: {$portc} ports configured"; } if (!empty($reason)) { echo getOpLink(NULL, 'delete VLAN', 'nodestroy', $reason); } else { echo getOpLink(array('op' => 'del', 'vlan_ck' => $vlan_ck), 'delete VLAN', 'destroy'); } echo $clear_line; finishPortlet(); }