diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index 69fa041dc9..a72373fbea 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -759,7 +759,9 @@ function agents_common_modules ($id_agent, $filter = false, $indexed = true, $ge * * @return array An array with all agents in the group or an empty array */ -function agents_get_group_agents ($id_group = 0, $search = false, $case = "lower", $noACL = false, $childGroups = false) { +function agents_get_group_agents ($id_group = 0, $search = false, + $case = "lower", $noACL = false, $childGroups = false) { + global $config; $filter = array(); @@ -773,6 +775,8 @@ function agents_get_group_agents ($id_group = 0, $search = false, $case = "lower } } + + if ($childGroups) { if (is_array($id_group)) { foreach ($id_group as $parent) { @@ -858,6 +862,11 @@ function agents_get_group_agents ($id_group = 0, $search = false, $case = "lower if (defined('METACONSOLE') && isset($search['id_server'])) { $filter['id_tmetaconsole_setup'] = $search['id_server']; + if ($filter['id_tmetaconsole_setup'] == 0) { + // All nodes + unset ($filter['id_tmetaconsole_setup']); + } + unset ($search["id_server"]); } @@ -889,6 +898,8 @@ function agents_get_group_agents ($id_group = 0, $search = false, $case = "lower $result = db_get_all_rows_filter($table_name, $filter, $fields); + + if ($result === false) return array (); //Return an empty array @@ -1139,8 +1150,10 @@ function agents_get_modules ($id_agent = null, $details = false, io_safe_output(implode (",", (array) $details)), $where); + $result = db_get_all_rows_sql ($sql); + if (empty ($result)) { return array (); } diff --git a/pandora_console/include/functions_visual_map.php b/pandora_console/include/functions_visual_map.php index f1812e6cde..4d2fa1c870 100755 --- a/pandora_console/include/functions_visual_map.php +++ b/pandora_console/include/functions_visual_map.php @@ -1167,14 +1167,16 @@ function visual_map_process_wizard_add ($id_agents, $image, $id_layout, $range, * * @return string Return the message status to insert DB. */ -function visual_map_process_wizard_add_modules ($id_modules, $image, $id_layout, - $range, $width = 0, $height = 0, $period, $process_value, $percentileitem_width, - $max_value, $type_percentile, $value_show, $label_type, $type, $enable_link = true, +function visual_map_process_wizard_add_modules ($id_modules, $image, + $id_layout, $range, $width = 0, $height = 0, $period, + $process_value, $percentileitem_width, $max_value, $type_percentile, + $value_show, $label_type, $type, $enable_link = true, $id_server = 0, $kind_relationship = VISUAL_MAP_WIZARD_PARENTS_NONE, $item_in_the_map = 0) { if (empty ($id_modules)) { - $return = ui_print_error_message (__('No modules selected'), '', true); + $return = ui_print_error_message( + __('No modules selected'), '', true); return $return; } @@ -1190,6 +1192,7 @@ function visual_map_process_wizard_add_modules ($id_modules, $image, $id_layout, $pos_y = $pos_y + $range; } + if ($id_server != 0) { $connection = db_get_row_filter('tmetaconsole_setup', array('id' => $id_server)); @@ -1310,20 +1313,23 @@ function visual_map_process_wizard_add_modules ($id_modules, $image, $id_layout, * * @return string Return the message status to insert DB. */ -function visual_map_process_wizard_add_agents ($id_agents, $image, $id_layout, - $range, $width = 0, $height = 0, $period, $process_value, $percentileitem_width, - $max_value, $type_percentile, $value_show, $label_type, $type, $enable_link = 1, - $id_server = 0, $kind_relationship = VISUAL_MAP_WIZARD_PARENTS_NONE, +function visual_map_process_wizard_add_agents ($id_agents, $image, + $id_layout, $range, $width = 0, $height = 0, $period, + $process_value, $percentileitem_width, $max_value, $type_percentile, + $value_show, $label_type, $type, $enable_link = 1, $id_server = 0, + $kind_relationship = VISUAL_MAP_WIZARD_PARENTS_NONE, $item_in_the_map = 0) { global $config; if (empty ($id_agents)) { - $return = ui_print_error_message (__('No agents selected'), '', true); + $return = ui_print_error_message( + __('No agents selected'), '', true); + return $return; } - $id_agents = (array) $id_agents; + $id_agents = (array)$id_agents; $error = false; $pos_y = 10; @@ -1339,7 +1345,14 @@ function visual_map_process_wizard_add_agents ($id_agents, $image, $id_layout, $relationship = false; } + foreach ($id_agents as $id_agent) { + if (is_array($id_agent)) { + $id_a = $id_agent['id_agent']; + $id_server = $id_agent['id_server']; + $id_agent = $id_a; + } + if ($pos_x > 600) { $pos_x = 10; $pos_y = $pos_y + $range; @@ -1383,6 +1396,7 @@ function visual_map_process_wizard_add_agents ($id_agents, $image, $id_layout, } if ($id_server != 0) { + $connection = db_get_row_filter('tmetaconsole_setup', array('id' => $id_server)); if (metaconsole_load_external_db($connection) != NOERR) {