function api_data_template_suggested_values_save($data_template_id, $_fields_suggested_values) { require_once(CACTI_BASE_PATH . "/lib/sys/sequence.php"); /* sanity checks */ validate_id_die($data_template_id, "data_template_id"); /* insert the new custom field values */ if (is_array($_fields_suggested_values) > 0) { foreach ($_fields_suggested_values as $field_name => $field_array) { foreach ($field_array as $field_item) { if (empty($field_item["id"])) { db_insert("data_template_suggested_value", array( "id" => array("type" => DB_TYPE_INTEGER, "value" => "0"), "data_template_id" => array("type" => DB_TYPE_INTEGER, "value" => $data_template_id), "field_name" => array("type" => DB_TYPE_STRING, "value" => $field_name), "value" => array("type" => DB_TYPE_STRING, "value" => $field_item["value"]), "sequence" => array("type" => DB_TYPE_INTEGER, "value" => seq_get_current(0, "sequence", "data_template_suggested_value", "data_template_id = " . sql_sanitize($data_template_id) . " and field_name = '" . sql_sanitize($field_name) . "'")) ), array("id")); }else{ db_update("data_template_suggested_value", array( "id" => array("type" => DB_TYPE_INTEGER, "value" => $field_item["id"]), "value" => array("type" => DB_TYPE_STRING, "value" => $field_item["value"]) ), array("id")); } } } } }
function api_graph_template_item_save($graph_template_item_id, $_fields_graph_item) { require_once(CACTI_BASE_PATH . "/lib/sys/sequence.php"); require_once(CACTI_BASE_PATH . "/lib/graph_template/graph_template_info.php"); /* sanity checks */ validate_id_die($graph_template_item_id, "graph_template_item_id", true); /* make sure that there is at least one field to save */ if (sizeof($_fields_graph_item) == 0) { return false; } /* sanity check for $graph_template_id */ if ((empty($graph_template_item_id)) && (empty($_fields_graph_item["graph_template_id"]))) { log_save("Required graph_template_id when graph_template_item_id = 0", SEV_ERROR); return false; } else if ((isset($_fields_graph_item["graph_template_id"])) && (!db_integer_validate($_fields_graph_item["graph_template_id"]))) { return false; } /* field: id */ $_fields["id"] = array("type" => DB_TYPE_INTEGER, "value" => $graph_template_item_id); /* field: graph_template_id */ if (!empty($_fields_graph_item["graph_template_id"])) { $_fields["graph_template_id"] = array("type" => DB_TYPE_INTEGER, "value" => $_fields_graph_item["graph_template_id"]); } /* field: sequence */ if (empty($graph_template_item_id)) { $_fields["sequence"] = array("type" => DB_TYPE_INTEGER, "value" => seq_get_current($graph_template_item_id, "sequence", "graph_template_item", "graph_template_id = " . sql_sanitize($_fields_graph_item["graph_template_id"]))); } /* convert the input array into something that is compatible with db_replace() */ $_fields += sql_get_database_field_array($_fields_graph_item, api_graph_template_item_form_list()); if (db_replace("graph_template_item", $_fields, array("id"))) { if (empty($graph_template_item_id)) { $graph_template_item_id = db_fetch_insert_id(); } return $graph_template_item_id; }else{ return false; } }
function api_graph_item_save($graph_item_id, &$_fields_graph_item) { require_once(CACTI_BASE_PATH . "/lib/sys/sequence.php"); require_once(CACTI_BASE_PATH . "/lib/graph/graph_info.php"); /* sanity check for $graph_item_id */ if (!is_numeric($graph_item_id)) { return false; } /* sanity check for $graph_id */ if ((empty($graph_item_id)) && (empty($_fields_graph_item["graph_id"]))) { log_save("Required graph_id when graph_item_id = 0", SEV_ERROR); return false; } else if ((isset($_fields_graph_item["graph_id"])) && (!is_numeric($_fields_graph_item["graph_id"]))) { return false; } /* field: id */ $_fields["id"] = array("type" => DB_TYPE_INTEGER, "value" => $graph_item_id); /* field: graph_id */ if (!empty($_fields_graph_item["graph_id"])) { $_fields["graph_id"] = array("type" => DB_TYPE_INTEGER, "value" => $_fields_graph_item["graph_id"]); } /* field: graph_template_item_id */ if (isset($_fields_graph_item["graph_template_item_id"])) { $_fields["graph_template_item_id"] = array("type" => DB_TYPE_INTEGER, "value" => $_fields_graph_item["graph_template_item_id"]); } /* field: sequence */ if (empty($graph_item_id)) { $_fields["sequence"] = array("type" => DB_TYPE_INTEGER, "value" => seq_get_current($_fields_graph_item["id"], "sequence", "graph_item", "graph_id = " . sql_sanitize($_fields_graph_item["graph_id"]))); } /* check for an empty field list */ if (sizeof($_fields) == 1) { return true; } /* convert the input array into something that is compatible with db_replace() */ $_fields += sql_get_database_field_array($_fields_graph_item, api_graph_item_form_list()); if (db_replace("graph_item", $_fields, array("id"))) { return true; }else{ return false; } }