pandorafms/pandora_console/godmode/reporting/map_builder.php

142 lines
4.8 KiB
PHP
Raw Normal View History

<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas
// 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.
global $config;
print_page_header (__('Visual console builder'), "", false, "map_builder", true);
$id_layout = (int) get_parameter ('id_layout');
$copy_layout = (bool) get_parameter ('copy_layout');
$delete_layout = (bool) get_parameter ('delete_layout');
if ($delete_layout) {
process_sql_delete ('tlayout_data', array ('id_layout' => $id_layout));
$result = process_sql_delete ('tlayout', array ('id' => $id_layout));
if ($result) {
echo '<h3 class="suc">'.__('Successfully deleted').'</h3>';
clean_cache();
} else {
echo '<h3 class="error">'.__('Not deleted. Error deleting data').'</h3>';
}
$id_layout = 0;
}
if ($copy_layout) {
// Number of inserts
$ninsert = (int) 0;
// Return from DB the source layout
$layout_src = get_db_all_rows_filter ("tlayout","id = " . $id_layout);
// Name of dst
$name_dst = get_parameter ("name_dst", $layout_src[0]['name'] . " copy");
// Create the new Console
$idGroup = $layout_src[0]['id_group'];
$background = $layout_src[0]['background'];
$height = $layout_src[0]['height'];
$width = $layout_src[0]['width'];
$visualConsoleName = $name_dst;
$values = array('name' => $visualConsoleName, 'id_group' => $idGroup, 'background' => $background, 'height' => $height, 'width' => $width);
$result = process_sql_insert('tlayout', $values);
$idNewVisualConsole = $result;
if($result) {
$ninsert = 1;
// Return from DB the items of the source layout
$data_layout_src = get_db_all_rows_filter ("tlayout_data", "id_layout = " . $id_layout);
if(!empty($data_layout_src)){
for ($a=0;$a < count($data_layout_src); $a++) {
// Changing the source id by the new visual console id
$data_layout_src[$a]['id_layout'] = $idNewVisualConsole;
// Unsetting the source's id
unset($data_layout_src[$a]['id']);
// Configure the cloned Console
$result = process_sql_insert('tlayout_data', $data_layout_src[$a]);
if($result)
$ninsert++;
}// for each item of console
$inserts = count($data_layout_src) + 1;
// If the number of inserts is correct, the copy is completed
if ($ninsert == $inserts) {
echo '<h3 class="suc">'.__('Successfully copied').'</h3>';
clean_cache();
} else {
echo '<h3 class="error">'.__('Not copied. Error copying data').'</h3>';
}
}
else{
// If the array is empty the copy is completed
echo '<h3 class="suc">'.__('Successfully copied').'</h3>';
clean_cache();
}
}
else {
echo '<h3 class="error">'.__('Not copied. Error copying data').'</h3>';
}
}
$table->width = '500px';
$table->data = array ();
$table->head = array ();
$table->head[0] = __('Map name');
$table->head[1] = __('Group');
$table->head[2] = __('Items');
$table->head[3] = __('Copy');
$table->head[4] = __('Delete');
$table->align = array ();
$table->align[3] = 'center';
$table->align[4] = 'center';
$maps = get_db_all_rows_in_table ('tlayout','name');
if (!$maps) {
echo '<div class="nf">'.('No maps defined').'</div>';
2008-06-26 Esteban Sanchez <estebans@artica.es> * ajax.php: Sed id_user in config array. * godmode/menu.php, general/header.php, operation/menu.php: Replaced lang_label with lang_string(). * general/logon_ok.php: Reduced one indentation level. * godmode/agentes/agent_manager.php: Replaced lang_label with lang_string(). Use pandora functions. * include/functions_html.php, godmode/agentes/configurar_agente.php: Tab and blankspaces style correction. * godmode/reporting/map_builder.php: Complete rewritten to provide an intuitive way of build the maps. It's cool, useful and very simple. * godmode/reporting/reporting_builder.php: Deleted an output debug. * godmode/setup/setup.php: Rewritten to use pandora functions. Added a colorpicker for color settings. * include/config.php: Reset pandora password. We must solve things with this file... * include/functions.php: Check if input is an array on safe_input(). Use filename as id in array returned by list_files(). * include/functions_db.php: Renamed return_coordinate_* functions. Style correction. * include/javascript/jquery.js: Updated to 1.2.6. * include/javascript/jquery.ui.datepicker.js: Code minimized. * include/javascript/pandora.js: Style correction. * include/javascript/wz_jsgraphics.js: Added a class to the elements of a line, so it can be modified using javascript. * /include/styles/pandora.css: Added style to some tables dropdowns. Added new styles relative to visual map editor. * operation/reporting/reporting_viewer.php: Style correction. Added jQuery UI. * operation/visual_console/index.php: Use Pandora functions. * operation/visual_console/render_view.php: Drawing the map is now on functions_visual_map.php. Added a countdown if a refresh time is set. Use pandora functions. Style correction. * reporting/fgraph.php: Style correction. Use graphic_error() if there's no data on grafico_modulo_sparse(). * images/trash.png: Added to repository. Image used on trash area on visual map editor. * images/console/background/africa.jpg, images/console/background/asia.jpg, images/console/background/europe.jpg, images/console/background/north_america.jpg, images/console/background/oceania.jpg, images/console/background/shouth_america.jpg, images/console/background/world.jpg: Added to repository. Useful and cool map backgrounds. * include/functions_visual_map.php: Added to repository. Implements visual map functions like drawing the map. * include/javascript/jquery.colorpicker.js: Added to repository. Implements a color picker widget. * /include/javascript/jquery.countdown.js: Added to repository. Implements a countdown widget. * include/javascript/jquery.ui.core.js: Added to repository. jQuery UI core. * include/javascript/jquery.ui.draggable.js: Added to repository. jQuery draggable plugin. * include/javascript/jquery.ui.droppable.js: Added to repository. jQuery droppable plugin. * include/javascript/pandora_visual_console.js: Added to repository. Function useful to visual map interface. * include/languages/countdown_*.js: Added to repository. Countdown localization. * include/languages/date_es_la.js, include/languages/date_gl.js, include/languages/time_es_la.js, include/languages/time_gl.js: Added to repository. Missing localizations. * include/styles/color-picker.css: Added to repository. Colorpicker style sheet. * include/styles/countdown.css: Added to repository. Countdown style sheet. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@899 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-06-26 15:26:48 +02:00
} else {
foreach ($maps as $map) {
if (give_acl ($config['id_user'], $map['id_group'], "AW")){
$data = array ();
$data[0] = '<a href="index.php?sec=gmap&sec2=godmode/reporting/visual_console_builder&tab=data&amp;action=edit&amp;id_visual_console='.$map['id'].'">'.$map['name'].'</a>';
2009-03-04 Sancho Lerena <slerena@artica.es> * extras/: New directory with extra contents (scripts, tools, samples) * index.php: Add new permission check for /attachment directory. Probably could be extended and wrapped into a function. This should be only called once, this is the reason why is placed here and not in config_process. * pandora_console_upgrade: Force MYSQL run, even if SQL return error (useful for applying over a older 3.0 version for example). * pandoradb_data.sql: Was missing some tconfig variables. * extras/*.sql: Missing somre tconfig variables and other minor issues fixed * extensions/update_manager/main.php: Description of update manager patch wider. Probably needs more formatting in the future. * extras/sample_login.php: Sample on how to implement autologin feature. * footer.php: I hope solve the frakkin image problem. * godmode/agents/agent_manager.php: proper ACL check notice. * godmode/alerts/alert_list.php: Fixed notice. * godmode/reporting/map_builder.php: Added link to wizard and item count. * godmode/reporting/map_builder_wizard.php: Added new feature, a wizard to populate the visual map, using agents from a combo, depending on the map selected. Could have a lot of improvements, it's a basic start. Allow to choose agents and image maps and space between images. Puts in a reticle automatically adjusting at 600px width. * godmode/setup.php: Checkbox for trap_forward was bad, fixed. * config_process.php: Fixed version to 3.0-dev * functions_html.php: Default of 0 in text boxes makes them unusable on default values, funny :-) * include/functions_reporting.php: Fixed a notice on unknown variable on function get_group_stat(). * operation/agentes/alerts_status.php: Filter on module status is made now with combos, like the rest of the filters in the GUI. * operation/events/events.php: a missing div makes graph float outside the filter box. TODO: Hidder filter makes free-width style buggy here. * operation/reporting/reporting_viewer.php: Fixed layout issue. * operation/visual_console/render_view.php: Added ACL check. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1510 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-03-04 18:57:00 +01:00
$data[1] = print_group_icon ($map['id_group'], true).'&nbsp;';
$data[1] .= get_group_name ($map['id_group'], true);
$data[2] = get_db_sql ("SELECT COUNT(*) FROM tlayout_data WHERE id_layout = ".$map['id']);
$data[3] = '<a href="index.php?sec=gmap&amp;sec2=godmode/reporting/map_builder&amp;id_layout='.$map['id'].'&amp;copy_layout=1">'.print_image ("images/copy.png", true).'</a>';
$data[4] = '<a href="index.php?sec=gmap&amp;sec2=godmode/reporting/map_builder&amp;id_layout='.$map['id'].'&amp;delete_layout=1">'.print_image ("images/cross.png", true).'</a>';
array_push ($table->data, $data);
}
}
print_table ($table);
}
echo '<div class="action-buttons" style="width: '.$table->width.'">';
echo '<form action="index.php?sec=gmap&amp;sec2=godmode/reporting/visual_console_builder" method="post">';
print_input_hidden ('edit_layout', 1);
print_submit_button (__('Create'), '', false, 'class="sub next"');
echo '</form>';
echo '</div>';
?>