diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 737c1fa8e6..e02b7ab468 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,14 @@ +2011-11-25 Juan Manuel Ramon + + * include/functions_agents.php + operation/menu.php + operation/gis_maps/render_view.php + operation/gis_maps/index.php + godmode/gis_maps/index.php: Fixed a problem with agent groups in + gis maps. + + Fixes: #3438313 + 2011-11-25 Sergio Martin * include/graphs/functions_gd.php: Fixed rounded corners in progress bar diff --git a/pandora_console/godmode/gis_maps/index.php b/pandora_console/godmode/gis_maps/index.php index c51e19ba40..933b43ed7a 100644 --- a/pandora_console/godmode/gis_maps/index.php +++ b/pandora_console/godmode/gis_maps/index.php @@ -85,9 +85,7 @@ $table->data = array(); $defaultMapId = null; -if (!$maps) { - echo '
'.('No maps defined').'
'; -} else { +if ($maps){ $own_info = get_user_info($config['id_user']); foreach ($maps as $map) { if (!check_acl ($config["id_user"], $map["group_id"], "IR")) { @@ -113,7 +111,12 @@ if (!$maps) { array_push ($table_info, $buttons); $table->data[] = $table_info; } +} + +if (!empty ($table->data)) { html_print_table($table); +} else { + echo '
'.('No maps defined').'
'; } echo '
'; diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index c094b6b5b5..1d10e40195 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -386,6 +386,7 @@ function agents_get_agents ($filter = false, $fields = false, $access = 'AR', $o switch ($config["dbtype"]) { case "mysql": case "postgresql": + $limit_sql = ''; if(isset($offset) && isset($limit)) { $limit_sql = " LIMIT $offset, $limit "; } @@ -765,10 +766,11 @@ function agents_common_modules ($id_agent, $filter = false, $indexed = true, $ge * @param string $case Which case to return the agentname as (lower, upper, none) * @param boolean $noACL jump the ACL test. * @param boolean $childGroups The flag to get agents in the child group of group parent passed. By default false. + * @param boolean $extra_access The flag to get agents of extra access policies. * * @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, $extra_access = true) { global $config; if (!$noACL) { @@ -858,11 +860,16 @@ function agents_get_group_agents ($id_group = 0, $search = false, $case = "lower enterprise_include_once ('include/functions_policies.php'); - $extra_sql = enterprise_hook('policies_get_agents_sql_condition'); - if ($extra_sql === ENTERPRISE_NOT_HOOK) { + if ($extra_access){ + $extra_sql = enterprise_hook('policies_get_agents_sql_condition'); + if ($extra_sql === ENTERPRISE_NOT_HOOK) { + $extra_sql = ''; + }else if ($extra_sql != '') { + $extra_sql .= ' OR '; + } + } + else{ $extra_sql = ''; - }else if ($extra_sql != '') { - $extra_sql .= ' OR '; } switch ($config["dbtype"]) { @@ -874,7 +881,7 @@ function agents_get_group_agents ($id_group = 0, $search = false, $case = "lower $sql = sprintf ("SELECT id_agente, nombre FROM tagente WHERE %s (%s) ORDER BY dbms_lob.substr(nombre,4000,1)", $extra_sql, $search_sql); break; } - + $result = db_get_all_rows_sql ($sql); if ($result === false) diff --git a/pandora_console/operation/gis_maps/index.php b/pandora_console/operation/gis_maps/index.php index 2bd8bc7fe2..14c8670411 100644 --- a/pandora_console/operation/gis_maps/index.php +++ b/pandora_console/operation/gis_maps/index.php @@ -38,6 +38,12 @@ $table->align[1] = 'center'; $rowPair = true; $iterator = 0; +$own_info = get_user_info ($config['id_user']); +if ($own_info['is_admin'] || check_acl ($config['id_user'], 0, "PM")) + $own_groups = array_keys(users_get_groups($config['id_user'], "IR")); +else + $own_groups = array_keys(users_get_groups($config['id_user'], "IR", false)); + if ($maps !== false) { foreach ($maps as $map) { if ($rowPair) @@ -47,7 +53,11 @@ if ($maps !== false) { $rowPair = !$rowPair; $iterator++; - if (!check_acl ($config["id_user"], $map["group_id"], "IR")) { + $is_in_group = in_array($map['group_id'], $own_groups); + if (!$is_in_group){ + continue; + } + if (!check_acl ($config["id_user"], $map["group_id"], "IR", 0, true)) { continue; } $data = array (); diff --git a/pandora_console/operation/gis_maps/render_view.php b/pandora_console/operation/gis_maps/render_view.php index b8476e8e6b..1598438af3 100644 --- a/pandora_console/operation/gis_maps/render_view.php +++ b/pandora_console/operation/gis_maps/render_view.php @@ -144,11 +144,11 @@ if ($layers != false) { gis_make_layer($layer['layer_name'], $layer['view_layer'], null, $layer['id_tmap_layer']); // calling agents_get_group_agents with none to obtain the names in the same case as they are in the DB. - $agentNamesByGroup = agents_get_group_agents($layer['tgrupo_id_grupo'],false,'none', true); + $agentNamesByGroup = agents_get_group_agents($layer['tgrupo_id_grupo'],false,'none', true, true, false); $agentNamesByLayer = gis_get_agents_layer($layer['id_tmap_layer'], array('nombre')); $agentNames = array_unique($agentNamesByGroup + $agentNamesByLayer); - + foreach ($agentNames as $agentName) { $idAgent = agents_get_agent_id($agentName); $coords = gis_get_data_last_position_agent($idAgent); diff --git a/pandora_console/operation/menu.php b/pandora_console/operation/menu.php index db4cb82a49..921527b5e1 100644 --- a/pandora_console/operation/menu.php +++ b/pandora_console/operation/menu.php @@ -78,7 +78,17 @@ if (check_acl ($config['id_user'], 0, "AR")) { } $id = (int) get_parameter ('id', -1); + $own_info = get_user_info ($config['id_user']); + if ($own_info['is_admin'] || check_acl ($config['id_user'], 0, "PM")) + $own_groups = array_keys(users_get_groups($config['id_user'], "IR")); + else + $own_groups = array_keys(users_get_groups($config['id_user'], "IR", false)); + foreach ($gisMaps as $gisMap) { + $is_in_group = in_array($gisMap['group_id'], $own_groups); + if (!$is_in_group){ + continue; + } if (! check_acl ($config["id_user"], $gisMap["group_id"], "IR")) { continue; }