2010-01-21 18:08:58 +01:00
|
|
|
<?php
|
|
|
|
// Pandora FMS - http://pandorafms.com
|
|
|
|
// ==================================================
|
2010-05-11 17:17:09 +02:00
|
|
|
// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas
|
2010-01-21 18:08:58 +01:00
|
|
|
// Please see http://pandorafms.org for full contribution list
|
|
|
|
|
|
|
|
// This program is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU General Public License
|
|
|
|
// as published by the Free Software Foundation for version 2.
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
|
|
|
|
// Load global vars
|
2010-03-03 18:10:37 +01:00
|
|
|
global $config;
|
2010-01-21 18:08:58 +01:00
|
|
|
|
|
|
|
check_login ();
|
|
|
|
|
|
|
|
require_once ('include/functions_gis.php');
|
|
|
|
|
2010-02-09 18:06:25 +01:00
|
|
|
require_javascript_file('openlayers.pandora');
|
|
|
|
|
2010-01-21 18:08:58 +01:00
|
|
|
if (! give_acl ($config['id_user'], 0, "IW")) {
|
2010-03-09 13:34:09 +01:00
|
|
|
audit_db ($config['id_user'], $_SERVER['REMOTE_ADDR'], "ACL Violation", "Trying to access map builder");
|
2010-01-21 18:08:58 +01:00
|
|
|
require ("general/noaccess.php");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-02-09 18:06:25 +01:00
|
|
|
if (is_ajax ()) {
|
|
|
|
$action = get_parameter('action');
|
|
|
|
$id_map = get_parameter('id_map');
|
|
|
|
|
2010-05-11 16:23:30 +02:00
|
|
|
// Set to not default the actual default map
|
|
|
|
$returnOperationDB = process_sql_update('tgis_map', array('default_map' => 0), array('default_map' => 1));
|
|
|
|
|
|
|
|
// Set default the new default map
|
2010-02-09 18:06:25 +01:00
|
|
|
$returnOperationDB = process_sql_update('tgis_map', array('default_map' => 1), array('id_tgis_map' => $id_map));
|
|
|
|
|
|
|
|
if ($returnOperationDB === false)
|
|
|
|
$data['correct'] = false;
|
|
|
|
else
|
|
|
|
$data['correct'] = true;
|
|
|
|
|
|
|
|
echo json_encode($data);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-01-28 18:58:30 +01:00
|
|
|
$action = get_parameter('action');
|
|
|
|
|
|
|
|
switch ($action) {
|
|
|
|
case 'delete_map':
|
2010-02-15 12:00:51 +01:00
|
|
|
$idMap = get_parameter('map_id');
|
2010-01-28 18:58:30 +01:00
|
|
|
deleteMap($idMap);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-03-04 18:58:59 +01:00
|
|
|
print_page_header (__('GIS Maps builder'), "images/server_web.png", false, "gis_map_builder", true);
|
2010-01-21 18:08:58 +01:00
|
|
|
|
|
|
|
$table->width = '500px';
|
|
|
|
$table->head[0] = __('Map name');
|
|
|
|
$table->head[1] = __('Group');
|
|
|
|
$table->head[2] = __('View');
|
2010-02-09 18:06:25 +01:00
|
|
|
$table->head[3] = __('Default');
|
|
|
|
$table->head[4] = __('Delete');
|
2010-01-21 18:08:58 +01:00
|
|
|
|
|
|
|
$table->align[1] = 'center';
|
|
|
|
$table->align[2] = 'center';
|
|
|
|
$table->align[3] = 'center';
|
2010-02-09 18:06:25 +01:00
|
|
|
$table->align[4] = 'center';
|
2010-01-21 18:08:58 +01:00
|
|
|
|
|
|
|
$maps = get_db_all_rows_in_table ('tgis_map','map_name');
|
|
|
|
|
|
|
|
$table->data = array();
|
2010-01-27 16:46:20 +01:00
|
|
|
|
2010-02-15 12:00:51 +01:00
|
|
|
$defaultMapId = null;
|
|
|
|
|
2010-05-11 17:17:09 +02:00
|
|
|
if (!$maps) {
|
|
|
|
echo '<div class="nf">'.('No maps defined').'</div>';
|
|
|
|
} else {
|
2010-01-27 16:46:20 +01:00
|
|
|
foreach ($maps as $map) {
|
2010-02-09 18:06:25 +01:00
|
|
|
|
|
|
|
$checked = false;
|
2010-02-15 12:00:51 +01:00
|
|
|
if ($map['default_map']) {
|
2010-02-09 18:06:25 +01:00
|
|
|
$checked = true;
|
2010-02-15 12:00:51 +01:00
|
|
|
$defaultMapId = $map['id_tgis_map'];
|
|
|
|
}
|
2010-02-09 18:06:25 +01:00
|
|
|
|
2010-02-16 16:28:07 +01:00
|
|
|
$table->data[] = array('<a href="index.php?sec=godgismaps&sec2=godmode/gis_maps/configure_gis_map&map_id='.$map['id_tgis_map'].'&action=edit_map">' . $map['map_name'] . '</a>',
|
2010-01-27 16:46:20 +01:00
|
|
|
print_group_icon ($map['group_id'], true),
|
2010-02-10 18:31:26 +01:00
|
|
|
'<a href="index.php?sec=gismaps&sec2=operation/gis_maps/render_view&map_id='.$map['id_tgis_map'].'">' . print_image ("images/eye.png", true).'</a>',
|
2010-02-09 18:06:25 +01:00
|
|
|
print_radio_button_extended('default_map', $map['id_tgis_map'], '', $checked, false, "setDefault(" . $map['id_tgis_map'] . ");", '', true),
|
2010-02-15 12:00:51 +01:00
|
|
|
'<a href="index.php?sec=godgismaps&sec2=godmode/gis_maps/index&map_id='.$map['id_tgis_map'].'&action=delete_map" onclick="return confirmDelete();">' . print_image ("images/cross.png", true).'</a>');
|
2010-01-27 16:46:20 +01:00
|
|
|
}
|
2010-05-11 17:17:09 +02:00
|
|
|
print_table($table);
|
2010-01-21 18:08:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
echo '<div class="action-buttons" style="width: '.$table->width.'">';
|
|
|
|
echo '<form action="index.php?sec=godgismaps&sec2=godmode/gis_maps/configure_gis_map" method="post">';
|
2010-01-27 16:46:20 +01:00
|
|
|
print_input_hidden ('action','new_map');
|
2010-01-21 18:08:58 +01:00
|
|
|
print_submit_button (__('Create'), '', false, 'class="sub next"');
|
|
|
|
echo '</form>';
|
|
|
|
echo '</div>';
|
2010-02-09 18:06:25 +01:00
|
|
|
?>
|
|
|
|
<script type="text/javascript">
|
2010-02-15 12:00:51 +01:00
|
|
|
var defaultMapId = "<?php echo $defaultMapId; ?>";
|
|
|
|
|
|
|
|
function confirmDelete() {
|
|
|
|
if (confirm('<?php echo __('Caution: Do you want delete the map?');?>'))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-02-09 18:06:25 +01:00
|
|
|
function setDefault(id_tgis_map) {
|
2010-02-15 12:00:51 +01:00
|
|
|
if (confirm('<?php echo __('Do you want to set default the map?');?>')) {
|
|
|
|
jQuery.ajax ({
|
|
|
|
data: "page=godmode/gis_maps/index&action=set_default&id_map=" + id_tgis_map,
|
|
|
|
type: "POST",
|
|
|
|
dataType: 'json',
|
|
|
|
url: "ajax.php",
|
|
|
|
timeout: 10000,
|
|
|
|
success: function (data) {
|
|
|
|
if (data.correct == 0) {
|
|
|
|
alert('<?php echo __('There was error on setup the default map.');?>');
|
|
|
|
}
|
2010-02-09 18:06:25 +01:00
|
|
|
}
|
2010-02-15 12:00:51 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
jQuery.each($("input[name=default_map]"), function() {
|
|
|
|
if ($(this).val() == defaultMapId) {
|
|
|
|
$(this).attr("checked", "checked");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$(this).removeAttr("checked");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2010-02-09 18:06:25 +01:00
|
|
|
}
|
2010-03-03 18:10:37 +01:00
|
|
|
</script>
|