2012-03-08 Vanessa Gil <vanessa.gil@artica.es>

* pandoradb.sql
	  pandoradb.oracle.sql
	  pandoradb.postgreSQL.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 fields
	'section' and 'data_section' to tusuario.

	* index.php
	  include/functions.php
	  operation/users/user_edit.php: Customize home screen.


git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5726 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
vgilc 2012-03-08 16:42:31 +00:00
parent 9a15d57273
commit 91eda84092
10 changed files with 187 additions and 8 deletions

View File

@ -1,3 +1,17 @@
2012-03-08 Vanessa Gil <vanessa.gil@artica.es>
* pandoradb.sql
pandoradb.oracle.sql
pandoradb.postgreSQL.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 fields
'section' and 'data_section' to tusuario.
* index.php
include/functions.php
operation/users/user_edit.php: Customize home screen.
2012-03-08 Sergio Martin <sergio.martin@artica.es>
* include/functions_graph.php

View File

@ -179,3 +179,10 @@ ALTER TABLE `tgraph` ADD COLUMN `id_graph_template` int(11) NOT NULL DEFAULT 0;
UPDATE ttipo_modulo SET descripcion='Generic data' WHERE id_tipo=1;
UPDATE ttipo_modulo SET descripcion='Generic data incremental' WHERE id_tipo=4;
-- -----------------------------------------------------
-- Table `tusuario`
-- -----------------------------------------------------
ALTER TABLE `tusuario` ADD COLUMN `section` TEXT NOT NULL;
ALTER TABLE `tusuario` ADD COLUMN `data_section` TEXT NOT NULL;

View File

@ -170,3 +170,10 @@ ALTER TABLE tgraph ADD (id_graph_template NUMBER(11, 0) default 0 NOT NULL);
UPDATE ttipo_modulo SET descripcion='Generic data' WHERE id_tipo=1;
UPDATE ttipo_modulo SET descripcion='Generic data incremental' WHERE id_tipo=4;
-- -----------------------------------------------------
-- Table `tusuario`
-- -----------------------------------------------------
ALTER TABLE tusuario ADD (section VARCHAR2(255) NOT NULL);
ALTER TABLE tusuario ADD (data_section VARCHAR2(255) NOT NULL);

View File

@ -157,3 +157,10 @@ ALTER TABLE "tgraph" ADD COLUMN "id_graph_template" INTEGER NOT NULL default 0;
UPDATE "ttipo_modulo" SET "descripcion"='Generic data' WHERE "id_tipo"=1;
UPDATE "ttipo_modulo" SET "descripcion"='Generic data incremental' WHERE "id_tipo"=4;
-- -----------------------------------------------------
-- Table `tusuario`
-- -----------------------------------------------------
ALTER TABLE "tusuario" ADD COLUMN "section" varchar(255) NOT NULL;
ALTER TABLE "tusuario" ADD COLUMN "data_section" varchar(255) NOT NULL;

View File

@ -1504,4 +1504,16 @@ function get_os_name ($id_os) {
return (string) db_get_value ('name', 'tconfig_os', 'id_os', (int) $id_os);
}
/**
* Get user's dashboards
*
* @param int user id.
*
* @return array Dashboard name of the given user.
*/
function get_user_dashboards ($id_user) {
$sql = "SELECT name FROM tdashboard WHERE id_user="."'".$id_user."'";
return db_get_all_rows_sql ($sql);
}
?>

View File

@ -220,7 +220,6 @@ if (isset ($_GET["bye"])) {
*/
extensions_load_extensions ($config['extensions']);
// Header
if ($config["pure"] == 0) {
echo '<div id="container"><div id="head">';
@ -237,14 +236,11 @@ else {
// Session locking concurrency speedup!
session_write_close ();
// Main block of content
if ($config["pure"] == 0) {
echo '<div id="main">';
}
// Page loader / selector
if ($searchPage) {
require ('operation/search_results.php');
@ -268,8 +264,47 @@ else {
}
}
else echo '<br /><strong class="error">'.__('Sorry! I can\'t find the page!').'</strong>';
}
else {
//home screen chosen by the user
$home_page ='';
if (isset($config['id_user'])) {
$user_info = users_get_user_by_id($config['id_user']);
$home_page = io_safe_output($user_info['section']);
$home_url = $user_info['data_section'];
}
if ($home_page != '') {
switch($home_page) {
case __('Event list'):
header ('location:' . $config['homeurl'] . '/index.php?sec=eventos&sec2=operation/events/events');
break;
case __('Group view'):
header ('location:' . $config['homeurl'] . '/index.php?sec=estado&sec2=operation/agentes/group_view');
break;
case __('Alert detail'):
header ('location:' . $config['homeurl'] . '/index.php?sec=estado&sec2=operation/agentes/alerts_status');
break;
case __('Tactical view'):
require ("general/logon_ok.php");
break;
case __('Dashboard'):
$id_dashboard = db_get_value('id', 'tdashboard', 'name', $home_url);
header ('location:' . $config['homeurl'] . '/index.php?sec=dashboard&sec2='.ENTERPRISE_DIR.'/dashboard/main_dashboard&id='.$id_dashboard);
break;
case __('Visual console'):
$id_visualc = db_get_value('id', 'tlayout', 'name', $home_url);
header ('location:' . $config['homeurl'] . '/index.php?sec=visualc&sec2=operation/visual_console/render_view&id='. $id_visualc .'&refr=60');
break;
case __('Other'):
header ('location:' . $config['homeurl'] . '/index.php?'. io_safe_output($home_url));
break;
}
} else {
require("general/logon_ok.php");
}
}
else require ("general/logon_ok.php");
require("general/shortcut_bar.php");
}
@ -296,3 +331,7 @@ echo '</html>';
$run_time = format_numeric (microtime (true) - $config['start_time'], 3);
echo "\n<!-- Page generated in $run_time seconds -->\n";
?>
<script language="javascript" type="text/javascript">
</script>

View File

@ -22,6 +22,7 @@ check_login ();
include_once($config['homedir'] . "/include/functions_profile.php");
include_once($config['homedir'] . '/include/functions_users.php');
include_once ($config['homedir'] . '/include/functions_groups.php');
include_once ($config['homedir'] . '/include/functions_visual_map.php');
$id = get_parameter_get ("id", $config["id_user"]); // ID given as parameter
$status = get_parameter ("status", -1); // Flag to print action status message
@ -90,7 +91,20 @@ 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);
$upd_info["section"] = get_parameter ("section", $user_info["section"]);
$upd_info["data_section"] = get_parameter ("data_section", '');
$dashboard = get_parameter('dashboard', '');
$visual_console = get_parameter('visual_console', '');
$section = io_safe_output($upd_info["section"]);
if (($section == 'Event list') || ($section == 'Group view') || ($section == 'Alert detail') || ($section == 'Tactical view')) {
$upd_info["data_section"] = '';
} else if ($section == 'Dashboard') {
$upd_info["data_section"] = $dashboard;
} else if ($section == 'Visual console') {
$upd_info["data_section"] = $visual_console;
}
if ( !empty ($password_new)) {
if ($config["user_can_update_password"] && $password_confirm == $password_new) {
$return = update_user_password ($id, $password_new);
@ -226,8 +240,38 @@ 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><tr><td class="datos">'.__('Home screen'). ui_print_help_tip(__('
User can customize the home page. By default, will display \'Tactical view\'. Example: Select \'Other\' and type sec=estado&sec2=operation/agentes/estado_agente to show agent detail view'), true) .'</td><td class="datos2">';
$values = array ('Dashboard'=>__('Dashboard'), 'Visual console'=>__('Visual console'), 'Event list'=>__('Event list'),
'Group view'=>__('Group view'), 'Tactical view'=>__('Tactical view'), 'Alert detail' => __('Alert detail'), 'Other'=>__('Other'));
echo html_print_select($values, 'section', io_safe_output($user_info["section"]), 'show_data_section();', '', -1, true, false, false);
echo "&nbsp;&nbsp;";
$dashboards = get_user_dashboards ($user_info['id_user']);
if ($dashboards === false) {
$dashboards = array('None'=>'None');
} else {
foreach ($dashboards as $key=>$dashboard) {
$dashboards_aux[$dashboard['name']] = $dashboard['name'];
}
}
echo html_print_select ($dashboards_aux, 'dashboard', $user_info["data_section"], '', '', '', true);
$layouts = visual_map_get_user_layouts ($user_info['id_user'], true);
if ($layouts === false) {
$layouts = array('None'=>'None');
} else {
foreach ($layouts as $layout) {
$layouts_aux[$layout] = $layout;
}
}
echo html_print_select ($layouts_aux, 'visual_console', $user_info["data_section"], '', '', '', true);
echo html_print_input_text ('data_section', $user_info["data_section"], '', 60, 255, true, false);
echo '</td></tr></table>';
echo '<div style="width:90%; text-align:right;">';
if (!$config["user_can_update_info"]) {
echo '<i>'.__('You can not change your user info from Pandora FMS under the current authentication scheme').'</i>';
@ -285,5 +329,48 @@ $(document).ready (function () {
$("#text-block_size").removeAttr('disabled');
}
}
show_data_section();
});
function show_data_section () {
section=$("#section").val();
switch (section) {
case <?php echo "'".__('Dashboard')."'"; ?>:
$("#text-data_section").css("display", "none");
$("#dashboard").css("display", "");
$("#visual_console").css("display", "none");
break;
case <?php echo "'".__('Visual console')."'"; ?>:
$("#text-data_section").css("display", "none");
$("#dashboard").css("display", "none");
$("#visual_console").css("display", "");
break;
case <?php echo "'".__('Event list')."'"; ?>:
$("#text-data_section").css("display", "none");
$("#dashboard").css("display", "none");
$("#visual_console").css("display", "none");
break;
case <?php echo "'".__('Group view')."'"; ?>:
$("#text-data_section").css("display", "none");
$("#dashboard").css("display", "none");
$("#visual_console").css("display", "none");
break;
case <?php echo "'".__('Tactical view')."'"; ?>:
$("#text-data_section").css("display", "none");
$("#dashboard").css("display", "none");
$("#visual_console").css("display", "none");
break;
case <?php echo "'".__('Alert detail')."'"; ?>:
$("#text-data_section").css("display", "none");
$("#dashboard").css("display", "none");
$("#visual_console").css("display", "none");
break;
case <?php echo "'".__('Other')."'"; ?>:
$("#text-data_section").css("display", "");
$("#dashboard").css("display", "none");
$("#visual_console").css("display", "none");
break;
}
}
</script>

View File

@ -868,7 +868,9 @@ CREATE TABLE tusuario (
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,
shortcut NUMBER(5, 0) DEFAULT 0
shortcut NUMBER(5, 0) DEFAULT 0,
section VARCHAR2(255) NOT NULL,
data_section VARCHAR2(255) NOT NULL
);
CREATE TABLE tusuario_perfil (

View File

@ -698,7 +698,9 @@ CREATE TABLE "tusuario" (
"flash_chart" INTEGER NOT NULL default 1,
"id_skin" INTEGER NOT NULL DEFAULT 0,
"disabled" INTEGER NOT NULL default 1,
"shortcut" SMALLINT DEFAULT 0
"shortcut" SMALLINT DEFAULT 0,
"section" varchar(255) NOT NULL,
"data_section" varchar(255) NOT NULL
);
CREATE TABLE "tusuario_perfil" (

View File

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