diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 1eaaede3e8..c607d7c020 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,13 @@ +2013-05-20 Miguel de Dios + + * include/ajax/skins.ajax.php, include/functions_gis.php, + include/javascript/openlayers.pandora.js, + operation/gis_maps/public_console.php, operation/gis_maps/ajax.php, + operation/gis_maps/render_view.php, + operation/visual_console/public_console.php, + operation/visual_console/render_view.php: added the public console + for GIS. + 2013-05-20 Miguel de Dios * operation/gis_maps/ajax.php, diff --git a/pandora_console/include/ajax/skins.ajax.php b/pandora_console/include/ajax/skins.ajax.php index b48e5a4719..5d18bf0df5 100644 --- a/pandora_console/include/ajax/skins.ajax.php +++ b/pandora_console/include/ajax/skins.ajax.php @@ -15,15 +15,13 @@ // Login check global $config; -check_login (); - $get_image_path = get_parameter('get_image_path', 0); /* skins image checks */ -if ($get_image_path){ +if ($get_image_path) { $img_src = get_parameter("img_src"); $only_src = get_parameter("only_src", 0); - + return html_print_image($img_src, false, '', $only_src); } diff --git a/pandora_console/include/functions_gis.php b/pandora_console/include/functions_gis.php index a671c97ef6..a722e07cc1 100644 --- a/pandora_console/include/functions_gis.php +++ b/pandora_console/include/functions_gis.php @@ -128,12 +128,20 @@ function gis_print_map($idDiv, $iniZoom, $latCenter, $lonCenter, $baselayers, $c echo ""; } -function gis_make_layer($name, $visible = true, $dot = null, $idLayer = null) { +function gis_make_layer($name, $visible = true, $dot = null, $idLayer = null, $public_console = 0, $id_map = 0) { + global $config; + if ($dot == null) { $dot['url'] = 'images/dot_green.png'; $dot['width'] = 20; //11; $dot['height'] = 20; //11; } + + $hash = ''; + if ($public_console) { + $hash = md5($config["dbpass"] . $id_map. $config["id_user"]); + } + $visible = (bool)$visible; ?> +'; +echo "

" . $map['map_name'] . "

"; +echo "
"; + +echo "
"; + +echo ""; + +gis_print_map('map', $map['zoom_level'], $map['initial_latitude'], + $map['initial_longitude'], $baselayers, $controls); + +if ($layers != false) { + foreach ($layers as $layer) { + gis_make_layer($layer['layer_name'], + $layer['view_layer'], null, $layer['id_tmap_layer'], 1, $idMap); + + // calling agents_get_group_agents with none to obtain the names in the same case as they are in the DB. + $agentNamesByGroup = array(); + if ($layer['tgrupo_id_grupo'] >= 0) { + $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); + + if ($coords === false) { + $coords['stored_latitude'] = $map['default_latitude']; + $coords['stored_longitude'] = $map['default_longitude']; + } + else { + if ($show_history == 'y') { + $lastPosition = array('longitude' => $coords['stored_longitude'], 'latitude' => $coords['stored_latitude']); + gis_add_path($layer['layer_name'], $idAgent, $lastPosition); + } + } + + + $icon = gis_get_agent_icon_map($idAgent, true); + $icon_size = getimagesize($icon); + $icon_width = $icon_size[0]; + $icon_height = $icon_size[1]; + $icon = ui_get_full_url($icon); + $status = agents_get_status($idAgent); + $parent = db_get_value('id_parent', 'tagente', 'id_agente', $idAgent); + + gis_add_agent_point($layer['layer_name'], + io_safe_output($agentName), $coords['stored_latitude'], + $coords['stored_longitude'], $icon, $icon_width, + $icon_height, $idAgent, $status, 'point_agent_info', + $parent); + } + } + gis_add_parent_lines(); + + switch ($config["dbtype"]) { + case "mysql": + $timestampLastOperation = db_get_value_sql("SELECT UNIX_TIMESTAMP()"); + break; + case "postgresql": + $timestampLastOperation = db_get_value_sql( + "SELECT ceil(date_part('epoch', CURRENT_TIMESTAMP))"); + break; + case "oracle": + $timestampLastOperation = db_get_value_sql( + "SELECT ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (86400)) FROM dual"); + break; + } + + gis_activate_select_control(); + gis_activate_ajax_refresh($layers, $timestampLastOperation, 1, $idMap); +} + +// Resize GIS map on fullscreen +?> + \ No newline at end of file diff --git a/pandora_console/operation/gis_maps/render_view.php b/pandora_console/operation/gis_maps/render_view.php index 48da1d2529..681d6da0ed 100644 --- a/pandora_console/operation/gis_maps/render_view.php +++ b/pandora_console/operation/gis_maps/render_view.php @@ -98,6 +98,14 @@ else { if (check_acl ($config["id_user"], $map['group_id'], "IW")) { $buttons['setup']['text'] = ''.html_print_image ("images/setup.png", true, array ("title" => __('Setup'))).''; $buttons['setup']['godmode'] = 1; + + + $hash = md5($config["dbpass"] . $idMap . $config["id_user"]); + + $buttons['public_link']['text'] = ''. + html_print_image ("images/camera_mc.png", true, array ("title" => __('Show link to public Visual Console'))).''; } $buttonsString = '' . diff --git a/pandora_console/operation/visual_console/public_console.php b/pandora_console/operation/visual_console/public_console.php index e555c73d12..c55cd98006 100644 --- a/pandora_console/operation/visual_console/public_console.php +++ b/pandora_console/operation/visual_console/public_console.php @@ -73,7 +73,7 @@ if (!isset($config['pure'])) // Render map $options = array(); echo '
'; -echo "

". $layout_name. "

"; +echo "

" . $layout_name . "

"; visual_map_print_visual_map ($id_layout, true, true, null, null, '../../'); @@ -101,7 +101,7 @@ $table->data[0][1] = html_print_select ($values, 'refr', $config["vc_refr"], '', $table->data[0][2] = html_print_submit_button (__('Refresh'), '', false, 'class="sub next"', true); $table->data[0][2] .= html_print_input_hidden ('vc_refr', $config["vc_refr"], true); -if ($vc_refr){ +if ($vc_refr) { $config["vc_refr"] = 0; } diff --git a/pandora_console/operation/visual_console/render_view.php b/pandora_console/operation/visual_console/render_view.php index 67c6418a67..d10de9ee57 100644 --- a/pandora_console/operation/visual_console/render_view.php +++ b/pandora_console/operation/visual_console/render_view.php @@ -86,7 +86,7 @@ $options['consoles_list']['text'] = '
'. html_print_image ("images/camera_mc.png", true, array ("title" => __('Show link to public Visual Console'))).'';