From b99298786ea27f347594115516a9ba67e80a6513 Mon Sep 17 00:00:00 2001 From: Tatiana Llorente Date: Tue, 19 May 2020 08:20:04 +0200 Subject: [PATCH] Ent 5754 editor de usuarios de godmode que sea visualmente similar al editor de usuarios el propio usuario --- .../godmode/users/configure_user.php | 455 ++++++++++++------ pandora_console/include/functions_html.php | 10 +- pandora_console/include/functions_profile.php | 13 +- pandora_console/include/styles/pandora.css | 41 +- 4 files changed, 350 insertions(+), 169 deletions(-) diff --git a/pandora_console/godmode/users/configure_user.php b/pandora_console/godmode/users/configure_user.php index dc0f726dc0..f4134a27e2 100644 --- a/pandora_console/godmode/users/configure_user.php +++ b/pandora_console/godmode/users/configure_user.php @@ -46,6 +46,54 @@ if ($enterprise_include) { enterprise_include_once('meta/include/functions_users_meta.php'); } + +if (!is_metaconsole()) { + date_default_timezone_set('UTC'); + include 'include/javascript/timezonepicker/includes/parser.inc'; + + // Read in options for map builder. + $bases = [ + 'gray' => 'Gray', + 'blue-marble' => 'Blue marble', + 'night-electric' => 'Night Electric', + 'living' => 'Living Earth', + ]; + + $local_file = 'include/javascript/timezonepicker/images/gray-400.png'; + + // Dimensions must always be exact since the imagemap does not scale. + $array_size = getimagesize($local_file); + + $map_width = $array_size[0]; + $map_height = $array_size[1]; + + $timezones = timezone_picker_parse_files( + $map_width, + $map_height, + 'include/javascript/timezonepicker/tz_world.txt', + 'include/javascript/timezonepicker/tz_islands.txt' + ); + + + foreach ($timezones as $timezone_name => $tz) { + if ($timezone_name == 'America/Montreal') { + $timezone_name = 'America/Toronto'; + } else if ($timezone_name == 'Asia/Chongqing') { + $timezone_name = 'Asia/Shanghai'; + } + + $area_data_timezone_polys .= ''; + foreach ($tz['polys'] as $coords) { + $area_data_timezone_polys .= ''; + } + + $area_data_timezone_rects .= ''; + foreach ($tz['rects'] as $coords) { + $area_data_timezone_rects .= ''; + } + } +} + // This defines the working user. Beware with this, old code get confusses // and operates with current logged user (dangerous). $id = get_parameter('id', get_parameter('id_user', '')); @@ -75,6 +123,12 @@ if (! check_acl($config['id_user'], 0, 'UM')) { $tab = get_parameter('tab', 'user'); +if ($id) { + $header_title = ' » '.__('Update user'); +} else { + $header_title = ' » '.__('Create user'); +} + // Header if ($meta) { user_meta_print_header(); @@ -94,7 +148,7 @@ if ($meta) { $buttons[$tab]['active'] = true; ui_print_page_header( - __('User detail editor'), + __('User detail editor').$header_title, 'images/gm_users.png', false, 'profile_tab', @@ -625,59 +679,61 @@ if ($values) { $user_info = $values; } -$table = new stdClass(); -$table->id = 'user_configuration_table'; -$table->width = '100%'; -$table->class = 'databox filters'; if (defined('METACONSOLE')) { if ($id) { - $table->head[0] = __('Update User'); + echo '
'.__('Update User').'
'; } else { - $table->head[0] = __('Create User'); + echo '
'.__('Create User').'
'; } - - $table->head_colspan[0] = 5; - $table->headstyle[0] = 'text-align: center'; } -$table->data = []; -$table->colspan = []; -$table->size = []; -$table->size[0] = '35%'; -$table->size[1] = '65%'; -$table->style = []; -$table->style[0] = 'font-weight: bold;'; +if (!$new_user) { + $user_id = '

'.__('User ID').':

'; + $user_id .= ''.$id.''; + $user_id .= html_print_input_hidden('id_user', $id, true); + $user_id .= '
'; +} else { + $user_id = '
'.html_print_input_text_extended( + 'id_user', + $id, + '', + '', + 20, + 100, + !$new_user || $view_mode, + '', + [ + 'class' => 'input_line user_icon_input', + 'placeholder' => __('User ID'), + ], + true + ).'
'; +} -$table->data[0][0] = __('User ID'); -$table->data[0][1] = html_print_input_text_extended( - 'id_user', - $id, - '', - '', - 20, - 60, - !$new_user || $view_mode, - '', - '', - true -); +if (is_user_admin($id)) { + $avatar = html_print_image('images/people_1.png', true, ['class' => 'user_avatar']); +} else { + $avatar = html_print_image('images/people_2.png', true, ['class' => 'user_avatar']); +} -$table->data[1][0] = __('Full (display) name'); -$table->data[1][1] = html_print_input_text_extended( +$full_name = '
'.html_print_input_text_extended( 'fullname', $user_info['fullname'], + 'fullname', '', - '', - 30, - 125, + 20, + 100, $view_mode, '', - '', + [ + 'class' => 'input', + 'placeholder' => __('Full (display) name'), + ], true -); +).'
'; -$table->data[2][0] = __('Language'); -$table->data[2][1] = html_print_select_from_sql( +$language = '

'.__('Language').':

'; +$language .= html_print_select_from_sql( 'SELECT id_language, name FROM tlanguage', 'language', $user_info['language'], @@ -685,88 +741,112 @@ $table->data[2][1] = html_print_select_from_sql( __('Default'), 'default', true -); +).'
'; -$table->data[3][0] = __('Timezone'); -$table->data[3][1] = html_print_timezone_select('timezone', $user_info['timezone']); + +$timezone = '

'.__('Timezone').':

'; +$timezone .= html_print_timezone_select('timezone', $user_info['timezone']).'
'; if ($config['user_can_update_password']) { - $table->data[4][0] = __('Password'); - $table->data[4][1] = html_print_input_text_extended( + $new_pass = '
'.html_print_input_text_extended( 'password_new', '', + 'password_new', '', - '', - 15, - 45, + '25', + '45', $view_mode, '', - '', + [ + 'class' => 'input', + 'placeholder' => __('Password'), + ], true, true - ); - $table->data[5][0] = __('Password confirmation'); - $table->data[5][1] = html_print_input_text_extended( + ).'
'; + $new_pass_confirm = '
'.html_print_input_text_extended( 'password_confirm', '', + 'password_conf', '', - '', - 15, - 45, + '20', + '45', $view_mode, '', - '', + [ + 'class' => 'input', + 'placeholder' => __('Password confirmation'), + ], true, true - ); + ).'
'; } $own_info = get_user_info($config['id_user']); -if ($config['admin_can_make_admin']) { - $table->data[6][0] = __('Global Profile'); - $table->data[6][1] = ''; - if ($own_info['is_admin'] || $user_info['is_admin']) { - $table->data[6][1] = html_print_radio_button('is_admin', 1, '', $user_info['is_admin'], true); - $table->data[6][1] .= __('Administrator'); - $table->data[6][1] .= ui_print_help_tip(__('This user has permissions to manage all. An admin user should not requiere additional group permissions, except for using Enterprise ACL.'), true); - $table->data[6][1] .= '
'; - } +$global_profile = '
'.__('Global Profile').': '; +$global_profile .= '
'; +$global_profile .= html_print_radio_button_extended( + 'is_admin', + 1, + [ + 'label' => __('Administrator'), + 'help_tip' => __('This user has permissions to manage all. An admin user should not requiere additional group permissions, except for using Enterprise ACL.'), + ], + $user_info['is_admin'], + false, + '', + '', + true +); +$global_profile .= html_print_radio_button_extended( + 'is_admin', + 0, + [ + 'label' => __('Standard User'), + 'help_tip' => __('This user has separated permissions to view data in his group agents, create incidents belong to his groups, add notes in another incidents, create personal assignments or reviews and other tasks, on different profiles'), + ], + $user_info['is_admin'], + false, + '', + '', + true +); +$global_profile .= '
'; - $table->data[6][1] .= html_print_radio_button('is_admin', 0, '', $user_info['is_admin'], true); - $table->data[6][1] .= __('Standard User'); - $table->data[6][1] .= ui_print_help_tip(__('This user has separated permissions to view data in his group agents, create incidents belong to his groups, add notes in another incidents, create personal assignments or reviews and other tasks, on different profiles'), true); -} - -$table->data[7][0] = __('E-mail'); -$table->data[7][1] = html_print_input_text_extended( +$email = '
'.html_print_input_text_extended( 'email', $user_info['email'], + 'email', '', - '', - 20, - 100, + '25', + '100', $view_mode, '', - '', + [ + 'class' => 'input input_line email_icon_input', + 'placeholder' => __('E-mail'), + ], true -); +).'
'; -$table->data[8][0] = __('Phone number'); -$table->data[8][1] = html_print_input_text_extended( +$phone = '
'.html_print_input_text_extended( 'phone', $user_info['phone'], + 'phone', '', - '', - 10, - 30, + '20', + '30', $view_mode, '', - '', + [ + 'class' => 'input input_line phone_icon_input', + 'placeholder' => __('Phone number'), + ], true -); +).'
'; -$table->data[9][0] = __('Comments'); -$table->data[9][1] = html_print_textarea( +$comments = '

'.__('Comments').':

'; +$comments .= html_print_textarea( 'comments', 2, 65, @@ -795,16 +875,17 @@ if (!$meta) { // User only can change skins if has more than one group if (count($usr_groups) > 1) { if ($isFunctionSkins !== ENTERPRISE_NOT_HOOK) { - $table->data[10][0] = __('Skin'); - $table->data[10][1] = skins_print_select($id_usr, 'skin', $user_info['id_skin'], '', __('None'), 0, true); + $skin = '

'.__('Skin').':

'; + $skin .= skins_print_select($id_usr, 'skin', $user_info['id_skin'], '', __('None'), 0, true).'
'; } } } if ($meta) { $array_filters = get_filters_custom_fields_view(0, true); - $table->data[11][0] = __('Search custom field view').' '.ui_print_help_tip(__('Load by default the selected view in custom field view'), true); - $table->data[11][1] = html_print_select( + + $search_custom_fields_view = '

'.__('Search custom field view').' '.ui_print_help_tip(__('Load by default the selected view in custom field view'), true).'

'; + $search_custom_fields_view .= html_print_select( $array_filters, 'default_custom_view', $user_info['default_custom_view'], @@ -816,7 +897,7 @@ if ($meta) { true, '', false - ); + ).'
'; } $values = [ @@ -825,7 +906,8 @@ $values = [ 0 => __('No'), ]; -$table->data[12][0] = __('Home screen').ui_print_help_tip(__('User can customize the home page. By default, will display \'Agent Detail\'. Example: Select \'Other\' and type index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=1 to show agent detail view'), true); +$home_screen = '

'.__('Home screen').ui_print_help_tip(__('User can customize the home page. By default, will display \'Agent Detail\'. Example: Select \'Other\' and type index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=1 to show agent detail view'), true).'

'; +; $values = [ 'Default' => __('Default'), 'Visual console' => __('Visual console'), @@ -841,7 +923,7 @@ if (!is_metaconsole()) { } -$table->data[12][1] = html_print_select($values, 'section', io_safe_output($user_info['section']), 'show_data_section();', '', -1, true, false, false); +$home_screen .= html_print_select($values, 'section', io_safe_output($user_info['section']), 'show_data_section();', '', -1, true, false, false).'
'; $dashboards = Manager::getDashboards(-1, -1); @@ -854,7 +936,7 @@ if ($dashboards === false) { } } -$table->data[12][1] .= html_print_select($dashboards_aux, 'dashboard', $user_info['data_section'], '', '', '', true); +$home_screen .= html_print_select($dashboards_aux, 'dashboard', $user_info['data_section'], '', '', '', true); $layouts = visual_map_get_user_layouts($config['id_user'], true); @@ -867,14 +949,14 @@ if ($layouts === false) { } } -$table->data[12][1] .= html_print_select($layouts_aux, 'visual_console', $user_info['data_section'], '', '', '', true); -$table->data[12][1] .= html_print_input_text('data_section', $user_info['data_section'], '', 60, 255, true, false); +$home_screen .= html_print_select($layouts_aux, 'visual_console', $user_info['data_section'], '', '', '', true); +$home_screen .= html_print_input_text('data_section', $user_info['data_section'], '', 60, 255, true, false); -$table->data[13][0] = __('Block size for pagination'); -$table->data[13][1] = html_print_input_text('block_size', $user_info['block_size'], '', 5, 5, true); +$size_pagination = '

'.__('Block size for pagination').'

'; +$size_pagination .= html_print_input_text('block_size', $user_info['block_size'], '', 5, 5, true).'
'; if ($id == $config['id_user']) { - $table->data[13][1] .= html_print_input_hidden('quick_language_change', 1, true); + $language .= html_print_input_hidden('quick_language_change', 1, true); } if (enterprise_installed() && defined('METACONSOLE')) { @@ -883,12 +965,12 @@ if (enterprise_installed() && defined('METACONSOLE')) { $user_info_metaconsole_access = $user_info['metaconsole_access']; } - $table->data[13][0] = __('Metaconsole access').' '.ui_print_help_icon('meta_access', true); + $meta_access = '

'.__('Metaconsole access').' '.ui_print_help_icon('meta_access', true).'

'; $metaconsole_accesses = [ 'basic' => __('Basic'), 'advanced' => __('Advanced'), ]; - $table->data[13][1] = html_print_select( + $meta_access .= html_print_select( $metaconsole_accesses, 'metaconsole_access', $user_info_metaconsole_access, @@ -898,16 +980,16 @@ if (enterprise_installed() && defined('METACONSOLE')) { true, false, false - ); + ).'
'; } -$table->data[14][0] = __('Not Login'); -$table->data[14][0] .= ui_print_help_tip(__('The user with not login set only can access to API.'), true); -$table->data[14][1] = html_print_checkbox('not_login', 1, $user_info['not_login'], true); +$not_login = '

'.__('Not Login').'

'; +$not_login .= ui_print_help_tip(__('The user with not login set only can access to API.'), true); +$not_login .= html_print_checkbox_switch('not_login', 1, $user_info['not_login'], true).'
'; -$table->data[15][0] = __('Session Time'); -$table->data[15][0] .= ui_print_help_tip(__('This is defined in minutes, If you wish a permanent session should putting -1 in this field.'), true); -$table->data[15][1] = html_print_input_text('session_time', $user_info['session_time'], '', 5, 5, true); +$session_time = '

'.__('Session Time'); +$session_time .= ui_print_help_tip(__('This is defined in minutes, If you wish a permanent session should putting -1 in this field.'), true).'

'; +$session_time .= html_print_input_text('session_time', $user_info['session_time'], '', 5, 5, true.false, false, '', 'class="input_line_small"').'
'; $event_filter_data = db_get_all_rows_sql('SELECT id_name, id_filter FROM tevent_filter'); if ($event_filter_data === false) { @@ -920,69 +1002,104 @@ foreach ($event_filter_data as $filter) { $event_filter[$filter['id_filter']] = $filter['id_name']; } -$table->data[16][0] = __('Default event filter'); -$table->data[16][1] = html_print_select($event_filter, 'default_event_filter', $user_info['default_event_filter'], '', '', __('None'), true, false, false); +$default_event_filter = '

'.__('Default event filter').'

'; +$default_event_filter .= html_print_select($event_filter, 'default_event_filter', $user_info['default_event_filter'], '', '', __('None'), true, false, false).'
'; -$table->data[17][0] = __('Disabled newsletter'); +$newsletter = '

'.__('Disabled newsletter').'

'; if ($user_info['middlename'] >= 0) { $middlename = false; } else { $middlename = true; } -$table->data[17][1] = html_print_checkbox( +$newsletter .= html_print_checkbox_switch( 'middlename', -1, $middlename, true -); +).'
'; if ($config['ehorus_user_level_conf']) { - $table->data[18][0] = __('eHorus user acces enabled'); - $table->data[18][1] = html_print_checkbox('ehorus_user_level_enabled', 1, $user_info['ehorus_user_level_enabled'], true); - $table->data[19][0] = __('eHorus user'); - $table->data[20][0] = __('eHorus password'); - $table->data[19][1] = html_print_input_text('ehorus_user_level_user', $user_info['ehorus_user_level_user'], '', 15, 45, true); - $table->data[20][1] = html_print_input_password('ehorus_user_level_pass', io_output_password($user_info['ehorus_user_level_pass']), '', 15, 45, true); + $ehorus = '

'.__('eHorus user access enabled').'

'; + $ehorus .= html_print_checkbox_switch('ehorus_user_level_enabled', 1, $user_info['ehorus_user_level_enabled'], true).'
'; + $ehorus .= '
'; + $ehorus .= '

'.__('eHorus user').'

'; + $ehorus .= html_print_input_text('ehorus_user_level_user', $user_info['ehorus_user_level_user'], '', 15, 45, true).'
'; + $ehorus .= '

'.__('eHorus password').'

'; + $ehorus .= html_print_input_password('ehorus_user_level_pass', io_output_password($user_info['ehorus_user_level_pass']), '', 15, 45, true).'
'; + $ehorus .= '
'; } if ($meta) { enterprise_include_once('include/functions_metaconsole.php'); - $data = []; - $data[0] = __('Enable agents managment'); - $data[1] = html_print_checkbox('metaconsole_agents_manager', 1, $user_info['metaconsole_agents_manager'], true); - $table->rowclass[] = ''; - $table->rowstyle[] = 'font-weight: bold;'; - $table->data['metaconsole_agents_manager'] = $data; + $metaconsole_agents_manager = '

'.__('Enable agents managment').'

'; + $metaconsole_agents_manager .= html_print_checkbox_switch('metaconsole_agents_manager', 1, $user_info['metaconsole_agents_manager'], true).'
'; - $data = []; - $data[0] = __('Assigned node').ui_print_help_tip(__('Server where the agents created of this user will be placed'), true); + $metaconsole_assigned_server = '

'.__('Assigned node').ui_print_help_tip(__('Server where the agents created of this user will be placed'), true).'

'; $servers = metaconsole_get_servers(); $servers_for_select = []; foreach ($servers as $server) { $servers_for_select[$server['id']] = $server['server_name']; } - $data[1] = html_print_select($servers_for_select, 'metaconsole_assigned_server', $user_info['metaconsole_assigned_server'], '', '', -1, true, false, false); - $table->rowclass[] = ''; - $table->rowstyle[] = 'font-weight: bold;'; - $table->data['metaconsole_assigned_server'] = $data; + $metaconsole_assigned_server .= html_print_select($servers_for_select, 'metaconsole_assigned_server', $user_info['metaconsole_assigned_server'], '', '', -1, true, false, false).'
'; - $data = []; - $data[0] = __('Enable node access').ui_print_help_tip(__('With this option enabled, the user will can access to nodes console'), true); - $data[2] = html_print_checkbox('metaconsole_access_node', 1, $user_info['metaconsole_access_node'], true); - $table->rowclass[] = ''; - $table->rowstyle[] = ''; - $table->data['metaconsole_access_node'] = $data; + $metaconsole_access_node = '

'.__('Enable node access').ui_print_help_tip(__('With this option enabled, the user will can access to nodes console'), true).'

'; + $metaconsole_access_node .= html_print_checkbox('metaconsole_access_node', 1, $user_info['metaconsole_access_node'], true).'
'; } echo '
'; -html_print_table($table); -echo '
'; +if (!$id) { + $user_id_update_view = $user_id; + $user_id_create = ''; +} else { + $user_id_update_view = ''; + $user_id_create = $user_id; +} + +if (is_metaconsole()) { + $access_or_pagination = $meta_access; +} else { + $access_or_pagination = $size_pagination; +} + + +echo '
+
+ +

Extra info:

'.$email.$phone.$not_login.$session_time.'
+
+
+
'.$language.$access_or_pagination.$skin.$home_screen.$default_event_filter.$newsletter.'
+ +
'.$timezone; +if (!is_metaconsole()) { + echo '
+ + + '.$area_data_timezone_polys.$area_data_timezone_rects.' +
'; +} else { + echo $search_custom_fields_view.$metaconsole_agents_manager.$metaconsole_assigned_server.$metaconsole_access_node; +} + + echo '
+
+ +
+
'.$comments.'
+
+
'.$ehorus.'
+
'; + +echo '
'; if ($config['admin_can_add_user']) { html_print_csrf_hidden(); if ($new_user) { @@ -1005,32 +1122,62 @@ if (!empty($id) && !$new_user) { enterprise_hook('close_meta_frame'); +if (!is_metaconsole()) { + ?> + + + + + '."\n\t"; + echo ''."\n\t"; + // Closes no meta condition. +} + ?>