From a65a494f7f581abec68c693cab17839ae732a51e Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Wed, 7 May 2014 17:15:48 +0000 Subject: [PATCH] 2014-05-07 Miguel de Dios * include/functions_ui.php, include/functions_networkmap.php: clean source code style. * include/functions_modules.php: added function "modules_get_interfaces". git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@9881 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 8 +++++ pandora_console/include/functions_modules.php | 34 +++++++++++++++++++ .../include/functions_networkmap.php | 13 ++++--- pandora_console/include/functions_ui.php | 7 ++-- 4 files changed, 56 insertions(+), 6 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 961843a3c0..642d5c163b 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,11 @@ +2014-05-07 Miguel de Dios + + * include/functions_ui.php, include/functions_networkmap.php: clean + source code style. + + * include/functions_modules.php: added function + "modules_get_interfaces". + 2014-05-07 Juan Manuel Ramon * pandoradb_data.sql diff --git a/pandora_console/include/functions_modules.php b/pandora_console/include/functions_modules.php index 59ccf90401..e83e889e45 100644 --- a/pandora_console/include/functions_modules.php +++ b/pandora_console/include/functions_modules.php @@ -961,6 +961,40 @@ function modules_get_unit ($id_agente_modulo) { return $unit = (string) db_get_value ('unit', 'tagente_modulo', 'id_agente_modulo', (int) $id_agente_modulo); } +function modules_get_interfaces($id_agent, $fields_param = false) { + $return = array(); + + $fields = $fields_param; + if ($fields !== false) { + if (is_array($fields)) { + $fields[] = 'id_tipo_modulo'; + } + } + + $modules = db_get_all_rows_filter('tagente_modulo', + array('id_agente' => $id_agent), $fields); + + if (empty($modules)) + $modules = array(); + + foreach ($modules as $module) { + if ($module['id_tipo_modulo'] == 18 || $module['id_tipo_modulo'] == 6) { + + if ($fields_param !== false) { + if (is_array($fields_param)) { + if (in_array('id_tipo_modulo', $fields) !== false) { + unset($module['id_tipo_modulo']); + } + } + } + + $return[] = $module; + } + } + + return $return; +} + /** * Get all the times a monitor went down during a period. * diff --git a/pandora_console/include/functions_networkmap.php b/pandora_console/include/functions_networkmap.php index 4a5e7d99c7..e93d1b4644 100644 --- a/pandora_console/include/functions_networkmap.php +++ b/pandora_console/include/functions_networkmap.php @@ -261,7 +261,9 @@ function networkmap_generate_dot ($pandora_name, $group = 0, $filter['id_grupo'] = $group; $agents = agents_get_agents ($filter, - array ('id_grupo, nombre, id_os, id_parent, id_agente, normal_count, warning_count, critical_count, unknown_count, total_count, notinit_count')); + array ('id_grupo, nombre, id_os, id_parent, id_agente, + normal_count, warning_count, critical_count, + unknown_count, total_count, notinit_count')); } else if ($group == -666) { $agents = false; @@ -269,7 +271,8 @@ function networkmap_generate_dot ($pandora_name, $group = 0, else { $agents = agents_get_agents ($filter, array ('id_grupo, nombre, id_os, id_parent, id_agente, - normal_count, warning_count, critical_count, unknown_count, total_count, notinit_count')); + normal_count, warning_count, critical_count, + unknown_count, total_count, notinit_count')); } if ($agents === false) @@ -277,7 +280,8 @@ function networkmap_generate_dot ($pandora_name, $group = 0, $agents = array(); // Open Graph - $graph = networkmap_open_graph ($layout, $nooverlap, $pure, $zoom, $ranksep, $font_size); + $graph = networkmap_open_graph ($layout, $nooverlap, $pure, $zoom, + $ranksep, $font_size); // Parse agents $nodes = array (); @@ -321,7 +325,8 @@ function networkmap_generate_dot ($pandora_name, $group = 0, // Parse modules foreach ($modules as $key => $module) { - if ($module['id_tipo_modulo'] != 18 && (!$l2_network || $module['id_tipo_modulo'] != 6)) { + if ($module['id_tipo_modulo'] != 18 && + (!$l2_network || $module['id_tipo_modulo'] != 6)) { continue; } diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 84cff59695..6b13b9e0e3 100644 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -1039,13 +1039,16 @@ function ui_print_help_icon ($help_id, $return = false, $home_url = '', $image = function ui_require_css_file ($name, $path = 'include/styles/') { global $config; - $filename = $path.$name.'.css'; + $filename = $path . $name . '.css'; if (! isset ($config['css'])) $config['css'] = array (); + if (isset ($config['css'][$name])) return true; - if (! file_exists ($filename) && ! file_exists ($config['homedir'].'/'.$filename)) + + if (! file_exists ($filename) && + ! file_exists ($config['homedir'] . '/' . $filename)) return false; $config['css'][$name] = $filename;