mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-08 04:18:52 +00:00
[ticket/14404] Set board & admin timezone based on browser timezone
PHPBB-14404
This commit is contained in:
parent
ae8a5e791e
commit
36de1a49b1
4 changed files with 24 additions and 1 deletions
|
@ -605,6 +605,8 @@
|
||||||
function interceptFormSubmit($form) {
|
function interceptFormSubmit($form) {
|
||||||
if (!$form.length) {
|
if (!$form.length) {
|
||||||
return;
|
return;
|
||||||
|
} else if ($form.find('input[name="admin_name"]').length > 0) {
|
||||||
|
setAdminTimezone($form);
|
||||||
}
|
}
|
||||||
|
|
||||||
$form.find(':submit').bind('click', function (event) {
|
$form.find(':submit').bind('click', function (event) {
|
||||||
|
@ -612,4 +614,20 @@
|
||||||
submitForm($form, $(this));
|
submitForm($form, $(this));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set admin timezone in form
|
||||||
|
*
|
||||||
|
* @param $form
|
||||||
|
*/
|
||||||
|
function setAdminTimezone($form) {
|
||||||
|
// Set admin timezone if it does not exist yet
|
||||||
|
if ($form.find('input[name="admin_timezone"]').length === 0) {
|
||||||
|
const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
||||||
|
|
||||||
|
// Add timezone as form entry
|
||||||
|
const timezoneEntry = $('<input type="hidden" name="admin_timezone" value="' + timeZone + '">');
|
||||||
|
$form.append(timezoneEntry);
|
||||||
|
}
|
||||||
|
}
|
||||||
})(jQuery); // Avoid conflicts with other libraries
|
})(jQuery); // Avoid conflicts with other libraries
|
||||||
|
|
|
@ -132,6 +132,7 @@ class add_config_settings extends database_task
|
||||||
|
|
||||||
$updates = [
|
$updates = [
|
||||||
'board_startdate' => (string) $current_time,
|
'board_startdate' => (string) $current_time,
|
||||||
|
'board_timezone' => $this->install_config->get('admin_timezone'),
|
||||||
'default_lang' => $this->install_config->get('default_lang'),
|
'default_lang' => $this->install_config->get('default_lang'),
|
||||||
|
|
||||||
'server_name' => $this->install_config->get('server_name'),
|
'server_name' => $this->install_config->get('server_name'),
|
||||||
|
|
|
@ -114,7 +114,8 @@ class update_user_and_post_data extends database_task
|
||||||
. ' user_lang = :lang,'
|
. ' user_lang = :lang,'
|
||||||
. ' user_email = :email,'
|
. ' user_email = :email,'
|
||||||
. ' user_dateformat = :dateformat,'
|
. ' user_dateformat = :dateformat,'
|
||||||
. ' username_clean = :clean_username'
|
. ' username_clean = :clean_username,'
|
||||||
|
. ' user_timezone = :timezone'
|
||||||
. ' WHERE username = \'Admin\'';
|
. ' WHERE username = \'Admin\'';
|
||||||
|
|
||||||
$this->create_and_execute_prepared_stmt($sql, [
|
$this->create_and_execute_prepared_stmt($sql, [
|
||||||
|
@ -125,6 +126,7 @@ class update_user_and_post_data extends database_task
|
||||||
'email' => $this->install_config->get('board_email'),
|
'email' => $this->install_config->get('board_email'),
|
||||||
'dateformat' => $this->language->lang('default_dateformat'),
|
'dateformat' => $this->language->lang('default_dateformat'),
|
||||||
'clean_username' => utf8_clean_string($this->install_config->get('admin_name')),
|
'clean_username' => utf8_clean_string($this->install_config->get('admin_name')),
|
||||||
|
'timezone' => $this->install_config->get('admin_timezone'),
|
||||||
]);
|
]);
|
||||||
$this->exec_sql('UPDATE ' . $this->user_table . ' SET user_regdate = ' . $current_time);
|
$this->exec_sql('UPDATE ' . $this->user_table . ' SET user_regdate = ' . $current_time);
|
||||||
|
|
||||||
|
|
|
@ -71,6 +71,7 @@ class obtain_admin_data extends \phpbb\install\task_base implements \phpbb\insta
|
||||||
$admin_pass1 = $this->io_handler->get_input('admin_pass1', '', true);
|
$admin_pass1 = $this->io_handler->get_input('admin_pass1', '', true);
|
||||||
$admin_pass2 = $this->io_handler->get_input('admin_pass2', '', true);
|
$admin_pass2 = $this->io_handler->get_input('admin_pass2', '', true);
|
||||||
$board_email = $this->io_handler->get_input('board_email', '', true);
|
$board_email = $this->io_handler->get_input('board_email', '', true);
|
||||||
|
$admin_timezone = $this->io_handler->get_input('admin_timezone', 'UTC', true);
|
||||||
|
|
||||||
$admin_data_valid = $this->check_admin_data($admin_name, $admin_pass1, $admin_pass2, $board_email);
|
$admin_data_valid = $this->check_admin_data($admin_name, $admin_pass1, $admin_pass2, $board_email);
|
||||||
|
|
||||||
|
@ -79,6 +80,7 @@ class obtain_admin_data extends \phpbb\install\task_base implements \phpbb\insta
|
||||||
$this->install_config->set('admin_name', $admin_name);
|
$this->install_config->set('admin_name', $admin_name);
|
||||||
$this->install_config->set('admin_passwd', $admin_pass1);
|
$this->install_config->set('admin_passwd', $admin_pass1);
|
||||||
$this->install_config->set('board_email', $board_email);
|
$this->install_config->set('board_email', $board_email);
|
||||||
|
$this->install_config->set('admin_timezone', $admin_timezone);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue