diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index e48c7c83db..032eca0a92 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,12 @@ +2014-01-22 Miguel de Dios + + * godmode/reporting/reporting_builder.item_editor.php, + include/constants.php, include/functions_reporting.php: added + constants and killed magic numbers and unicorns. + + * include/functions_modules.php: added function + "modules_get_modules_in_group". + 2014-01-21 Sergio Martin * images/long_arrow.png diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index d79f14afbe..6c0c6b8bda 100644 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -915,11 +915,14 @@ html_print_input_hidden('id_item', $idItem); diff --git a/pandora_console/include/constants.php b/pandora_console/include/constants.php index f6b2a452e8..7bed8af604 100644 --- a/pandora_console/include/constants.php +++ b/pandora_console/include/constants.php @@ -317,6 +317,10 @@ define ('REPORT_EXCEPTION_CONDITION_NE', 8); define ('REPORT_EXCEPTION_CONDITION_OK', 3); define ('REPORT_EXCEPTION_CONDITION_NOT_OK', 4); +define ('REPORT_ITEM_ORDER_BY_AGENT_NAME', 3); +define ('REPORT_ITEM_ORDER_BY_ASCENDING', 2); +define ('REPORT_ITEM_ORDER_BY_DESCENDING', 1); + /* POLICIES */ define("POLICY_UPDATED", 0); diff --git a/pandora_console/include/functions_modules.php b/pandora_console/include/functions_modules.php index eec258fadc..5c389e53a3 100644 --- a/pandora_console/include/functions_modules.php +++ b/pandora_console/include/functions_modules.php @@ -1109,6 +1109,49 @@ function modules_get_monitors_in_group ($id_group) { return db_get_all_rows_sql ($sql); } +/** + * Get all the modules defined in an group. + * + * @param int $id_group Group id to get all the modules. + * + * @return array An array with all the modules defined in the group (tagente_modulo). + */ +function modules_get_modules_in_group ($id_group) { + global $config; + + if ($id_group <= 0) { + //We select all groups the user has access to if it's 0 or -1 + global $config; + $id_group = array_keys (users_get_groups ($config['id_user'])); + } + + if (is_array ($id_group)) { + $id_group = implode (",",$id_group); + } + + switch ($config["dbtype"]) { + case "mysql": + $sql = sprintf ("SELECT `tagente_modulo`.* + FROM `tagente_modulo`, `ttipo_modulo`, `tagente` + WHERE `id_tipo_modulo` = `id_tipo` + AND `tagente`.`id_agente` = `tagente_modulo`.`id_agente` + AND `tagente`.`id_grupo` IN (%s) + ORDER BY `tagente`.`nombre`", $id_group); + break; + case "postgresql": + case "oracle": + $sql = sprintf ("SELECT tagente_modulo.* + FROM tagente_modulo, ttipo_modulo, tagente + WHERE id_tipo_modulo = id_tipo + AND tagente.id_agente = tagente_modulo.id_agente + AND tagente.id_grupo IN (%s) + ORDER BY tagente.nombre", $id_group); + break; + } + + return db_get_all_rows_sql ($sql); +} + /** * Get all the monitors defined in an agent. * diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 1212547898..a9b8d42188 100644 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -4966,15 +4966,15 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f // Put description at the end of the module (if exists) $table->colspan[1][0] = 3; - if ($content["description"] != ""){ + if ($content["description"] != "") { $data_desc = array(); $data_desc[0] = $content["description"]; array_push ($table->data, $data_desc); } //Get all the related data - $sql = sprintf("select id_agent_module, server_name - from treport_content_item - where id_report_content = %d", $content['id_rc']); + $sql = sprintf("SELECT id_agent_module, server_name + FROM treport_content_item + WHERE id_report_content = %d", $content['id_rc']); $tops = db_process_sql ($sql); @@ -5000,6 +5000,7 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f //Get data of all agents (before to slide to N values) $data_top = array(); + foreach ($tops as $key => $row) { //Metaconsole connection @@ -5014,7 +5015,8 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f $ag_name = modules_get_agentmodule_agent_name($row ['id_agent_module']); $mod_name = modules_get_agentmodule_name ($row ['id_agent_module']); - $unit = db_get_value('unit', 'tagente_modulo', 'id_agente_modulo', $row ['id_agent_module']); + $unit = db_get_value('unit', 'tagente_modulo', + 'id_agente_modulo', $row ['id_agent_module']); switch ($top_n) {