Example #1
0
function intSetAllIPpoolNames(&$smarty)
{
    /*	set all available ippool names in "ippool_names" variable into smarty object
    */
    $ippool_list_req = new GetIPpoolNames();
    list($success, $ippool_names) = $ippool_list_req->send();
    if ($success) {
        $smarty->assign("ippool_names", $ippool_names);
    } else {
        $smarty->assign("ippool_names", array());
        $smarty->set_page_error($ippool_names->gerErrorMsgs());
    }
}
function smarty_function_ippool_names_select($params, &$smarty)
{
    /* return string of html select code for ippool 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 . "ippool.php";
    $req = new GetIPpoolNames();
    $resp = $req->sendAndRecv();
    if ($resp->isSuccessful()) {
        $names = $resp->getResult();
    } else {
        $names = array();
    }
    if (isset($params["add_empty"]) and $params["add_empty"] == "TRUE") {
        $names[] = "";
    }
    $selected = getSelectedAttrFromSmartyParams($smarty, $params);
    $select_arr = array("selected" => $selected, "output" => $names, "values" => $names, "name" => $params["name"]);
    if (isset($params["id"])) {
        $select_arr["id"] = $params["id"];
    }
    return smarty_function_html_options($select_arr, $smarty);
}
Example #3
0
function getIPpoolInfos()
{
    /*    
       Return an array of all ip pool infos in format (ippool_name=>associative_ippool_info_array)
    */
    $ippool_list_req = new GetIPpoolNames();
    list($success, $ippool_names) = $ippool_list_req->send();
    if (!$success) {
        return array(FALSE, $ippool_names);
    } else {
        $ippools_info = array();
        $ippool_info_req = new GetIPpoolInfo("");
        foreach ($ippool_names as $ippool_name) {
            $ippool_info_req->changeParam("ippool_name", $ippool_name);
            list($success, $ippool_info) = $ippool_info_req->send();
            if (!$success) {
                return array(FALSE, $ippool_info);
            } else {
                $ippools_info[$ippool_name] = $ippool_info;
            }
        }
        return array(TRUE, $ippools_info);
    }
}