diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 7d1260b432..54eb1cc779 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,15 @@ +2008-07-17 Esteban Sanchez + + * godmode/reporting/reporting_builder.php, + godmode/reporting/map_builder.php: Check if all_agents were set to + avoid warning on foreach. + + * include/functions_db.php: Fixed typo in return_status_layout(). + Return false on get_db_all_rows_sql(). + + * include/functions_visual_map.php: Check layouts_data to avoid + warning on foreach. Removed ugly comments. + 2008-07-17 Esteban Sanchez * include/functions_db.php: Removed debug output to check use of diff --git a/pandora_console/godmode/reporting/map_builder.php b/pandora_console/godmode/reporting/map_builder.php index 8859f070a2..7a6c223301 100644 --- a/pandora_console/godmode/reporting/map_builder.php +++ b/pandora_console/godmode/reporting/map_builder.php @@ -371,10 +371,12 @@ if (! $edit_layout && ! $id_layout) { $all_agents = get_agents_in_group ($id_group); $agents = array (); - foreach ($all_agents as $agent) { - $agents[$agent['id_agente']] = strtolower($agent['nombre']); + if ($all_agents !== false) { + foreach ($all_agents as $agent) { + $agents[$agent['id_agente']] = strtolower($agent['nombre']); + } + asort($agents); } - asort($agents); echo '
'; echo '

'.lang_string ('Map element editor').'

'; diff --git a/pandora_console/godmode/reporting/reporting_builder.php b/pandora_console/godmode/reporting/reporting_builder.php index 3b36e2ffdb..c38a08af70 100644 --- a/pandora_console/godmode/reporting/reporting_builder.php +++ b/pandora_console/godmode/reporting/reporting_builder.php @@ -192,10 +192,12 @@ if ($id_report) { $all_agents = get_agents_in_group ($report_id_group); $agents = array (); -foreach ($all_agents as $agent) { - $agents[$agent['id_agente']] = strtolower($agent['nombre']); +if ($all_agents !== false) { + foreach ($all_agents as $agent) { + $agents[$agent['id_agente']] = strtolower($agent['nombre']); + } + asort ($agents); } -asort ($agents); if ($edit_sla_report_content) { /* Edit SLA report form */ diff --git a/pandora_console/include/functions_db.php b/pandora_console/include/functions_db.php index 8455de1518..b644178a4c 100644 --- a/pandora_console/include/functions_db.php +++ b/pandora_console/include/functions_db.php @@ -198,7 +198,7 @@ function get_agents_in_group ($id_group, $disabled = false) { } elseif ($disabled && $id_group != 1) { return get_db_all_rows_field_filter ('tagente', 'id_grupo', (int) $id_group, 'nombre'); } else { - $sql = sprintf ("SELECT * FROM `tagente` WHERE `id_grupo` = '%d' AND `disabled` = '0' ORDER BY `nombre`",$id_group); + $sql = sprintf ("SELECT * FROM `tagente` WHERE `id_grupo` = '%d' AND `disabled` = 0 ORDER BY `nombre`",$id_group); return get_db_all_rows_sql ($sql); } } @@ -1337,7 +1337,8 @@ function get_db_all_rows_sql ($sql) { } if (! empty ($retval)) return $retval; - return ""; //Return empty because NULL is a possible database value + //Return false, check with === or !== + return false; } /** @@ -1435,7 +1436,7 @@ function return_status_agent_module ($id_agentmodule = 0){ function return_status_layout ($id_layout = 0) { $temp_status = 0; $temp_total = 0; - $sql = sprintf ("SELECT id_agente_modulo, parent_item, id_layout_linked FROM `tlayout_date` WHERE `id_layout` = '%d'",$id_layout); + $sql = sprintf ("SELECT id_agente_modulo, parent_item, id_layout_linked FROM `tlayout_data` WHERE `id_layout` = '%d'",$id_layout); $result = get_db_all_rows_sql ($sql); foreach ($result as $rownum => $data) { if (($data["id_layout_linked"] != 0) && ($data["id_agente_modulo"] == 0)) { diff --git a/pandora_console/include/functions_visual_map.php b/pandora_console/include/functions_visual_map.php index ed53bb4207..832018909f 100644 --- a/pandora_console/include/functions_visual_map.php +++ b/pandora_console/include/functions_visual_map.php @@ -24,6 +24,11 @@ function print_pandora_visual_map ($id_layout, $show_links = true, $draw_lines = $layout_datas = get_db_all_rows_field_filter ('tlayout_data', 'id_layout', $id_layout); $lines = array (); + if ($layout_datas === false) { + echo '
'; + return; + } + foreach ($layout_datas as $layout_data) { // Linked to other layout ?? - Only if not module defined if (($layout_data['id_layout_linked'] != 0) && ($layout_data['id_agente_modulo'] == 0)) { @@ -40,7 +45,6 @@ function print_pandora_visual_map ($id_layout, $show_links = true, $draw_lines = } // STATIC IMAGE (type = 0) - // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if ($layout_data['type'] == 0) { // Link image @@ -108,7 +112,6 @@ function print_pandora_visual_map ($id_layout, $show_links = true, $draw_lines = } // Get parent relationship - Create line data - // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if ($layout_data["parent_item"] != "" && $layout_data["parent_item"] != 0) { $line['id'] = $layout_data['id']; $line['node_begin'] = 'layout-data-'.$layout_data["parent_item"];