2012-02-01 Juan Manuel Ramon <juanmanuel.ramon@artica.es>

* operation/incidents/incident.php: removed trace.
	
	* operation/agentes/alerts_status.php
	 index.php
	 operation/users/user_edit.php
	 general/shortcut_bar.php: Added shortcut bar.

	* pandoradb.sql
	 pandoradb.postgreSQL.sql
	 pandoradb.oracle.sql
	 extras/pandoradb_migrate_4.0.x_to_4.1.mysql.sql
	 extras/pandoradb_migrate_4.0.x_to_4.1.oracle.sql
	 extras/pandoradb_migrate_4.0.x_to_4.1.postgreSQL.sql: Added shorcut
	 field in tusuario table.	



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5457 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
juanmanuelr 2012-02-01 10:57:43 +00:00
parent 4276ecf461
commit 5d9b0630bc
12 changed files with 349 additions and 8 deletions

View File

@ -1,3 +1,20 @@
2012-02-01 Juan Manuel Ramon <juanmanuel.ramon@artica.es>
* operation/incidents/incident.php: removed trace.
* operation/agentes/alerts_status.php
index.php
operation/users/user_edit.php
general/shortcut_bar.php: Added shortcut bar.
* pandoradb.sql
pandoradb.postgreSQL.sql
pandoradb.oracle.sql
extras/pandoradb_migrate_4.0.x_to_4.1.mysql.sql
extras/pandoradb_migrate_4.0.x_to_4.1.oracle.sql
extras/pandoradb_migrate_4.0.x_to_4.1.postgreSQL.sql: Added shorcut
field in tusuario table.
2012-01-31 Juan Manuel Ramon <juanmanuel.ramon@artica.es>
* include/functions_reporting: Fixed bug when the module has only

View File

@ -54,6 +54,7 @@ CREATE TABLE IF NOT EXISTS `tnetflow_report_content` (
-- -----------------------------------------------------
ALTER TABLE `tusuario` ADD COLUMN `disabled` int(4) NOT NULL DEFAULT 0;
ALTER TABLE `tusuario` ADD COLUMN `shortcut` tinyint(1) DEFAULT 0;
-- -----------------------------------------------------
-- Table `tincidencia`

View File

@ -3,7 +3,8 @@
-- -----------------------------------------------------
alter table tusuario add (disabled NUMBER(10,0) default 0 NOT NULL);
alter table tusuario add (shortcut NUMBER(5, 0) DEFAULT 0);
-- -----------------------------------------------------
-- Table "tnetflow_filter"
-- -----------------------------------------------------

View File

@ -3,6 +3,7 @@
-- -----------------------------------------------------
ALTER TABLE "tusuario" ADD COLUMN "disabled" INTEGER NOT NULL DEFAULT 0;
ALTER TABLE "tusuario" ADD COLUMN "shortcut" SMALLINT DEFAULT 0;
-- -----------------------------------------------------
-- Table `tnetflow_filter`

View File

@ -0,0 +1,273 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2011 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; 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.
$shortcut_state = db_get_value_filter('shortcut', 'tusuario', array('id_user' => $config['id_user']));
// If shortcut bar is disabled return to index.php
if ($shortcut_state == 0)
return;
if (is_ajax()) {
require_once("include/functions_events.php");
$update_shortcut_state = get_parameter('update_shortcut_state', 0);
$get_critical_events = get_parameter('get_critical_events', 0);
$get_opened_incidents = get_parameter('get_opened_incidents', 0);
// Update if shortcut is visible or hidden
if ($update_shortcut_state){
$value = get_parameter('value', 0);
db_process_sql_update('tusuario', array('shortcut' => $value), array('id_user' => $config['id_user']));
}
// Get critical events (realtime update)
if ($get_critical_events){
$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'], "LM"));
else
$own_groups = array_keys(users_get_groups($config['id_user'], "LM", false));
// Get events in the last 8 hours
$shortcut_events_update = events_get_group_events($own_groups, 28800, time());
if ($shortcut_events_update == false)
$shortcut_events_update = array();
$critical_events_update = 0;
foreach($shortcut_events_update as $event_update){
if ($event_update['criticity'] == 4 and $event_update['estado'] == 0){
$critical_events++;
}
}
echo $critical_events_update;
}
// Select only opened incidents
if ($get_opened_incidents){
$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'], "LM"));
else
$own_groups = array_keys(users_get_groups($config['id_user'], "LM", false));
$sql = "SELECT count(*) total_incidents FROM tincidencia WHERE
id_grupo IN (".implode (",",array_keys ($own_groups)).") AND estado IN (0)
ORDER BY actualizacion";
$result_incidents_update = db_get_all_rows_sql ($sql);
if ($result_incidents_update === false)
$shortcut_incidents = 0;
else
$shortcut_incidents = $result_incidents_update[0]['total_incidents'];
echo $shortcut_incidents;
}
return;
}
if ($shortcut_state == 2){
echo "<div id='shortcut_button' style='position: fixed; overflow: hidden; bottom: 0px; left: 0px; width: 185px; height: 40px; background-color: #FFFFFF; border: 1px solid #808080; border-top-left-radius: 10px; border-top-right-radius: 10px;'>";
}else{
echo "<div id='shortcut_button' style='position: fixed; overflow: hidden; bottom: 0px; left: 0px; width: 185px; height: 0px; background-color: #FFFFFF; border: 1px solid #808080; border-top-left-radius: 10px; border-top-right-radius: 10px;'>";
}
html_print_image("images/pandora_textlogo.png", false, array("title" => __("Press here to activate shortcut bar")));
echo "</div>";
if ($shortcut_state == 2){
echo "<div id='shotcut_bar' style='position: fixed; overflow:hidden; bottom: 0px; left: 0px; width:100%; height: 20px; background-color:#DCDCDC; border: 1px solid #808080;'>";
} else {
echo "<div id='shotcut_bar' style='position: fixed; overflow:hidden; bottom: 0px; left: 0px; width:100%; height: 0px; background-color:#DCDCDC; border: 1px solid #808080;'>";
}
echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
echo "<a href='index.php?sec=estado&sec2=operation/agentes/alerts_status&refr=120&filter=fired&free_search=&filter_button=Filter'>";
html_print_image("images/bell.png", false, array("title" => __("Alerts fired")));
echo "&nbsp;";
// Calculate alerts fired
$data_reporting = reporting_get_group_stats();
echo "<span id='shortcut_alerts_fired' style='font-size: 9pt; color:#696969; font-weight: bold;' title='" . __('Alerts fired') . "'>" . $data_reporting['monitor_alerts_fired'] . "</span>";
echo "</a>";
echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
echo "<a href='index.php?sec=eventos&sec2=operation/events/events&status=3&severity=4&event_view_hr=8&ev_group=0&group_rep=1&filter_only_alert=-1'>";
html_print_image("images/lightning_go.png", false, array("title" => __("Critical events")));
echo "&nbsp;";
// Calculate critical events (not validated)
$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'], "LM"));
else
$own_groups = array_keys(users_get_groups($config['id_user'], "LM", false));
// Get events in the last 8 hours
$shortcut_events = events_get_group_events($own_groups, 28800, time());
if ($shortcut_events == false)
$shortcut_events = array();
$critical_events = 0;
foreach($shortcut_events as $event){
if ($event['criticity'] == 4 and $event['estado'] == 0){
$critical_events++;
}
}
echo "<span id='shortcut_critical_events' style='font-size: 9pt; color:#696969; font-weight: bold;' title='" . __('Critical events') . "'>" . $critical_events . "</span>";
echo "</a>";
echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
// Calculate opened incidents (id integria incidents are not enabled)
if ($config['integria_enabled'] == 0){
echo "<a href='index.php?sec=incidencias&sec2=operation/incidents/incident&estado=0'>";
html_print_image("images/book_edit.png", false, array("title" => __("Incidents opened")));
echo "&nbsp;";
// Select only opened incidents
$sql = "SELECT count(*) total_incidents FROM tincidencia WHERE
id_grupo IN (".implode (",",array_keys ($own_groups)).") AND estado IN (0)
ORDER BY actualizacion";
$result_incidents = db_get_all_rows_sql ($sql);
if ($result_incidents === false)
$shortcut_incidents = 0;
else
$shortcut_incidents = $result_incidents[0]['total_incidents'];
echo "<span id='shortcut_incidents_opened' style='font-size: 9pt; color:#696969; font-weight: bold;' title='" . __('Incidents opened') . "'>" . $shortcut_incidents . "</span>";
echo "</a>";
echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
}
echo "&nbsp;&nbsp;&nbsp;";
echo "<span style='font-size: 9pt; color:#696969; font-weight: bold;'>|</span>";
echo "&nbsp;&nbsp;&nbsp;&nbsp;";
echo "&nbsp;&nbsp;&nbsp;&nbsp;";
echo "<a href='index.php?sec=reporting&sec2=operation/reporting/custom_reporting'>";
html_print_image("images/reporting.png", false, array("title" => __("View reports")));
echo "</a>";
echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
echo "<a href='index.php?sec=messages&sec2=operation/messages/message'>";
html_print_image("images/email.png", false, array("title" => __("Create new message")));
echo "</a>";
// Login in Console and shortcut bar is disabled
// This will show and hide the shortcut value in Javascript code
if (isset($_POST['nick']) and $shortcut_state != 2){
html_print_input_hidden("login_console", 1);
} else {
html_print_input_hidden("login_console", 0);
}
html_print_input_hidden("shortcut_id_user", $config['id_user']);
echo "</div>";
?>
<script type='text/javascript'>
$(function() {
if ($('#hidden-login_console').val() == 1){
$('#shotcut_bar').css({height: 0}).animate({ height: '20' }, 900);
$('#shortcut_button').css({height: 22}).animate({ height: '40' }, 900);
$('#shotcut_bar').css({height: 20}).animate({ height: '0' }, 900);
$('#shortcut_button').css({height:40}).animate({ height: '22' }, 900);
} else {
if ($('#shotcut_bar').css('height') == '0px'){
$('#shotcut_bar').css('height', '0px');
$('#shortcut_button').css('height', '22px');
}else{
$('#shotcut_bar').css('height', '20px');
$('#shortcut_button').css('height', '40px');
}
}
$('#shortcut_button').click (function () {
if ($('#shotcut_bar').css('height') == '0px'){
$('#shotcut_bar').css({height: 0}).animate({ height: '20' }, 900);
$('#shortcut_button').css({height: 22}).animate({ height: '40' }, 900);
jQuery.post ("ajax.php",
{"page" : "general/shortcut_bar",
"update_shortcut_state": 1,
"value": 2
},
function (data) {
}
);
} else {
$('#shotcut_bar').css({height: 20}).animate({ height: '0' }, 900);
$('#shortcut_button').css({height: 40}).animate({ height: '22' }, 900);
jQuery.post ("ajax.php",
{"page" : "general/shortcut_bar",
"update_shortcut_state": 1,
"value": 1
},
function (data) {
}
);
}
});
});
var id_user = $('#hidden-shortcut_id_user').val();
function shortcut_check_alerts() {
jQuery.post ("ajax.php",
{"page" : "operation/agentes/alerts_status",
"get_alert_fired": 1
},
function (data) {
$('#shortcut_alerts_fired').text(data);
}
);
}
function shortcut_check_events() {
jQuery.post ("ajax.php",
{"page" : "general/shortcut_bar",
"get_critical_events": 1
},
function (data) {
$('#shortcut_critical_events').text(data);
}
);
}
function shortcut_check_incidents() {
jQuery.post ("ajax.php",
{"page" : "general/shortcut_bar",
"get_opened_incidents": 1
},
function (data) {
$('#shortcut_incidents_opened').text(data);
}
);
}
$(document).ready (function () {
setInterval("shortcut_check_alerts()", (10 * 1000)); //10 seconds between ajax request
setInterval("shortcut_check_events()", (10 * 1000)); //10 seconds between ajax request
setInterval("shortcut_check_incidents()", (10 * 1000)); //10 seconds between ajax request
});
</script>

View File

@ -21,7 +21,7 @@ if (function_exists ('mb_internal_encoding')) {
// Set to 1 to do not check for installer or config file (for development!).
// Activate gives more error information, not useful for production sites
$develop_bypass = 0;
$develop_bypass = 1;
if ($develop_bypass != 1) {
// If no config file, automatically try to install
@ -96,8 +96,7 @@ if (!empty ($config["https"]) && empty ($_SERVER['HTTPS'])) {
$config["pure"] = (bool) get_parameter ("pure");
// Auto Refresh page (can now be disabled anywhere in the script)
$config["refr"] = (int) get_parameter ("refr");
$config["refr"] = (int) get_parameter ("refr", $config["refr"]);
ob_start ();
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'."\n";
@ -160,6 +159,7 @@ elseif (! isset ($config['id_user']) && isset ($_GET["login"])) {
$pass = get_parameter_post ("pass"); //This is the variable with the password
$nick = db_escape_string_sql($nick);
$pass = db_escape_string_sql($pass);
// process_user_login is a virtual function which should be defined in each auth file.
// It accepts username and password. The rest should be internal to the auth file.
// The auth file can set $config["auth_error"] to an informative error output or reference their internal error messages to it
@ -194,6 +194,7 @@ elseif (! isset ($config['id_user']) && isset ($_GET["login"])) {
}
elseif (! isset ($config['id_user'])) {
// There is no user connected
require_once ('general/login_page.php');
while (@ob_end_flush ());
exit ("</html>");
@ -221,7 +222,7 @@ extensions_load_extensions ($config['extensions']);
// Header
if ($config["pure"] == 0) {
echo '<div id="container"><div id="head">';
require ("general/header.php");
require ("general/header.php");
echo '</div><div id="page"><div id="menu">';
require ("general/main_menu.php");
echo '</div>';
@ -267,6 +268,7 @@ else {
else echo '<br /><strong class="error">'.__('Sorry! I can\'t find the page!').'</strong>';
}
else require ("general/logon_ok.php");
require("general/shortcut_bar.php");
}
if ($config["pure"] == 0) {

View File

@ -18,6 +18,20 @@ global $config;
// Login check
check_login ();
if (is_ajax()){
require_once("include/functions_reporting.php");
$get_alert_fired = get_parameter("get_alert_fired", 0);
if ($get_alert_fired){
// Calculate alerts fired
$data_reporting = reporting_get_group_stats();
echo $data_reporting['monitor_alerts_fired'];
}
return;
}
require_once ("include/functions_agents.php");
require_once ('operation/agentes/alerts_status.functions.php');
require_once ('include/functions_users.php');

View File

@ -125,7 +125,7 @@ elseif ($action == "insert") {
$sql = sprintf ("INSERT INTO tincidencia (inicio, actualizacion, titulo, descripcion, id_usuario, origen, estado, prioridad, id_grupo, id_creator, id_agent) VALUES
(NOW(), NOW(), '%s', '%s', '%s', '%s', %d, %d, '%s', '%s', %d)", $titulo, $descripcion, $config["id_user"], $origen, $estado, $prioridad, $grupo, $config["id_user"], $id_agent);
$id_inc = db_process_sql ($sql, "insert_id");
html_debug_print($sql);
if ($id_inc === false) {
echo '<h3 class="error">'.__('Error creating incident').'</h3>';
}

View File

@ -42,9 +42,34 @@ if (($config["id_user"] == $id || check_acl ($config["id_user"], users_get_group
$view_mode = true;
}
if (is_ajax ()){
$shortcut_update = get_parameter("shortcut_update", 0);
// Update of user to show/don't show shortcut bar
if ($shortcut_update){
// First we get the actual state
$shortcut_value = db_get_value_filter('shortcut', 'tusuario', array('id_user' => $id));
//Deactivate shorcut var
if ($shortcut_value == 1){
db_process_sql_update('tusuario', array('shortcut' => 0), array('id_user' => $id));
}
// Activate shortcut var
else {
db_process_sql_update('tusuario', array('shortcut' => 1), array('id_user' => $id));
}
}
return;
}
// Header
ui_print_page_header (__('User detail editor'), "images/group.png", false, "", false, "");
// Update user info
if (isset ($_GET["modified"]) && !$view_mode) {
$upd_info = array ();
$upd_info["fullname"] = get_parameter_post ("fullname", $user_info["fullname"]);
@ -64,6 +89,7 @@ if (isset ($_GET["modified"]) && !$view_mode) {
}
$upd_info["flash_chart"] = get_parameter ("flash_charts", $config["flash_charts"]);
$upd_info["shortcut"] = get_parameter ("shortcut_bar", 0);
if ( !empty ($password_new)) {
if ($config["user_can_update_password"] && $password_confirm == $password_new) {
@ -197,6 +223,9 @@ echo html_print_input_text ('block_size', $block_size, '', 5, 5, true);
echo html_print_checkbox('default_block_size', 1, $user_info["block_size"] == 0, true);
echo __('Default').' ('.$config["global_block_size"].')';
echo '</td></tr><tr><td class="datos">'.__('Shortcut bar') . ui_print_help_tip(__('This will activate a shortcut bar with alerts, events, messages... information'), true) . '</td><td class="datos2">';
echo html_print_checkbox('shortcut_bar', 1, $user_info["shortcut"], true);
echo '</td></tr></table>';
echo '<div style="width:90%; text-align:right;">';

View File

@ -856,7 +856,8 @@ CREATE TABLE tusuario (
block_size NUMBER(10, 0) default 20 NOT NULL,
flash_chart NUMBER(10, 0) default 1 NOT NULL,
id_skin NUMBER(10, 0) DEFAULT 0 NOT NULL,
disabled NUMBER(10, 0) default 0 NOT NULL
disabled NUMBER(10, 0) default 0 NOT NULL,
shortcut NUMBER(5, 0) DEFAULT 0
);
CREATE TABLE tusuario_perfil (

View File

@ -686,7 +686,8 @@ CREATE TABLE "tusuario" (
"block_size" INTEGER NOT NULL default 20,
"flash_chart" INTEGER NOT NULL default 1,
"id_skin" INTEGER NOT NULL DEFAULT 0,
"disabled" INTEGER NOT NULL default 1
"disabled" INTEGER NOT NULL default 1,
"shortcut" SMALLINT DEFAULT 0
);
CREATE TABLE "tusuario_perfil" (

View File

@ -762,6 +762,7 @@ CREATE TABLE IF NOT EXISTS `tusuario` (
`flash_chart` int(4) NOT NULL DEFAULT 1,
`id_skin` int(10) unsigned NOT NULL,
`disabled` int(4) NOT NULL DEFAULT 0,
`shortcut` tinyint(1) DEFAULT 0,
UNIQUE KEY `id_user` (`id_user`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;