diff --git a/pandora_console/godmode/users/configure_profile.php b/pandora_console/godmode/users/configure_profile.php index 4cddff8932..82af2e5e8e 100644 --- a/pandora_console/godmode/users/configure_profile.php +++ b/pandora_console/godmode/users/configure_profile.php @@ -39,12 +39,13 @@ if (! check_acl($config['id_user'], 0, 'UM')) { } enterprise_include_once('meta/include/functions_users_meta.php'); - -$tab = get_parameter('tab', 'profile'); -$pure = get_parameter('pure', 0); - +// Get parameters. +$tab = get_parameter('tab', 'profile'); +$pure = get_parameter('pure', 0); +$new_profile = (bool) get_parameter('new_profile'); +$id_profile = (int) get_parameter('id'); // Header. -if (!is_metaconsole()) { +if (is_metaconsole() === false) { $buttons = [ 'user' => [ 'active' => false, @@ -72,13 +73,29 @@ if (!is_metaconsole()) { $buttons[$tab]['active'] = true; - ui_print_page_header( - __('User management').' » '.__('Profiles defined on %s', get_product_name()), + $profile = db_get_row('tperfil', 'id_perfil', $id_profile); + + ui_print_standard_header( + __('Edit profile %s', $profile['name']), 'images/gm_users.png', false, 'configure_profiles_tab', true, - $buttons + $buttons, + [ + [ + 'link' => '', + 'label' => __('Profiles'), + ], + [ + 'link' => '', + 'label' => __('Manage users'), + ], + [ + 'link' => ui_get_full_url('index.php?sec=gusuarios&sec2=godmode/users/profile_list&tab=profile'), + 'label' => __('User Profile management'), + ], + ] ); $sec2 = 'gusuarios'; } else { @@ -86,10 +103,6 @@ if (!is_metaconsole()) { $sec2 = 'advanced'; } - -$new_profile = (bool) get_parameter('new_profile'); -$id_profile = (int) get_parameter('id'); - // Edit profile. if ($id_profile || $new_profile) { if ($new_profile) { diff --git a/pandora_console/godmode/users/configure_user.php b/pandora_console/godmode/users/configure_user.php index 865ab8eb9d..fdfcfd1b3c 100644 --- a/pandora_console/godmode/users/configure_user.php +++ b/pandora_console/godmode/users/configure_user.php @@ -54,71 +54,27 @@ if ($enterprise_include === true) { enterprise_include_once('meta/include/functions_users_meta.php'); } -if (is_metaconsole() === false) { - 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', '')); +// Check if we are the same user for edit or we have a proper profile for edit users. +if ($id !== $config['id_user']) { + if ((bool) check_acl($config['id_user'], 0, 'UM') === false) { + db_pandora_audit( + AUDIT_LOG_ACL_VIOLATION, + 'Trying to access User Management' + ); + include 'general/noaccess.php'; + + return; + } +} + // ID given as parameter. $pure = get_parameter('pure', 0); - $user_info = get_user_info($id); $is_err = false; -if ((bool) check_acl($config['id_user'], 0, 'UM') === false) { - db_pandora_audit( - AUDIT_LOG_ACL_VIOLATION, - 'Trying to access User Management' - ); - include 'general/noaccess.php'; - - return; -} - if (is_ajax() === true) { $delete_profile = (bool) get_parameter('delete_profile'); $get_user_profile = (bool) get_parameter('get_user_profile'); @@ -270,7 +226,7 @@ enterprise_hook('open_meta_frame'); $tab = get_parameter('tab', 'user'); // Save autorefresh list. -$autorefresh_list = get_parameter_post('autorefresh_list'); +$autorefresh_list = (array) get_parameter_post('autorefresh_list'); $autorefresh_white_list = (($autorefresh_list[0] === '') || ($autorefresh_list[0] === '0')) ? '' : json_encode($autorefresh_list); // Header. @@ -338,6 +294,7 @@ if ((bool) $config['user_can_update_info'] === true) { $view_mode = true; } +$delete_profile = (is_ajax() === true) ? (bool) get_parameter('delete_profile') : false; $new_user = (bool) get_parameter('new_user'); $create_user = (bool) get_parameter('create_user'); $add_profile = (bool) get_parameter('add_profile'); @@ -564,6 +521,7 @@ if ($create_user === true) { $info ); + HD('patatas', true); ui_print_result_message( $result, __('Successfully created'), @@ -1002,7 +960,7 @@ if ($add_profile && empty($json_profile)) { ); } -if ($values) { +if (isset($values) === true && empty($values) === false) { $user_info = $values; } @@ -1530,7 +1488,7 @@ $default_event_filter .= html_print_select( false ).''; -if ($config['ehorus_user_level_conf']) { +if (isset($config['ehorus_user_level_conf']) === true && (bool) $config['ehorus_user_level_conf'] === true) { $ehorus = '

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

'; $ehorus .= html_print_checkbox_switch( 'ehorus_user_level_enabled', @@ -1562,7 +1520,7 @@ if ($config['ehorus_user_level_conf']) { $double_auth_enabled = (bool) db_get_value('id', 'tuser_double_auth', 'id_user', $id); -if ($config['double_auth_enabled'] && check_acl($config['id_user'], 0, 'PM')) { +if (isset($config['double_auth_enabled']) === true && (bool) ($config['double_auth_enabled']) === true && check_acl($config['id_user'], 0, 'PM')) { $double_authentication = '

'.__('Double authentication').'

'; if (($config['2FA_all_users'] == '' && !$double_auth_enabled) || ($config['double_auth_enabled'] == '' && $double_auth_enabled) @@ -1678,14 +1636,10 @@ if (is_metaconsole() === true) { ).'
'; } + +echo '
'; echo '
'; - -require_once 'user_management.php'; - - - - if (!$id) { $user_id_update_view = $user_id; $user_id_create = ''; @@ -1696,138 +1650,138 @@ if (!$id) { if (is_metaconsole() === true) { $access_or_pagination = $meta_access; + if ($id != '' && !$is_err) { + $div_user_info = ' + '; + } else { + $div_user_info = ' + '; + } + + echo '
+
+ +

Extra info

'.$email.$phone.$not_login.$local_user.$session_time.'
+
+
+
'.$language.$access_or_pagination.$skin.$default_event_filter.$double_authentication.'
+ +
'.$timezone; + + echo $search_custom_fields_view.$metaconsole_agents_manager.$metaconsole_access_node; + + $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%' + ); + $arrows = ' '; + $select_in = html_print_select( + $autorefresh_list, + 'autorefresh_list[]', + '', + '', + '', + '', + true, + true, + true, + '', + false, + 'width:100%' + ); + + $table_ichanges = ''; + + $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', + $user_info['time_autorefresh'], + '', + '', + '', + true, + false, + false + ).'
'; + + + echo '
+
+
'.$autorefresh_show.$time_autorefresh.'
+
+
'.$comments.'
+
'; + + if (empty($ehorus) === false) { + html_print_div( + [ + 'class' => 'user_edit_third_row white_box', + 'content' => $ehorus, + ], + true + ); + } } else { $access_or_pagination = $size_pagination; -} - -if ($id != '' && !$is_err) { - $div_user_info = ' - '; -} else { - $div_user_info = ' - '; -} - -echo '
-
- -

Extra info

'.$email.$phone.$not_login.$local_user.$session_time.'
-
-
-
'.$language.$access_or_pagination.$skin.$default_event_filter.$double_authentication.'
- -
'.$timezone; -if (is_metaconsole() === false) { - echo '
- - - '.$area_data_timezone_polys.$area_data_timezone_rects.' -
'; -} else { - echo $search_custom_fields_view.$metaconsole_agents_manager.$metaconsole_access_node; -} - -$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%' -); -$arrows = ' '; -$select_in = html_print_select( - $autorefresh_list, - 'autorefresh_list[]', - '', - '', - '', - '', - true, - true, - true, - '', - false, - 'width:100%' -); - -$table_ichanges = ''; - -$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', - $user_info['time_autorefresh'], - '', - '', - '', - true, - false, - false -).'
'; - - -echo '
-
-
'.$autorefresh_show.$time_autorefresh.'
-
-
'.$comments.'
-
'; - -if (!empty($ehorus)) { - echo '
'.$ehorus.'
'; + // WIP: Only for node. + include_once 'user_management.php'; } echo '
'; -if ($config['admin_can_add_user']) { +if ((bool) $config['admin_can_add_user'] === true) { html_print_csrf_hidden(); html_print_input_hidden((($new_user === true) ? 'create_user' : 'update_user'), 1); } @@ -1837,8 +1791,8 @@ if ($new_user === true) { html_print_input_hidden('json_profile', $json_profile); } - echo ''; +echo '
'; $actionButtons = []; @@ -1873,10 +1827,11 @@ $actionButtons[] = html_print_go_back_button( html_print_action_buttons(implode('', $actionButtons), ['type' => 'form_action']); - echo '
'; enterprise_hook('close_meta_frame'); + +// This is an image generated for JS. $delete_image = html_print_input_image( 'del', 'images/cross.png', @@ -1889,7 +1844,7 @@ $delete_image = html_print_input_image( ] ); -if (!is_metaconsole()) { +if (is_metaconsole() === false) { ?>