From 700d6996dda42731de09d7887f09f1a92cfd1dbb Mon Sep 17 00:00:00 2001 From: zarzuelo Date: Tue, 19 Jul 2011 14:29:59 +0000 Subject: [PATCH] 2011-07-19 Sergio Martin * include/functions_networkmap.php include/functions_visual_map.php include/functions_agents.php: Fixed more errors when no agents for bug 3371316 git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4587 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 7 +++++++ pandora_console/include/functions_agents.php | 12 +++++++++++- pandora_console/include/functions_networkmap.php | 3 +++ pandora_console/include/functions_visual_map.php | 16 ++++++++++++---- 4 files changed, 33 insertions(+), 5 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 4761c06019..af02fb3b01 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,10 @@ +2011-07-19 Sergio Martin + + * include/functions_networkmap.php + include/functions_visual_map.php + include/functions_agents.php: Fixed more errors when + no agents for bug 3371316 + 2011-07-19 Sergio Martin * include/functions_html.php: Fixed check when no diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index 7d9f5aae34..566cfa9c4b 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -910,6 +910,11 @@ function agents_get_modules ($id_agent = null, $details = false, $filter = false if ($id_agent === null) { //Extract the agents of group user. $groups = users_get_groups(false, 'AR', false); + + if(empty($groups)) { + return array(); + } + $id_groups = array_keys($groups); $sql = "SELECT id_agente FROM tagente WHERE id_grupo IN (" . implode(',', $id_groups) . ")"; @@ -925,6 +930,11 @@ function agents_get_modules ($id_agent = null, $details = false, $filter = false $id_agent = safe_int ($id_agent, 1); $userGroups = users_get_groups($config['id_user'], 'AR', false); + + if(empty($userGroups)) { + return array(); + } + $id_userGroups = array_keys($userGroups); $where = " WHERE ( @@ -951,7 +961,7 @@ function agents_get_modules ($id_agent = null, $details = false, $filter = false ) ) )"; - + if (! empty ($id_agent)) { $where .= sprintf (' AND id_agente IN (%s)', implode (",", (array) $id_agent)); } diff --git a/pandora_console/include/functions_networkmap.php b/pandora_console/include/functions_networkmap.php index 3c837c8a52..243dbed887 100644 --- a/pandora_console/include/functions_networkmap.php +++ b/pandora_console/include/functions_networkmap.php @@ -176,6 +176,9 @@ function networkmap_generate_dot_groups ($pandora_name, $group = 0, $simple = 0, } else { $groups = db_get_all_rows_in_table ('tgrupo'); + if($groups === false) { + $groups = array(); + } } // Open Graph diff --git a/pandora_console/include/functions_visual_map.php b/pandora_console/include/functions_visual_map.php index 4f671c6024..3d6bac2a78 100644 --- a/pandora_console/include/functions_visual_map.php +++ b/pandora_console/include/functions_visual_map.php @@ -1019,15 +1019,23 @@ function visual_map_get_user_layouts ($id_user = 0, $only_names = false, $filter $filter = array (); $where = db_format_array_where_clause_sql ($filter); - if ($where != '') { - $where .= ' AND '; - } + if ($returnAllGroup) $groups = users_get_groups ($id_user); else $groups = users_get_groups ($id_user, 'IR', false); - $where .= sprintf ('id_group IN (%s)', implode (",", array_keys ($groups))); + + if(!empty($groups)) { + if ($where != '') { + $where .= ' AND '; + } + $where .= sprintf ('id_group IN (%s)', implode (",", array_keys ($groups))); + } + if($where == '') { + $where = array(); + } + $layouts = db_get_all_rows_filter ('tlayout', $where); if ($layouts == false)