function update_data_query_sort_cache($host_id, $data_query_id) { $raw_xml = get_data_query_array($data_query_id); /* get a list of valid data query types */ $valid_index_types = get_ordered_index_type_list($host_id, $data_query_id); /* something is probably wrong with the data query */ if (sizeof($valid_index_types) == 0) { $sort_field = ""; } else { /* grab the first field off the list */ $sort_field = $valid_index_types[0]; } /* substitute variables */ if (isset($raw_xml["index_title_format"])) { $title_format = str_replace("|chosen_order_field|", "|query_{$sort_field}|", $raw_xml["index_title_format"]); } else { $title_format = "|query_{$sort_field}|"; } /* update the cache */ /* TODO: if both $sort field AND $title_format are empty, this yields funny results */ db_execute("UPDATE host_snmp_query SET sort_field = '{$sort_field}', title_format = '{$title_format}' WHERE host_id = '{$host_id}' AND snmp_query_id = '{$data_query_id}'"); }
function update_data_query_sort_cache($host_id, $data_query_id) { $raw_xml = get_data_query_array($data_query_id); /* get a list of valid data query types */ $valid_index_types = get_ordered_index_type_list($host_id, $data_query_id); /* something is probably wrong with the data query */ if (sizeof($valid_index_types) == 0) { $sort_field = ""; }else{ /* grab the first field off the list */ $sort_field = $valid_index_types[0]; } /* substitute variables */ if (isset($raw_xml["index_title_format"])) { $title_format = str_replace("|chosen_order_field|", "|query_$sort_field|", $raw_xml["index_title_format"]); }else{ $title_format = "|query_$sort_field|"; } /* update the cache */ db_execute("update host_snmp_query set sort_field = '$sort_field', title_format = '$title_format' where host_id = '$host_id' and snmp_query_id = '$data_query_id'"); }
function update_data_query_sort_cache($host_id, $data_query_id) { require_once(CACTI_BASE_PATH . "/lib/data_query/data_query_info.php"); /* sanity check for $host_id */ if ((!is_numeric($host_id)) || (empty($host_id))) { log_save("Invalid input '$host_id' for 'host_id' in " . __FUNCTION__ . "()", SEV_ERROR); return false; } /* sanity check for $data_query_id */ if ((!is_numeric($data_query_id)) || (empty($data_query_id))) { log_save("Invalid input '$data_query_id' for 'data_query_id' in " . __FUNCTION__ . "()", SEV_ERROR); return false; } /* retrieve information about this data query */ $data_query = api_data_query_get($data_query_id); /* get a list of valid data query types */ $valid_index_types = get_ordered_index_type_list($data_query_id, $host_id); /* something is probably wrong with the data query */ if (sizeof($valid_index_types) == 0) { $sort_field = ""; }else{ /* grab the first field off the list */ list($sort_field, $sort_field_formatted) = each($valid_index_types); } /* substitute variables */ if (isset($raw_xml["index_title_format"])) { $title_format = str_replace("|chosen_order_field|", "|query_$sort_field|", $data_query["index_title_format"]); }else{ $title_format = "|query_$sort_field|"; } /* update the cache */ db_update("host_data_query", array( "sort_field" => array("type" => DB_TYPE_STRING, "value" => $sort_field), "title_format" => array("type" => DB_TYPE_STRING, "value" => $title_format), "host_id" => array("type" => DB_TYPE_INTEGER, "value" => $host_id), "data_query_id" => array("type" => DB_TYPE_INTEGER, "value" => $data_query_id) ), array("host_id", "data_query_id")); }