Merge branch 'ent-9529-14208-definir-timezone-por-defecto-para-nuevos-usuarios' into 'develop', JJOS.

Draft: Ent 9529 14208 definir timezone por defecto para nuevos usuarios

See merge request artica/pandorafms!5492
This commit is contained in:
Jimmy Olano 2023-03-29 02:28:47 +00:00
commit 5044c23ef3
4 changed files with 83 additions and 6 deletions

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'];
}
if (isset($config['timezonevisual']) === true) {
$user_info['timezone'] = $config['timezonevisual'];
}
$permissions = fill_permissions_ldap($sr);
if (empty($permissions) === true) {
$config['auth_error'] = __('User not found in database or incorrect password');

View File

@ -579,6 +579,10 @@ function config_update_config()
$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) {
$error_update[] = __('Autocreate blacklist');
}

View File

@ -4387,12 +4387,53 @@ function events_page_details($event, $server_id=0)
$data = [];
$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;
$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[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;
$data = [];
@ -4879,6 +4920,13 @@ function events_page_general($event)
$data[1] .= __('Last event').': ';
$data[1] .= date($config['date_format'], $event['timestamp_last']);
} 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']);
}

View File

@ -536,10 +536,31 @@ if (is_ajax() === true) {
(empty($tmp->ack_utimestamp) === true) ? 0 : $tmp->ack_utimestamp,
true
);
$tmp->timestamp = ui_print_timestamp(
$tmp->utimestamp,
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($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) {
$tmp->data = format_numeric(