diff --git a/pandora_console/extras/mr/64.sql b/pandora_console/extras/mr/64.sql index 9408ab3ca5..c0e15cf01c 100644 --- a/pandora_console/extras/mr/64.sql +++ b/pandora_console/extras/mr/64.sql @@ -7,4 +7,13 @@ WHERE name='Cisco _nameOID_ power state'; ALTER TABLE `tlayout_data` ADD COLUMN `recursive_group` TINYINT NOT NULL DEFAULT '0' AFTER `fill_color`; -COMMIT; +ALTER TABLE `tusuario` +ADD COLUMN `metaconsole_section` VARCHAR(255) NOT NULL DEFAULT 'Default' AFTER `data_section`; + +ALTER TABLE `tusuario` +ADD COLUMN `metaconsole_data_section` VARCHAR(255) NOT NULL DEFAULT '' AFTER `metaconsole_section`; + +ALTER TABLE `tusuario` +ADD COLUMN `metaconsole_default_event_filter` INT UNSIGNED NOT NULL DEFAULT 0 AFTER `default_event_filter`; + +COMMIT; \ No newline at end of file diff --git a/pandora_console/godmode/users/configure_user.php b/pandora_console/godmode/users/configure_user.php index 3dc1db9b78..29b97084fe 100644 --- a/pandora_console/godmode/users/configure_user.php +++ b/pandora_console/godmode/users/configure_user.php @@ -90,6 +90,13 @@ if ($id !== $config['id_user']) { // ID given as parameter. $pure = get_parameter('pure', 0); $user_info = get_user_info($id); + +if (is_metaconsole() === true) { + $user_info['section'] = $user_info['metaconsole_section']; + $user_info['data_section'] = $user_info['metaconsole_data_section']; + $user_info['default_event_filter'] = $user_info['metaconsole_default_event_filter']; +} + $is_err = false; if (is_ajax() === true) { @@ -1466,6 +1473,10 @@ foreach ($event_filter_data as $filter) { $event_filter[$filter['id_filter']] = $filter['id_name']; } +if (is_metaconsole() === true && empty($user_info['metaconsole_default_event_filter']) !== true) { + $user_info['default_event_filter'] = $user_info['metaconsole_default_event_filter']; +} + $default_event_filter = '
'.__('Default event filter').'
'; $default_event_filter .= html_print_select( $event_filter, diff --git a/pandora_console/godmode/users/user_management.php b/pandora_console/godmode/users/user_management.php index dd2bf68404..b03c79f374 100644 --- a/pandora_console/godmode/users/user_management.php +++ b/pandora_console/godmode/users/user_management.php @@ -596,11 +596,15 @@ $userManagementTable->data['fields_blocksize_eventfilter'][0] = html_print_input true ); +if (is_metaconsole() === true && empty($user_info['metaconsole_default_event_filter']) !== true) { + $user_info['default_event_filter'] = $user_info['metaconsole_default_event_filter']; +} + $userManagementTable->data['captions_blocksize_eventfilter'][1] = __('Event filter'); $userManagementTable->data['fields_blocksize_eventfilter'][1] = html_print_select( $event_filter, 'default_event_filter', - ($user_info['default_event_filter'] ?? 0), + [$user_info['default_event_filter']], '', '', __('None'), @@ -617,6 +621,11 @@ $homeScreenTable->style = []; $homeScreenTable->rowclass = []; $homeScreenTable->data = []; // Home screen. +if (is_metaconsole() === true && empty($user_info['metaconsole_data_section']) !== true) { + $user_info['data_section'] = $user_info['metaconsole_data_section']; + $user_info['section'] = $user_info['metaconsole_section']; +} + $homeScreenTable->data['captions_homescreen'][0] = __('Home screen'); $homeScreenTable->colspan['captions_homescreen'][0] = 2; $homeScreenTable->rowclass['captions_homescreen'] = 'field_half_width'; @@ -643,6 +652,17 @@ $homeScreenTable->data['fields_homescreen'][1] = html_print_div( $userManagementTable->rowclass['homescreen_table'] = 'w100p'; $userManagementTable->data['homescreen_table'] = html_print_table($homeScreenTable, true); +$homeScreenTable->data['fields_homescreen'][1] = html_print_div( + [ + 'class' => 'w100p', + 'content' => $customHomeScreenDataField, + ], + true +); + +$userManagementTable->rowclass['homescreen_table'] = 'w100p'; +$userManagementTable->data['homescreen_table'] = html_print_table($homeScreenTable, true); + if (is_metaconsole() === true && users_is_admin() === true) { $userManagementTable->rowclass['search_custom1_looknfeel'] = 'field_half_width'; diff --git a/pandora_console/include/auth/mysql.php b/pandora_console/include/auth/mysql.php index 8c1e27f0f9..eb8fd521c2 100644 --- a/pandora_console/include/auth/mysql.php +++ b/pandora_console/include/auth/mysql.php @@ -801,6 +801,34 @@ function update_user(string $id_user, array $values) return false; } + if (isset($values['section']) === true) { + $homeScreenValues = [ + HOME_SCREEN_DEFAULT => __('Default'), + HOME_SCREEN_VISUAL_CONSOLE => __('Visual console'), + HOME_SCREEN_EVENT_LIST => __('Event list'), + HOME_SCREEN_GROUP_VIEW => __('Group view'), + HOME_SCREEN_TACTICAL_VIEW => __('Tactical view'), + HOME_SCREEN_ALERT_DETAIL => __('Alert detail'), + HOME_SCREEN_EXTERNAL_LINK => __('External link'), + HOME_SCREEN_OTHER => __('Other'), + HOME_SCREEN_DASHBOARD => __('Dashboard'), + ]; + + if (array_key_exists($values['section'], $homeScreenValues) === true) { + $values['section'] = $homeScreenValues[$values['section']]; + } + + if (is_metaconsole() === true) { + $values['metaconsole_section'] = $values['section']; + $values['metaconsole_data_section'] = $values['data_section']; + $values['metaconsole_default_event_filter'] = $values['default_event_filter']; + unset($values['id_skin']); + unset($values['section']); + unset($values['data_section']); + unset($values['default_event_filter']); + } + } + $output = db_process_sql_update('tusuario', $values, ['id_user' => $id_user]); if (isset($values['is_admin']) === true && (bool) $values['is_admin'] === true) { diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index 834f09ca7a..91d4cd734e 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -899,7 +899,7 @@ function html_print_select( if (is_array($selected) && in_array($value, $selected)) { $output .= ' selected="selected"'; } else if (is_numeric($value) && is_numeric($selected) - && $value == $selected + && $value === $selected ) { // This fixes string ($value) to int ($selected) comparisons $output .= ' selected="selected"'; diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index a826986e95..f0e69a427c 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -1100,16 +1100,29 @@ $load_filter_id = (int) get_parameter('filter_id', 0); $fav_menu = []; if ($load_filter_id === 0) { // Load user filter. - $loaded_filter = db_get_row_sql( - sprintf( - 'SELECT f.id_filter, f.id_name - FROM tevent_filter f - INNER JOIN tusuario u - ON u.default_event_filter=f.id_filter - WHERE u.id_user = "%s" ', - $config['id_user'] - ) - ); + if (is_metaconsole() === true) { + $loaded_filter = db_get_row_sql( + sprintf( + 'SELECT f.id_filter, f.id_name + FROM tevent_filter f + INNER JOIN tusuario u + ON u.metaconsole_default_event_filter=f.id_filter + WHERE u.id_user = "%s" ', + $config['id_user'] + ) + ); + } else { + $loaded_filter = db_get_row_sql( + sprintf( + 'SELECT f.id_filter, f.id_name + FROM tevent_filter f + INNER JOIN tusuario u + ON u.default_event_filter=f.id_filter + WHERE u.id_user = "%s" ', + $config['id_user'] + ) + ); + } } else { // Load filter selected by user. $loaded_filter['id_filter'] = $load_filter_id; diff --git a/pandora_console/operation/users/user_edit.php b/pandora_console/operation/users/user_edit.php index 17aedf98ed..f67d54c3bb 100644 --- a/pandora_console/operation/users/user_edit.php +++ b/pandora_console/operation/users/user_edit.php @@ -475,7 +475,12 @@ $skin = ''; 'Dashboard' => __('Dashboard'), ]; - $home_screen .= html_print_select($values, 'section', io_safe_output($user_info['section']), 'show_data_section();', '', -1, true, false, false).''.__('Event filter').'
'; $user_groups = implode(',', array_keys((users_get_groups($config['id_user'], 'AR', true)))); diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 38ce21bc71..4d0f3e737d 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -1296,6 +1296,8 @@ CREATE TABLE IF NOT EXISTS `tusuario` ( `shortcut_data` TEXT, `section` TEXT, `data_section` TEXT, + `metaconsole_section` VARCHAR(255) NOT NULL DEFAULT 'Default', + `metaconsole_data_section` VARCHAR(255) NOT NULL DEFAULT '', `force_change_pass` TINYINT UNSIGNED NOT NULL DEFAULT 0, `last_pass_change` DATETIME, `last_failed_login` DATETIME, @@ -1310,6 +1312,7 @@ CREATE TABLE IF NOT EXISTS `tusuario` ( `id_filter` INT UNSIGNED NULL DEFAULT NULL, `session_time` INT signed NOT NULL DEFAULT 0, `default_event_filter` INT UNSIGNED NOT NULL DEFAULT 0, + `metaconsole_default_event_filter` INT UNSIGNED NOT NULL DEFAULT 0, `show_tips_startup` TINYINT UNSIGNED NOT NULL DEFAULT 1, `autorefresh_white_list` TEXT , `time_autorefresh` INT UNSIGNED NOT NULL DEFAULT 30,