From d777cd8f94368eede50af463ed6a80450a5d78ba Mon Sep 17 00:00:00 2001 From: zarzuelo Date: Tue, 22 May 2012 12:23:49 +0000 Subject: [PATCH] 2012-05-22 Sergio Martin * include/functions_reporting.php include/ajax/agent.php include/functions_io.php include/constants.php operation/agentes/ver_agente.php godmode/groups/group_list.php godmode/reporting/reporting_builder.list_items.php godmode/reporting/graph_builder.graph_editor.php godmode/reporting/reporting_builder.item_editor.php: Change the metaconsole error controls to adapt the calls to last changes Clean code git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6334 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 14 +++++++++++++ pandora_console/godmode/groups/group_list.php | 2 +- .../reporting/graph_builder.graph_editor.php | 2 +- .../reporting_builder.item_editor.php | 10 +++++----- .../reporting_builder.list_items.php | 2 +- pandora_console/include/ajax/agent.php | 4 ++-- pandora_console/include/constants.php | 3 +++ pandora_console/include/functions_io.php | 18 ++++++++--------- .../include/functions_reporting.php | 20 +++++++++---------- .../operation/agentes/ver_agente.php | 4 ++-- 10 files changed, 48 insertions(+), 31 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index d9ac5b713b..ea15e7e9b5 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,17 @@ +2012-05-22 Sergio Martin + + * include/functions_reporting.php + include/ajax/agent.php + include/functions_io.php + include/constants.php + operation/agentes/ver_agente.php + godmode/groups/group_list.php + godmode/reporting/reporting_builder.list_items.php + godmode/reporting/graph_builder.graph_editor.php + godmode/reporting/reporting_builder.item_editor.php: Change the + metaconsole error controls to adapt the calls to last changes + Clean code + 2012-05-22 Sancho Lerena * include/functions_ui.php: Added definition for module unknown. diff --git a/pandora_console/godmode/groups/group_list.php b/pandora_console/godmode/groups/group_list.php index e68d166379..ce67889e46 100644 --- a/pandora_console/godmode/groups/group_list.php +++ b/pandora_console/godmode/groups/group_list.php @@ -100,7 +100,7 @@ if (is_ajax ()) { $connection_result = enterprise_hook('metaconsole_load_external_db', array($connection_data)); - if ($connection_result) { + if ($connection_result == NOERR) { $agents_tmp = agents_get_group_agents ($id_group, $filter, "none", false, $recursion); if ($agents_tmp === false) diff --git a/pandora_console/godmode/reporting/graph_builder.graph_editor.php b/pandora_console/godmode/reporting/graph_builder.graph_editor.php index 25b9219448..5d95288dd4 100644 --- a/pandora_console/godmode/reporting/graph_builder.graph_editor.php +++ b/pandora_console/godmode/reporting/graph_builder.graph_editor.php @@ -144,7 +144,7 @@ echo ""; $connection_result = enterprise_hook('metaconsole_load_external_db', array($connection_data)); - if ($connection_result) { + if ($connection_result == NOERR) { $agents_tmp = agents_get_group_agents (); if ($agents_tmp === false) diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index 56719461fe..a002583982 100644 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -97,7 +97,7 @@ switch ($action) { // Metaconsole db connection if (($config ['metaconsole'] == 1) && ($server_name != '')) { $connection = metaconsole_get_connection($server_name); - if (!metaconsole_load_external_db($connection)) { + if (metaconsole_load_external_db($connection) != NOERR) { //ui_print_error_message ("Error connecting to ".$server_name); } } @@ -481,7 +481,7 @@ html_print_input_hidden('id_item', $idItem); $connection = metaconsole_get_connection($server_name); $agent_name = ''; - if (metaconsole_load_external_db($connection)) + if (metaconsole_load_external_db($connection) == NOERR) $agent_name = db_get_value_filter('nombre', 'tagente', array('id_agente' => $idAgent)); //Restore db connection @@ -509,7 +509,7 @@ html_print_input_hidden('id_item', $idItem); if ($config['metaconsole'] == 1) { $connection = metaconsole_get_connection($server_name); - if (metaconsole_load_external_db($connection)) { + if (metaconsole_load_external_db($connection) == NOERR) { $agent_name_temp = db_get_all_rows_sql($sql); if ($agent_name_temp === false) @@ -811,7 +811,7 @@ function print_SLA_list($width, $action, $idItem = null) { // Metaconsole db connection if (($config ['metaconsole'] == 1) && ($server_name != '')) { $connection = metaconsole_get_connection($server_name); - if (!metaconsole_load_external_db($connection)) { + if (metaconsole_load_external_db($connection) != NOERR) { //ui_print_error_message ("Error connecting to ".$server_name); continue; } @@ -906,7 +906,7 @@ function print_General_list($width, $action, $idItem = null) { // Metaconsole db connection if (($config ['metaconsole'] == 1) && ($server_name != '')) { $connection = metaconsole_get_connection($server_name); - if (!metaconsole_load_external_db($connection)) { + if (metaconsole_load_external_db($connection) != NOERR) { //ui_print_error_message ("Error connecting to ".$server_name); continue; } diff --git a/pandora_console/godmode/reporting/reporting_builder.list_items.php b/pandora_console/godmode/reporting/reporting_builder.list_items.php index 1f24065601..b79dc64657 100644 --- a/pandora_console/godmode/reporting/reporting_builder.list_items.php +++ b/pandora_console/godmode/reporting/reporting_builder.list_items.php @@ -271,7 +271,7 @@ foreach ($items as $item) { if (($config ['metaconsole'] == 1) && ($server_name != '')) { $connection = metaconsole_get_connection($server_name); - if (!metaconsole_load_external_db($connection)) { + if (metaconsole_load_external_db($connection) != NOERR) { //ui_print_error_message ("Error connecting to ".$server_name); // Don't skip SLA or top N or general report items if (($item['type'] != 'SLA') and ($item['type'] != 'top_n') and ($item['type'] != 'general') diff --git a/pandora_console/include/ajax/agent.php b/pandora_console/include/ajax/agent.php index e36bf5aa93..68cea2f4a3 100644 --- a/pandora_console/include/ajax/agent.php +++ b/pandora_console/include/ajax/agent.php @@ -94,7 +94,7 @@ elseif ($search_agents && ($config['metaconsole'] == 1)) { } foreach ($servers as $server) { - if (!metaconsole_load_external_db ($server)) { + if (metaconsole_load_external_db ($server) != NOERR) { continue; } @@ -194,7 +194,7 @@ elseif ($search_agents_2 && ($config['metaconsole'] == 1)) { } foreach ($servers as $server) { - if (!metaconsole_load_external_db ($server)) { + if (metaconsole_load_external_db ($server) != NOERR) { continue; } diff --git a/pandora_console/include/constants.php b/pandora_console/include/constants.php index 20ba3be36f..c59405eaa9 100644 --- a/pandora_console/include/constants.php +++ b/pandora_console/include/constants.php @@ -31,10 +31,13 @@ define ('AGENT_ENABLED',0); define ('AGENT_DISABLED',1); /* Error report codes */ +define ('NOERR',11111); define ('ERR_GENERIC',-10000); define ('ERR_EXIST',-20000); define ('ERR_INCOMPLETE', -30000); define ('ERR_DB', -40000); +define ('ERR_DB_HOST', -40001); +define ('ERR_DB_DB', -40002); define ('ERR_FILE', -50000); define ('ERR_NOCHANGES', -60000); define ('ERR_NODATA', -70000); diff --git a/pandora_console/include/functions_io.php b/pandora_console/include/functions_io.php index ff5fb6c475..3d044da4e0 100755 --- a/pandora_console/include/functions_io.php +++ b/pandora_console/include/functions_io.php @@ -327,17 +327,17 @@ function __ ($string /*, variable arguments */) { global $config; - if ($config['enterprise_installed']) { - if (isset($config['translate_string_extension_installed']) && $config['translate_string_extension_installed'] == 1) { - if (array_key_exists('translate_string.php', $extensions)) { - enterprise_include_once('extensions/translate_string/functions.php'); + if ($config['enterprise_installed'] && + isset($config['translate_string_extension_installed']) && + $config['translate_string_extension_installed'] == 1 && + array_key_exists('translate_string.php', $extensions)) { + + enterprise_include_once('extensions/translate_string/functions.php'); - $tranlateString = get_defined_translation($string); + $tranlateString = get_defined_translation($string); - if ($tranlateString !== false) { - return $tranlateString; - } - } + if ($tranlateString !== false) { + return $tranlateString; } } diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index b69c72f4fe..e9ec535f5d 100644 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -2226,7 +2226,7 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f $server_name = $content ['server_name']; if (($config ['metaconsole'] == 1) && $server_name != '') { $connection = metaconsole_get_connection($server_name); - if (!metaconsole_load_external_db($connection)) { + if (metaconsole_load_external_db($connection) != NOERR) { //ui_print_error_message ("Error connecting to ".$server_name); } } @@ -2504,7 +2504,7 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f //Metaconsole connection if (($config ['metaconsole'] == 1) && $server_name != '') { $connection = metaconsole_get_connection($server_name); - if (!metaconsole_load_external_db($connection)) { + if (metaconsole_load_external_db($connection) != NOERR) { //ui_print_error_message ("Error connecting to ".$server_name); continue; } @@ -3324,7 +3324,7 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f $server_name = $row ['server_name']; if (($config ['metaconsole'] == 1) && $server_name != '') { $connection = metaconsole_get_connection($server_name); - if (!metaconsole_load_external_db($connection)) { + if (metaconsole_load_external_db($connection) != NOERR) { //ui_print_error_message ("Error connecting to ".$server_name); continue; } @@ -3453,7 +3453,7 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f $server_name = $general ['server_name']; if (($config ['metaconsole'] == 1) && $server_name != '') { $connection = metaconsole_get_connection($server_name); - if (!metaconsole_load_external_db($connection)) { + if (metaconsole_load_external_db($connection) != NOERR) { //ui_print_error_message ("Error connecting to ".$server_name); continue; } @@ -3500,7 +3500,7 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f $server_name = $g ['server_name']; if (($config ['metaconsole'] == 1) && $server_name != '') { $connection = metaconsole_get_connection($server_name); - if (!metaconsole_load_external_db($connection)) { + if (metaconsole_load_external_db($connection) != NOERR) { //ui_print_error_message ("Error connecting to ".$server_name); continue; } @@ -3565,7 +3565,7 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f $server_name = $generals[$i]['server_name']; if (($config ['metaconsole'] == 1) && $server_name != '') { $connection = metaconsole_get_connection($server_name); - if (!metaconsole_load_external_db($connection)) { + if (metaconsole_load_external_db($connection) != NOERR) { //ui_print_error_message ("Error connecting to ".$server_name); continue; } @@ -3605,7 +3605,7 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f $server_name = $g['server_name']; if (($config ['metaconsole'] == 1) && $server_name != '') { $connection = metaconsole_get_connection($server_name); - if (!metaconsole_load_external_db($connection)) { + if (metaconsole_load_external_db($connection) != NOERR) { //ui_print_error_message ("Error connecting to ".$server_name); continue; } @@ -3723,7 +3723,7 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f $server_name = $row['server_name']; if (($config ['metaconsole'] == 1) && $server_name != '') { $connection = metaconsole_get_connection($server_name); - if (!metaconsole_load_external_db($connection)) { + if (metaconsole_load_external_db($connection) != NOERR) { //ui_print_error_message ("Error connecting to ".$server_name); continue; } @@ -3990,7 +3990,7 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f $server_name = $exceptions[$i]['server_name']; if (($config ['metaconsole'] == 1) && $server_name != '') { $connection = metaconsole_get_connection($server_name); - if (!metaconsole_load_external_db($connection)) { + if (metaconsole_load_external_db($connection) != NOERR) { //ui_print_error_message ("Error connecting to ".$server_name); continue; } @@ -4013,7 +4013,7 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f $server_name = $exc['server_name']; if (($config ['metaconsole'] == 1) && $server_name != '') { $connection = metaconsole_get_connection($server_name); - if (!metaconsole_load_external_db($connection)) { + if (metaconsole_load_external_db($connection) != NOERR) { //ui_print_error_message ("Error connecting to ".$server_name); continue; } diff --git a/pandora_console/operation/agentes/ver_agente.php b/pandora_console/operation/agentes/ver_agente.php index bdcaf1e168..256a53637c 100644 --- a/pandora_console/operation/agentes/ver_agente.php +++ b/pandora_console/operation/agentes/ver_agente.php @@ -188,7 +188,7 @@ if (is_ajax ()) { //Metaconsole db connection $connection = metaconsole_get_connection($server_name); - if (!metaconsole_load_external_db($connection)) { + if (metaconsole_load_external_db($connection) != NOERR) { //ui_print_error_message ("Error connecting to ".$server_name); continue; } @@ -270,7 +270,7 @@ if (is_ajax ()) { if ($config ['metaconsole'] == 1) { if (enterprise_include_once ('include/functions_metaconsole.php') !== ENTERPRISE_NOT_HOOK) { $connection = metaconsole_get_connection($server_name); - if (metaconsole_load_external_db($connection)) { + if (metaconsole_load_external_db($connection) == NOERR) { /* Get all agents if no agent was given */ if ($id_agent == 0) $id_agent = array_keys (agents_get_group_agents (array_keys (users_get_groups ()), $search, "none"));