Exemplo n.º 1
0
function intSetRasAndPorts(&$smarty)
{
    /*
        Get Ras IPs and Ports from core, and assign them to smarty object variable name "rases"
        rases is and associative array with key as ras ip addess and values as ports arrays
        rases=array(ras_ip=>ports_array,...)
        ports_array=array(port1_name,port2_name,...)
    */
    $rases = array();
    $rases_ip_req = new GetActiveRasIPs();
    list($success, $ras_ips) = $rases_ip_req->send();
    if (!$success) {
        $smarty->set_page_error($ras_ips->getErrorMsgs());
    } else {
        $ras_ports_req = new GetRasPorts("");
        foreach ($ras_ips as $ras_ip) {
            $ras_ports_req->changeParam("ras_ip", $ras_ip);
            list($success, $ports) = $ras_ports_req->send();
            if (!$success) {
                $smarty->set_page_error($ports->getErrorMsgs());
                break;
            }
            $rases[$ras_ip] = $ports;
        }
    }
    $smarty->assign("rases", $rases);
}
function smarty_function_ras_ips_select($params, &$smarty)
{
    /* return string of html select code for ras ips selects.
    
        parameter name(string,required): html select name
        parameter id(string,optional): set optional dom ID
        parameter add_empty(boolean,optional): add an empty entry in select
    
    
        parameter default_var(string,optional): see getSelectedAttrFromSmartyParams comments
        parameter default_request(string,optional):
        parameter default_smarty(string,optional):
        parameter default(string,optional)
        parameter target(string,optional):
    
        
    */
    require_once $smarty->_get_plugin_filepath('function', 'html_options');
    require_once IBSINC . "ras.php";
    $req = new GetActiveRasIPs();
    $resp = $req->sendAndRecv();
    if ($resp->isSuccessful()) {
        $ips = $resp->getResult();
    } else {
        $ips = array();
    }
    if (isset($params["add_empty"]) and $params["add_empty"] == "TRUE") {
        $ips[] = "";
    }
    $selected = getSelectedAttrFromSmartyParams($smarty, $params);
    $select_arr = array("selected" => $selected, "output" => $ips, "values" => $ips, "name" => $params["name"]);
    if (isset($params["id"])) {
        $select_arr["id"] = $params["id"];
    }
    return smarty_function_html_options($select_arr, $smarty);
}
function createRasTable(&$smarty, $prefix)
{
    $req = new GetActiveRasIPs();
    $resp = $req->sendAndRecv();
    if ($resp->isSuccessful()) {
        $content = "";
        $i = 0;
        foreach ($resp->getResult() as $ras_ip) {
            if ($i % 4 == 0) {
                $content .= smarty_function_multiTableTR(array(), $smarty);
            }
            $checked = checkBoxValue("{$prefix}_{$i}");
            $content .= smarty_block_multiTableTD(array("type" => "left", "width" => "25%"), "<input type=checkbox name='{$prefix}_{$i}' value='{$ras_ip}' {$checked}>", $smarty);
            $content .= smarty_block_multiTableTD(array("type" => "right", "width" => "25%"), "{$ras_ip}", $smarty);
            $i++;
        }
        $content .= smarty_function_multiTablePad(array("last_index" => $i - 1, "go_until" => 4, "width" => "25%"), $smarty);
        $content = smarty_block_multiTable(array(), $content, $smarty);
    } else {
        $err = $resp->getError();
        $content = $err->getErrorMsg();
    }
    return $content;
}
Exemplo n.º 4
0
function getAllActiveRasInfos()
{
    /*
    	return a list of associative dictionaries containing all active ras informations
    */
    $ras_infos = array();
    $ras_ips_request = new GetActiveRasIPs();
    list($success, $ras_ips) = $ras_ips_request->send();
    if (!$success) {
        return array(FALSE, $ras_ips);
    }
    $ras_info_request = new GetRasInfo("");
    foreach ($ras_ips as $ras_ip) {
        $ras_info_request->changeParam("ras_ip", $ras_ip);
        list($success, $ras_info) = $ras_info_request->send();
        if (!$success) {
            return array(FALSE, $ras_info);
        }
        $ras_infos[] = $ras_info;
    }
    return array(TRUE, $ras_infos);
}