Example #1
0
function renderVLANDomainListEditor()
{
    function printNewItemTR()
    {
        printOpFormIntro('add');
        echo '<tr><td>';
        printImageHREF('create', 'create domain', TRUE, 104);
        echo '</td><td>';
        echo '<input type=text size=48 name=vdom_descr tabindex=102>';
        echo '</td><td>';
        printImageHREF('create', 'create domain', TRUE, 103);
        echo '</td></tr></form>';
    }
    echo '<table cellspacing=0 cellpadding=5 align=center class=widetable>';
    echo '<tr><th>&nbsp;</th><th>description</th><th>&nbsp;</th></tr>';
    if (getConfigVar('ADDNEW_AT_TOP') == 'yes') {
        printNewItemTR();
    }
    foreach (getVLANDomainStats() as $vdom_id => $dominfo) {
        printOpFormIntro('upd', array('vdom_id' => $vdom_id));
        echo '<tr><td>';
        if ($dominfo['switchc'] or $dominfo['vlanc'] > 1) {
            printImageHREF('nodestroy', 'domain used elsewhere');
        } else {
            echo getOpLink(array('op' => 'del', 'vdom_id' => $vdom_id), '', 'destroy', 'delete domain');
        }
        echo '</td><td><input name=vdom_descr type=text size=48 value="';
        echo niftyString($dominfo['description'], 0) . '">';
        echo '</td><td>';
        printImageHREF('save', 'update description', TRUE);
        echo '</td></tr></form>';
    }
    if (getConfigVar('ADDNEW_AT_TOP') != 'yes') {
        printNewItemTR();
    }
    echo '</table>';
}
function renderVLANDomainListEditor()
{
    function printNewItemTR()
    {
        printOpFormIntro('add');
        echo '<tr><td>';
        printImageHREF('create', 'create domain', TRUE);
        echo '</td><td>';
        echo '<input type=text size=48 name=vdom_descr>';
        echo '</td>&nbsp;<td>';
        echo '</td><td>';
        printImageHREF('create', 'create domain', TRUE);
        echo '</td></tr></form>';
    }
    $domain_list = getVLANDomainStats();
    $group_opts = array('existing groups' => array(0 => '-- no group --'));
    foreach ($domain_list as $vdom_id => $dominfo) {
        if ($dominfo['group_id']) {
            continue;
        }
        $key = $dominfo['subdomc'] ? 'existing groups' : 'create group';
        $group_opts[$key][$vdom_id] = $dominfo['description'];
    }
    echo '<table cellspacing=0 cellpadding=5 align=center class=widetable>';
    echo '<tr><th>&nbsp;</th><th>description</th><th>group</th><th>&nbsp;</th></tr>';
    if (getConfigVar('ADDNEW_AT_TOP') == 'yes') {
        printNewItemTR();
    }
    foreach ($domain_list as $vdom_id => $dominfo) {
        printOpFormIntro('upd', array('vdom_id' => $vdom_id));
        echo '<tr><td>';
        if ($dominfo['switchc'] or $dominfo['vlanc'] > 1) {
            printImageHREF('nodestroy', 'domain used elsewhere');
        } else {
            echo getOpLink(array('op' => 'del', 'vdom_id' => $vdom_id), '', 'destroy', 'delete domain');
        }
        echo '</td><td><input name=vdom_descr type=text size=48 value="';
        echo stringForTextInputValue($dominfo['description'], 255) . '">';
        echo '</td><td>';
        if ($dominfo['subdomc']) {
            printSelect(array(0 => 'a domain group'), array('name' => 'group_id'));
        } else {
            printNiftySelect($group_opts, array('name' => 'group_id'), intval($dominfo['group_id']));
        }
        echo '</td><td>';
        printImageHREF('save', 'update description', TRUE);
        echo '</td></tr></form>';
    }
    if (getConfigVar('ADDNEW_AT_TOP') != 'yes') {
        printNewItemTR();
    }
    echo '</table>';
}
Example #3
0
File: api.php Project: xtha/salt
 case 'get_ipv4network':
     require_once 'inc/init.php';
     genericAssertion('network_id', 'uint0');
     $range = spotEntity('ipv4net', $_REQUEST['network_id']);
     loadIPAddrList($range);
     sendAPIResponse($range);
     break;
     // get all VLAN domains
     //    UI equivalent: /index.php?page=
     //    UI handler: ()
 // get all VLAN domains
 //    UI equivalent: /index.php?page=
 //    UI handler: ()
 case 'get_vlan_domains':
     require_once 'inc/init.php';
     sendAPIResponse(getVLANDomainStats());
     break;
     // get VLANs in one domain
     //    UI equivalent: /index.php?page=
     //    UI handler: ()
 // get VLANs in one domain
 //    UI equivalent: /index.php?page=
 //    UI handler: ()
 case 'get_vlan_domain':
     require_once 'inc/init.php';
     assertUIntArg('domain_id');
     $domain = getDomainVLANs($_REQUEST['domain_id']);
     if (!$domain) {
         throw new EntityNotFoundException('domain_id', $_REQUEST['domain_id']);
     }
     sendAPIResponse($domain);
Example #4
0
function getAllVLANOptions($except_domains = array())
{
    $ret = array();
    foreach (getVLANDomainStats() as $domain) {
        if (!in_array($domain['id'], $except_domains)) {
            foreach (getDomainVLANs($domain['id']) as $vlan) {
                $ret[$domain['description']]["{$domain['id']}-{$vlan['vlan_id']}"] = "{$vlan['vlan_id']} ({$vlan['netc']}) {$vlan['vlan_descr']}";
            }
        }
    }
    return $ret;
}