#9529 timezone visual for new users

This commit is contained in:
Jonathan 2023-02-01 16:57:48 +01:00
parent 997a8d5434
commit 181b172ba8
5 changed files with 84 additions and 7 deletions

View File

@ -276,7 +276,7 @@ foreach ($timezones as $timezone) {
} }
} }
$table->data[$i][0] = __('Timezone setup'); $table->data[$i][0] = __('Server Timezone setup');
$table->data[$i][1] = html_print_input_text_extended( $table->data[$i][1] = html_print_input_text_extended(
'timezone_text', 'timezone_text',
$config['timezone'], $config['timezone'],

View File

@ -393,6 +393,10 @@ function process_user_login_remote($login, $pass, $api=false)
$user_info['metaconsole_access_node'] = $config['ldap_adv_user_node']; $user_info['metaconsole_access_node'] = $config['ldap_adv_user_node'];
} }
if (isset($config['timezonevisual']) === true) {
$user_info['timezone'] = $config['timezonevisual'];
}
$permissions = fill_permissions_ldap($sr); $permissions = fill_permissions_ldap($sr);
if (empty($permissions) === true) { if (empty($permissions) === true) {
$config['auth_error'] = __('User not found in database or incorrect password'); $config['auth_error'] = __('User not found in database or incorrect password');

View File

@ -561,6 +561,10 @@ function config_update_config()
$error_update[] = __('Automatically assigned no hierarchy'); $error_update[] = __('Automatically assigned no hierarchy');
} }
if (config_update_value('timezonevisual', (string) get_parameter('timezonevisual'), true) === false) {
$error_update[] = __('Automatically timezone visual');
}
if (config_update_value('autocreate_blacklist', get_parameter('autocreate_blacklist'), true) === false) { if (config_update_value('autocreate_blacklist', get_parameter('autocreate_blacklist'), true) === false) {
$error_update[] = __('Autocreate blacklist'); $error_update[] = __('Autocreate blacklist');
} }

View File

@ -4235,12 +4235,53 @@ function events_page_details($event, $server_id=0)
$data = []; $data = [];
$data[0] = '<div class="normal_weight mrgn_lft_20px">'.__('Last contact').'</div>'; $data[0] = '<div class="normal_weight mrgn_lft_20px">'.__('Last contact').'</div>';
$data[1] = ($agent['ultimo_contacto'] == '1970-01-01 00:00:00') ? '<i>'.__('N/A').'</i>' : ui_print_timestamp($agent['ultimo_contacto'], true);
$user_timezone = users_get_user_by_id($_SESSION['id_usuario'])['timezone'];
if (!$user_timezone) {
$timezone = timezone_open(date_default_timezone_get());
$datetime_eur = date_create('now', timezone_open($config['timezone']));
$dif = timezone_offset_get($timezone, $datetime_eur);
date($config['date_format'], $dif);
if (!date('I')) {
// For summer -3600sec.
$dif -= 3600;
}
$total_sec = strtotime($agent['ultimo_contacto']);
$total_sec += $dif;
$last_contact = date($config['date_format'], $total_sec);
$last_contact_value = ui_print_timestamp($last_contact, true);
} else {
$user_timezone = users_get_user_by_id($_SESSION['id_usuario'])['timezone'];
date_default_timezone_set($user_timezone);
$last_contact_value = human_time_comparation(strtotime($agent['ultimo_contacto']), 'large');
}
$data[1] = ($agent['ultimo_contacto'] == '1970-01-01 00:00:00') ? '<i>'.__('N/A').'</i>' : $last_contact_value;
$table_details->data[] = $data; $table_details->data[] = $data;
$user_timezone = users_get_user_by_id($_SESSION['id_usuario'])['timezone'];
if (!$user_timezone) {
$timezone = timezone_open(date_default_timezone_get());
$datetime_eur = date_create('now', timezone_open($config['timezone']));
$dif = timezone_offset_get($timezone, $datetime_eur);
date($config['date_format'], $dif);
if (!date('I')) {
// For summer -3600sec.
$dif -= 3600;
}
$total_sec = strtotime($agent['ultimo_contacto_remoto']);
$total_sec += $dif;
$lr_contact = date($config['date_format'], $total_sec);
} else {
$lr_contact = date($config['date_format'], strtotime($agent['ultimo_contacto_remoto']));
}
$data = []; $data = [];
$data[0] = '<div class="normal_weight mrgn_lft_20px">'.__('Last remote contact').'</div>'; $data[0] = '<div class="normal_weight mrgn_lft_20px">'.__('Last remote contact').'</div>';
$data[1] = ($agent['ultimo_contacto_remoto'] == '1970-01-01 00:00:00') ? '<i>'.__('N/A').'</i>' : date_w_fixed_tz($agent['ultimo_contacto_remoto']); $data[1] = ($agent['ultimo_contacto_remoto'] == '1970-01-01 00:00:00') ? '<i>'.__('N/A').'</i>' : $lr_contact;
$table_details->data[] = $data; $table_details->data[] = $data;
$data = []; $data = [];
@ -4729,6 +4770,13 @@ function events_page_general($event)
$data[1] .= __('Last event').': '; $data[1] .= __('Last event').': ';
$data[1] .= date($config['date_format'], $event['timestamp_last']); $data[1] .= date($config['date_format'], $event['timestamp_last']);
} else { } else {
$user_timezone = users_get_user_by_id($_SESSION['id_usuario'])['timezone'];
if ($user_timezone) {
date_default_timezone_set($user_timezone);
} else {
date_default_timezone_set($config['timezone']);
}
$data[1] = date($config['date_format'], $event['utimestamp']); $data[1] = date($config['date_format'], $event['utimestamp']);
} }

View File

@ -527,10 +527,31 @@ if (is_ajax() === true) {
(empty($tmp->ack_utimestamp) === true) ? 0 : $tmp->ack_utimestamp, (empty($tmp->ack_utimestamp) === true) ? 0 : $tmp->ack_utimestamp,
true true
); );
$tmp->timestamp = ui_print_timestamp(
$tmp->timestamp, $user_timezone = users_get_user_by_id($_SESSION['id_usuario'])['timezone'];
true if (!$user_timezone) {
); $timezone = timezone_open(date_default_timezone_get());
$datetime_eur = date_create('now', timezone_open($config['timezone']));
$dif = timezone_offset_get($timezone, $datetime_eur);
date($config['date_format'], $dif);
if (!date('I')) {
// For summer -3600sec.
$dif -= 3600;
}
$total_sec = strtotime($tmp->timestamp);
$total_sec += $dif;
$last_contact = date($config['date_format'], $total_sec);
$last_contact_value = ui_print_timestamp($last_contact, true);
} else {
$user_timezone = users_get_user_by_id($_SESSION['id_usuario'])['timezone'];
date_default_timezone_set($user_timezone);
$title = date($config['date_format'], strtotime($tmp->timestamp));
$value = human_time_comparation(strtotime($tmp->timestamp), 'large');
$last_contact_value = '<span title="'.$title.'">'.$value.'</span>';
}
$tmp->timestamp = $last_contact_value;
if (is_numeric($tmp->data) === true) { if (is_numeric($tmp->data) === true) {
$tmp->data = format_numeric( $tmp->data = format_numeric(