function form_save() { if ($_POST["action_post"] == "script_edit") { /* cache all post field values */ init_post_field_cache(); $form_script["name"] = $_POST["name"]; $form_script["input_string"] = $_POST["input_string"]; $form_script["type_id"] = $_POST["type_id"]; field_register_error(api_script_field_validate($form_script, "|field|")); /* if the validation passes, save the row to the database */ if (!is_error_message()) { $script_id = api_script_save($_POST["id"], $form_script); } if ((is_error_message()) || (empty($_POST["id"]))) { header("Location: scripts.php?action=edit&id=" . (empty($script_id) ? $_POST["id"] : $script_id)); }else{ header("Location: scripts.php"); } /* submit button on the actions area page */ }else if ($_POST["action_post"] == "box-1") { $selected_rows = explode(":", $_POST["box-1-action-area-selected-rows"]); if ($_POST["box-1-action-area-type"] == "remove") { foreach ($selected_rows as $script_id) { api_script_remove($script_id); } }else if ($_POST["box-1-action-area-type"] == "duplicate") { // yet yet coded } header("Location: scripts.php"); /* 'filter' area at the bottom of the box */ }else if ($_POST["action_post"] == "script_list") { $get_string = ""; /* the 'clear' button wasn't pressed, so we should filter */ if (!isset($_POST["box-1-action-clear-button"])) { if (trim($_POST["box-1-search_filter"]) != "") { $get_string = ($get_string == "" ? "?" : "&") . "search_filter=" . urlencode($_POST["box-1-search_filter"]); } } header("Location: scripts.php$get_string"); } }
function package_script_import(&$xml_array, $package_id, $object_hash) { require_once(CACTI_BASE_PATH . "/lib/script/script_info.php"); require_once(CACTI_BASE_PATH . "/lib/script/script_update.php"); /* * XML Tag: <script> */ /* obtain a list of all script specific fields */ $script_fields = api_script_form_list(); if (isset($xml_array["script"])) { $save_fields = array(); /* tag the script as a package member */ $save_fields["package_id"] = $package_id; /* get the base fields from the xml */ foreach (array_keys($script_fields) as $field_name) { if (isset($xml_array["script"][$field_name])) { $save_fields[$field_name] = xml_character_decode($xml_array["script"][$field_name]); } } /* save the script to the database and register its new id */ $script_id = package_hash_update($object_hash, api_script_save(0, $save_fields)); if ($script_id === false) { return; } } /* * XML Tag: <fields> */ /* obtain a list of all data query field specific fields */ $script_field_fields = api_script_field_form_list(); if ((isset($xml_array["fields"])) && (is_array($xml_array["fields"]))) { /* loop through each available script field */ foreach ($xml_array["fields"] as $script_field_hash => $script_field) { $save_fields = array(); /* make sure that each field is associated with the new script */ $save_fields["data_input_id"] = $script_id; /* get the base fields from the xml */ foreach (array_keys($script_field_fields) as $field_name) { if (isset($script_field[$field_name])) { $save_fields[$field_name] = xml_character_decode($script_field[$field_name]); } } /* save the script field to the database and register its new id */ api_script_field_save(0, $save_fields); } } }