Exemple #1
0
function form_actions()
{
    global $colors, $config, $host_types_actions, $fields_hmib_host_types_edit;
    /* if we are to save this form, instead of display it */
    if (isset($_POST["selected_items"])) {
        $selected_items = unserialize(stripslashes($_POST["selected_items"]));
        if ($_POST["drp_action"] == "1") {
            /* delete */
            for ($i = 0; $i < count($selected_items); $i++) {
                /* ================= input validation ================= */
                input_validate_input_number($selected_items[$i]);
                /* ==================================================== */
                api_hmib_host_type_remove($selected_items[$i]);
            }
        } elseif ($_POST["drp_action"] == "2") {
            /* duplicate */
            for ($i = 0; $i < count($selected_items); $i++) {
                /* ================= input validation ================= */
                input_validate_input_number($selected_items[$i]);
                /* ==================================================== */
                hmib_duplicate_host_type($selected_items[$i], $i, $_POST["title_format"]);
            }
        }
        header("Location: hmib_types.php");
        exit;
    }
    /* setup some variables */
    $host_types_list = "";
    $i = 0;
    /* loop through each of the device types selected on the previous page and get more info about them */
    while (list($var, $val) = each($_POST)) {
        if (ereg("^chk_([0-9]+)\$", $var, $matches)) {
            /* ================= input validation ================= */
            input_validate_input_number($matches[1]);
            /* ==================================================== */
            $host_types_info = db_fetch_row("SELECT name FROM plugin_hmib_hrSystemTypes WHERE id=" . $matches[1]);
            $host_types_list .= "<li>" . $host_types_info["name"] . "</li>";
            $host_types_array[$i] = $matches[1];
        }
        $i++;
    }
    include_once "./include/top_header.php";
    html_start_box("<strong>" . $host_types_actions[$_POST["drp_action"]] . "</strong>", "60%", $colors["header_panel"], "3", "center", "");
    print "<form action='hmib_types.php' method='post'>\n";
    if ($_POST["drp_action"] == "1") {
        /* delete */
        print "\t<tr>\n\t\t\t\t<td class='textArea' bgcolor='#" . $colors["form_alternate1"] . "'>\n\t\t\t\t\t<p>Are you sure you want to delete the following Host Type(s)?</p>\n\t\t\t\t\t<p><ul>{$host_types_list}</ul></p>\n\t\t\t\t</td>\n\t\t\t</tr>\n\n\t\t\t";
    } elseif ($_POST["drp_action"] == "2") {
        /* duplicate */
        print "\t<tr>\n\t\t\t\t<td class='textArea' bgcolor='#" . $colors["form_alternate1"] . "'>\n\t\t\t\t\t<p>When you click save, the following Host Type(s) will be duplicated. You may optionally\n\t\t\t\t\tchange the description for the new Host Types.  Otherwise, do not change value below and the\n\t\t\t\t\toriginal name will be replicated with a new suffix.</p>\n\t\t\t\t\t<p><ul>{$host_types_list}</ul></p>\n\t\t\t\t\t<p><strong>Host Type Prefix:</strong><br>";
        form_text_box("title_format", "<description> (1)", "", "255", "30", "text");
        print "</p>\n\t\t\t\t</td>\n\t\t\t</tr>\n\n\t\t\t";
    }
    if (!isset($host_types_array)) {
        print "<tr><td bgcolor='#" . $colors["form_alternate1"] . "'><span class='textError'>You must select at least one Host Type.</span></td></tr>\n";
        $save_html = "";
    } else {
        $save_html = "<input type='submit' value='Yes' name='save'>";
    }
    print "\t<tr>\n\t\t\t<td colspan='2' align='right' bgcolor='#eaeaea'>\n\t\t\t\t<input type='hidden' name='action' value='actions'>\n\t\t\t\t<input type='hidden' name='selected_items' value='" . (isset($host_types_array) ? serialize($host_types_array) : '') . "'>\n\t\t\t\t<input type='hidden' name='drp_action' value='" . $_POST["drp_action"] . "'>" . (strlen($save_html) ? "\n\t\t\t\t<input type='submit' name='cancel' value='No'>\n\t\t\t\t{$save_html}" : "<input type='submit' name='cancel' value='Return'>") . "\n\t\t\t</td>\n\t\t</tr>\n\t\t";
    html_end_box();
    include_once "./include/bottom_footer.php";
}
Exemple #2
0
function form_actions()
{
    global $config, $host_types_actions, $fields_hmib_host_types_edit;
    /* ================= input validation ================= */
    get_filter_request_var('drp_action');
    /* ==================================================== */
    /* if we are to save this form, instead of display it */
    if (isset_request_var('selected_items')) {
        $selected_items = sanitize_unserialize_selected_items(get_nfilter_request_var('selected_items'));
        if ($selected_items != false) {
            if (get_request_var('drp_action') == '1') {
                /* delete */
                foreach ($selected_items as $item) {
                    api_hmib_host_type_remove($item);
                }
            } elseif (get_request_var('drp_action') == '2') {
                /* duplicate */
                foreach ($selected_items as $item) {
                    hmib_duplicate_host_type($item, $i, get_request_var('title_format'));
                }
            }
        }
        header('Location: hmib_types.php?heder=false');
        exit;
    }
    /* setup some variables */
    $host_types_list = '';
    $i = 0;
    /* loop through each of the device types selected on the previous page and get more info about them */
    while (list($var, $val) = each($_POST)) {
        if (preg_match('/^chk_([0-9]+)$/', $var, $matches)) {
            /* ================= input validation ================= */
            input_validate_input_number($matches[1]);
            /* ==================================================== */
            $host_types_info = db_fetch_row('SELECT name FROM plugin_hmib_hrSystemTypes WHERE id=' . $matches[1]);
            $host_types_list .= '<li>' . $host_types_info['name'] . '</li>';
            $host_types_array[$i] = $matches[1];
        }
        $i++;
    }
    top_header();
    form_start('hmib_types.php');
    html_start_box($host_types_actions[get_request_var('drp_action')], '60%', '', '3', 'center', '');
    if (get_filter_request_var('drp_action') == '1') {
        /* delete */
        print "\t<tr>\n\t\t\t\t<td class='textArea'>\n\t\t\t\t\t<p>" . __('Click \'Continue\' to Delete the following Host Type(s)') . "</p>\n\t\t\t\t\t<p><ul>{$host_types_list}</ul></p>\n\t\t\t\t</td>\n\t\t\t</tr>\n";
        $save_html = "<input type='button' value='" . __('Cancel') . "' onClick='cactiReturnTo()'>&nbsp;<input type='submit' value='" . __('Continue') . "' title='" . __('Delete Host Type(s)') . "'>";
    } elseif (get_filter_request_var('drp_action') == '2') {
        /* duplicate */
        print "\t<tr>\n\t\t\t\t<td class='textArea'>\n\t\t\t\t\t<p>" . __('Click \'Continue\' to Duplicate the following Host Type(s). You may optionally change the description for the new Host Type(s).  Otherwise, do not change value below and the original name will be replicated with a new suffix.') . "</p>\n\t\t\t\t\t<p><ul>{$host_types_list}</ul></p>\n\t\t\t\t\t<p><strong>" . __('Host Type Prefix:') . "</strong><br>";
        form_text_box('title_format', '<description> (1)', '', '255', '30', 'text');
        print "</p>\n\t\t\t\t</td>\n\t\t\t</tr>\n";
        $save_html = "<input type='button' value='" . __('Cancel') . "' onClick='cactiReturnTo()'>&nbsp;<input type='submit' value='" . __('Continue') . "' title='" . __('Duplicate Host Type(s)') . "'>";
    }
    if (!isset($host_types_array)) {
        print "<tr><td class='odd'><span class='textError'>" . __('You must select at least one Host Type.') . "</span></td></tr>\n";
        $save_html = "<input type='button' value='" . __('Cancel') . "' onClick='cactiReturnTo()'>";
    } else {
    }
    print "<tr class='even'>\n\t\t<td colspan='2' class='saveRow'>\n\t\t\t<input type='hidden' name='action' value='actions'>\n\t\t\t<input type='hidden' name='selected_items' value='" . (isset($host_types_array) ? serialize($host_types_array) : '') . "'>\n\t\t\t<input type='hidden' name='drp_action' value='" . get_request_var('drp_action') . "'>\n\t\t\t{$save_html}\n\t\t</td>\n\t</tr>\n";
    html_end_box();
    form_end();
    bottom_footer();
}