function api_graph_tree_list($filter_array = "", $current_page = 0, $rows_per_page = 0) { require_once(CACTI_BASE_PATH . "/lib/graph_tree/graph_tree_form.php"); $sql_where = ""; /* validation and setup for the WHERE clause */ if ((is_array($filter_array)) && (sizeof($filter_array) > 0)) { /* validate each field against the known master field list */ $field_errors = api_graph_tree_fields_validate(sql_filter_array_to_field_array($filter_array)); /* if a field input error has occured, register the error in the session and return */ if (sizeof($field_errors) > 0) { field_register_error($field_errors); return false; /* otherwise, form an SQL WHERE string using the filter fields */ }else{ $sql_where = sql_filter_array_to_where_string($filter_array, api_graph_tree_form_list(), true); } } $sql_limit = ""; /* validation and setup for the LIMIT clause */ if ((is_numeric($current_page)) && (is_numeric($rows_per_page)) && (!empty($current_page)) && (!empty($rows_per_page))) { $sql_limit = "limit " . ($rows_per_page * ($current_page - 1)) . ",$rows_per_page"; } return db_fetch_assoc("select graph_tree.id, graph_tree.name, graph_tree.sort_type from graph_tree $sql_where order by name $sql_limit"); }
function form_save() { if ($_POST["action_post"] == "graph_tree_edit") { /* cache all post field values */ init_post_field_cache(); $form_graph_tree["name"] = $_POST["name"]; $form_graph_tree["sort_type"] = $_POST["sort_type"]; /* validate graph tree preset fields */ field_register_error(api_graph_tree_fields_validate($form_graph_tree, "|field|")); if (!is_error_message()) { $graph_tree_id = api_graph_tree_save($_POST["id"], $form_graph_tree); } if (is_error_message()) { header("Location: graph_trees.php?action=edit" . (empty($graph_tree_id) ? "" : "&id={$graph_tree_id}")); } else { header("Location: graph_trees.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 $graph_tree_id) { api_graph_tree_remove($graph_tree_id); } } else { if ($_POST["box-1-action-area-type"] == "duplicate") { // yet yet coded } } header("Location: graph_trees.php"); /* 'filter' area at the bottom of the box */ } else { if ($_POST["action_post"] == "graph_tree_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: graph_trees.php{$get_string}"); } } } }