Merge branch 'ent-11117-edicion-usuario-entorno-meta-nodo' into 'develop'

Ent 11117 edicion usuario entorno meta nodo

See merge request artica/pandorafms!5856
This commit is contained in:
Rafael Ameijeiras 2023-05-22 16:12:04 +00:00
commit 8aae692cb2
8 changed files with 107 additions and 14 deletions

View File

@ -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;

View File

@ -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 = '<div class="label_select"><p class="edit_user_labels">'.__('Default event filter').'</p>';
$default_event_filter .= html_print_select(
$event_filter,

View File

@ -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';

View File

@ -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) {

View File

@ -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"';

View File

@ -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;

View File

@ -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).'</div>';
if (is_metaconsole() === true) {
$home_screen .= html_print_select($values, 'metaconsole_section', io_safe_output($user_info['section']), 'show_data_section();', '', -1, true, false, false).'</div>';
} else {
$home_screen .= html_print_select($values, 'section', io_safe_output($user_info['section']), 'show_data_section();', '', -1, true, false, false).'</div>';
}
$dashboards = Manager::getDashboards(
-1,
@ -558,6 +563,10 @@ $skin = '';
$double_authentication .= '</div>';
}
if (is_metaconsole() === true && empty($user_info['metaconsole_default_event_filter']) !== true) {
$user_info['default_event_filter'] = $user_info['metaconsole_default_event_filter'];
}
if ((bool) check_acl($config['id_user'], 0, 'ER') === true) {
$event_filter = '<div class="label_select"><p class="edit_user_labels">'.__('Event filter').'</p>';
$user_groups = implode(',', array_keys((users_get_groups($config['id_user'], 'AR', true))));

View File

@ -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,