diff --git a/pandora_console/godmode/massive/massive_delete_profiles.php b/pandora_console/godmode/massive/massive_delete_profiles.php index 3a8611f3c7..7c45b2a285 100644 --- a/pandora_console/godmode/massive/massive_delete_profiles.php +++ b/pandora_console/godmode/massive/massive_delete_profiles.php @@ -141,6 +141,7 @@ if ($table !== null) { unset($table); +$table = new stdClass(); $table->width = '100%'; $table->class = 'databox filters'; $table->data = []; diff --git a/pandora_console/godmode/massive/massive_edit_users.php b/pandora_console/godmode/massive/massive_edit_users.php new file mode 100644 index 0000000000..2f1cbeb4fe --- /dev/null +++ b/pandora_console/godmode/massive/massive_edit_users.php @@ -0,0 +1,717 @@ +'.__('metaconsole').''; + } else { + $url = __('any node'); + } + + ui_print_warning_message( + __( + 'This node is configured with centralized mode. All profiles user information is read only. Go to %s to manage it.', + $url + ) + ); + + return; +} + +if (is_metaconsole() === true) { + include_once $config['homedir'].'/include/functions_visual_map.php'; + open_meta_frame(); +} + +$edit_users = (int) get_parameter('edit_users'); +if ($edit_users === 1) { + $users = get_parameter('id_users', false, false); + if ($users !== false) { + $update = []; + + $language = (string) get_parameter('language', '-1'); + if ($language !== '-1') { + $update['language'] = $language; + } + + $block_size_change = (int) get_parameter('block_size_change'); + if ($block_size_change === 0) { + $block_size = (int) get_parameter('block_size', -1); + if ($block_size !== -1) { + $update['block_size'] = $block_size; + } + } + + $section = get_parameter('section', '-1'); + if ($section !== '-1') { + $update['section'] = $section; + } + + $data_section = get_parameter('data_section', ''); + $dashboard = get_parameter('dashboard', ''); + $visual_console = get_parameter('visual_console', ''); + $section = io_safe_output($section); + + if (($section === 'Event list') || ($section === 'Group view') + || ($section === 'Alert detail') || ($section === 'Tactical view') + || ($section === 'Default') + ) { + $update['data_section'] = ''; + } else if ($section === 'Dashboard') { + $update['data_section'] = $dashboard; + } else if ($section === 'Visual console') { + $update['data_section'] = $visual_console; + } + + $event = (int) get_parameter('event_filter', -1); + if ($event !== -1) { + $update['default_event_filter'] = $event; + } + + $autorefresh_list = get_parameter_post('autorefresh_list', [0 => '-1']); + if ($autorefresh_list[0] !== '-1') { + if (($autorefresh_list[0] === '') || ($autorefresh_list[0] === '0')) { + $update['autorefresh_white_list'] = ''; + } else { + $update['autorefresh_white_list'] = json_encode($autorefresh_list); + } + } + + $time_autorefresh = (int) get_parameter('time_autorefresh', -1); + if ($time_autorefresh !== -1) { + $update['time_autorefresh'] = $time_autorefresh; + } + + $timezone = (string) get_parameter('timezone', '-1'); + if ($timezone !== '-1') { + $update['timezone'] = $timezone; + } + + $disabled = (int) get_parameter('disabled', -1); + if ($disabled !== -1) { + $update['disabled'] = $disabled; + } + + $error = []; + $success = []; + foreach ($users as $key => $user) { + if (empty($update) === false) { + $result = update_user($user, $update); + if ($result === false) { + $error[] = $user; + } else { + $success[] = $user; + } + } else { + $error[] = $user; + } + } + + if (empty($success) === false) { + ui_print_success_message( + __( + 'Users updated successfully (%s)', + implode( + ',', + $success + ) + ) + ); + } + + if (empty($error) === false) { + ui_print_error_message( + __( + 'Users cannot be updated (%s)', + implode(',', $error) + ) + ); + } + } +} + +if (is_metaconsole() === false) { + 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' + ); +} + + +$get_users = get_users(); +$users = []; +if (empty($get_users) === false) { + foreach ($get_users as $key => $value) { + $users[$key] = $key; + } +} + +$users_div = '

'.__('Users').'

'; +$users_div .= html_print_select( + $users, + 'id_users[]', + 0, + false, + '', + '', + true, + true, + true, + '', + false, + '', + false, + false, + false, + '', + false, + false, + false, + false, + true, + true, + true +).'
'; +echo '
'; +echo '
'; +echo '
'.$users_div.'
'; +echo '
'; + +// Language. +$language_db = db_get_all_rows_sql('SELECT id_language, name FROM tlanguage'); +array_unshift($language_db, ['id_language' => 'default', 'name' => __('Default')]); +$language_list = []; +foreach ($language_db as $key => $value) { + $language_list[$value['id_language']] = $value['name']; +} + +$language = '

'.__('Language').'

'; +$language .= html_print_select( + $language_list, + 'language', + '', + '', + __('No change'), + -1, + true, + false, + false +).'
'; + +// Pagination. +$block_size = $config['global_block_size']; +$size_pagination = '

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

'; +$size_pagination .= html_print_input_text('block_size', $block_size, '', 5, 5, true); +$size_pagination .= html_print_checkbox_switch('block_size_change', 1, 1, true); +$size_pagination .= ''.__('No change').''; +$size_pagination .= '
'; + +// Home screen. +$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 = [ + '-1' => __('No change'), + 'Default' => __('Default'), + 'Visual console' => __('Visual console'), + 'Event list' => __('Event list'), + 'Group view' => __('Group view'), + 'Tactical view' => __('Tactical view'), + 'Alert detail' => __('Alert detail'), + 'Other' => __('Other'), + 'Dashboard' => __('Dashboard'), +]; + +$home_screen .= html_print_select( + $values, + 'section', + '', + 'show_data_section();', + '', + -1, + true, + false, + false, + '', + false, + '', + '', + 10 +).'
'; + +$dashboards = get_user_dashboards($config['id_user']); + +$dashboards_aux = []; +if ($dashboards === false) { + $dashboards = ['None' => 'None']; +} else { + foreach ($dashboards as $key => $dashboard) { + $dashboards_aux[$dashboard['id']] = $dashboard['name']; + } +} + +$home_screen .= ''; + +$layouts = visual_map_get_user_layouts($config['id_user'], true); +$layouts_aux = []; +if (empty($layouts) === true) { + $layouts_aux = ['None' => 'None']; +} else { + foreach ($layouts as $layout) { + $layouts_aux[$layout] = $layout; + } +} + +$home_screen .= ''; +$home_screen .= html_print_input_text('data_section', '', '', 60, 255, true, false); + + +// Event filter. +$user_groups = implode(',', array_keys((users_get_groups($config['id_user'], 'AR', true)))); +$event_list = db_get_all_rows_sql('SELECT id_filter, id_name AS name FROM tevent_filter WHERE id_group_filter IN ('.$user_groups.')'); +if (empty($event_list) === true) { + $event_list = []; +} + +array_unshift($event_list, ['id_filter' => 'none', 'name' => __('None')]); + +$event_filter = '

'.__('Event filter').'

'; +$event_filter .= html_print_select( + $event_list, + 'event_filter', + '', + '', + __('No change'), + -1, + true, + false, + false +).'
'; + +// Autorefresh. +$autorefresh_list_out = []; +if (is_metaconsole() === false || is_centralized() === true) { + $autorefresh_list_out['operation/agentes/estado_agente'] = 'Agent detail'; + $autorefresh_list_out['operation/agentes/alerts_status'] = 'Alert detail'; + $autorefresh_list_out['enterprise/operation/cluster/cluster'] = 'Cluster view'; + $autorefresh_list_out['operation/gis_maps/render_view'] = 'Gis Map'; + $autorefresh_list_out['operation/reporting/graph_viewer'] = 'Graph Viewer'; + $autorefresh_list_out['operation/snmpconsole/snmp_view'] = 'SNMP console'; + + if (enterprise_installed()) { + $autorefresh_list_out['general/sap_view'] = 'SAP view'; + } +} + +$autorefresh_list_out['operation/agentes/tactical'] = 'Tactical view'; +$autorefresh_list_out['operation/agentes/group_view'] = 'Group view'; +$autorefresh_list_out['operation/agentes/status_monitor'] = 'Monitor detail'; +$autorefresh_list_out['enterprise/operation/services/services'] = 'Services'; +$autorefresh_list_out['operation/dashboard/dashboard'] = 'Dashboard'; + +$autorefresh_list_out['operation/agentes/pandora_networkmap'] = 'Network map'; +$autorefresh_list_out['operation/visual_console/render_view'] = 'Visual console'; +$autorefresh_list_out['operation/events/events'] = 'Events'; + +$autorefresh_show = '

'._('Autorefresh').ui_print_help_tip( + __('This will activate autorefresh in selected pages'), + true +).'

'; +$select_out = html_print_select( + $autorefresh_list_out, + 'autorefresh_list_out[]', + '', + '', + '', + '', + true, + true, + true, + '', + false, + 'width:100%;min-height: 150px;' +); +$arrows = ' '; +$autorefresh_list = []; +$autorefresh_list['-1'] = __('No change'); +$autorefresh_list[] = __('None'); + +$select_in = html_print_select( + $autorefresh_list, + 'autorefresh_list[]', + '-1', + '', + '', + '', + true, + true, + true, + '', + false, + 'width:100%;min-height: 150px;' +); + +$table_ichanges = '
+
+

'.__('Full list of pages').':

+
'.$select_out.'
+
+ +
+

'.__('List of pages with autorefresh').':

+
'.$select_in.'
+
+
'; + +$autorefresh_show .= $table_ichanges; + +// Time autorefresh. +$times = get_refresh_time_array(); +$time_autorefresh = '

'.__('Time autorefresh'); +$time_autorefresh .= ui_print_help_tip( + __('Interval of autorefresh of the elements, by default they are 30 seconds, needing to enable the autorefresh first'), + true +).'

'; +$time_autorefresh .= html_print_select( + $times, + 'time_autorefresh', + '', + '', + __('No change'), + '-1', + true, + false, + false +).'
'; + +$timezone = '

'.__('Timezone').ui_print_help_tip(__('The timezone must be that of the associated server.'), true).'

'; +$timezone .= html_print_timezone_select('timezone', '-1', __('No change'), '-1').'
'; +$timezone_map = ''; + +if (is_metaconsole() === false) { + 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 .= ''; + } + } + + $timezone_map = '
+ + + '.$area_data_timezone_polys.$area_data_timezone_rects.' +
'; +} + +// Status (Disable / Enable). +$status = '
'; +$status .= '

'.__('Status').'

'; + +$table = new StdClass(); +$table->width = '100%'; +$table->class = 'databox filters'; + +$table->data[0][0] = __('No change'); +$table->data[0][0] .= html_print_radio_button_extended( + 'disabled', + -1, + '', + -1, + false, + '', + 'class="mrgn_right_40px"', + true +); +$table->data[0][0] .= __('Disable'); +$table->data[0][0] .= html_print_radio_button_extended( + 'disabled', + 1, + '', + '', + false, + '', + 'class="mrgn_right_40px"', + true +); +$table->data[0][0] .= __('Enable'); +$table->data[0][0] .= html_print_radio_button_extended( + 'disabled', + 0, + '', + '', + false, + '', + 'class="mrgn_right_40px"', + true +); + +$status .= html_print_table($table, true); + +echo ''; + +attachActionButton('edit_users', 'update', '100%'); + +echo ''; + +if (is_metaconsole() === false) { + // Include OpenLayers and timezone user map library. + echo ''."\n\t"; + echo ''."\n\t"; + // Closes no meta condition. + ?> + + + + + + \ No newline at end of file diff --git a/pandora_console/godmode/massive/massive_operations.php b/pandora_console/godmode/massive/massive_operations.php index 49b151b7d4..1bc1d60e85 100755 --- a/pandora_console/godmode/massive/massive_operations.php +++ b/pandora_console/godmode/massive/massive_operations.php @@ -70,10 +70,16 @@ $options_agents = [ ]; if (check_acl($config['id_user'], 0, 'UM')) { - $options_users = [ - 'add_profiles' => __('Bulk profile add'), - 'delete_profiles' => __('Bulk profile delete'), - ]; + if (is_metaconsole() === false) { + $options_users = [ + 'add_profiles' => __('Bulk profile add'), + 'delete_profiles' => __('Bulk profile delete'), + ]; + } + + if (users_is_admin() === true) { + $options_users['edit_users'] = __('Edit users in bulk'); + } } else { $options_users = []; } @@ -479,6 +485,10 @@ switch ($option) { include_once $config['homedir'].'/godmode/massive/massive_edit_plugins.php'; break; + case 'edit_users': + include_once $config['homedir'].'/godmode/massive/massive_edit_users.php'; + break; + default: if (!enterprise_hook('massive_operations', [$option])) { include_once $config['homedir'].'/godmode/massive/massive_config.php'; diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index ef41904c38..9e0333965d 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -4735,12 +4735,12 @@ function html_print_autocomplete_modules( * * @return string HTML code */ -function html_print_timezone_select($name, $selected='') +function html_print_timezone_select($name, $selected='', $nothing='', $nothing_value='') { - $timezones_index = timezone_identifiers_list(); $timezones = timezone_identifiers_list(); - $timezones = array_combine($timezones_index, $timezones); - return html_print_select($timezones, $name, $selected, '', __('None'), '', true, false, false); + $timezones = array_combine($timezones, $timezones); + $timezones = (['' => __('none')] + $timezones); + return html_print_select($timezones, $name, $selected, '', $nothing, $nothing_value, true, false, false); }