User-defined time zone (#4906)

* User-defined time zone
#fix https://github.com/FreshRSS/FreshRSS/issues/2754

* Update app/i18n/nl/conf.php

Co-authored-by: Frans de Jonge <fransdejonge@gmail.com>

* Timezone when creating a new user

Co-authored-by: Frans de Jonge <fransdejonge@gmail.com>
This commit is contained in:
Alexandre Alapetite
2022-11-29 15:27:32 +01:00
committed by GitHub
parent 60d626030d
commit 6261dc9cf4
29 changed files with 74 additions and 2 deletions

View File

@@ -42,6 +42,7 @@ class FreshRSS_configure_Controller extends FreshRSS_ActionController {
public function displayAction() {
if (Minz_Request::isPost()) {
FreshRSS_Context::$user_conf->language = Minz_Request::param('language', 'en');
FreshRSS_Context::$user_conf->timezone = Minz_Request::param('timezone', '');
FreshRSS_Context::$user_conf->theme = Minz_Request::param('theme', FreshRSS_Themes::$defaultTheme);
FreshRSS_Context::$user_conf->content_width = Minz_Request::param('content_width', 'thin');
FreshRSS_Context::$user_conf->topline_read = Minz_Request::param('topline_read', false);

View File

@@ -344,6 +344,7 @@ class FreshRSS_user_Controller extends FreshRSS_ActionController {
$ok = self::createUser($new_user_name, $email, $passwordPlain, array(
'language' => Minz_Request::param('new_user_language', FreshRSS_Context::$user_conf->language),
'timezone' => Minz_Request::param('new_user_timezone', ''),
'is_admin' => Minz_Request::paramBoolean('new_user_is_admin'),
'enabled' => true,
));

View File

@@ -99,6 +99,9 @@ class FreshRSS extends Minz_FrontController {
Minz_Session::_param('language', $language);
Minz_Translate::init($language);
$timezone = isset(FreshRSS_Context::$user_conf) ? FreshRSS_Context::$user_conf->timezone : '';
date_default_timezone_set($timezone != '' ? $timezone : '' . ini_get('date.timezone'));
}
private static function getThemeFileUrl($theme_id, $filename) {

View File

@@ -28,6 +28,7 @@
* @property-read string $is_admin
* @property int|null $keep_history_default
* @property string $language
* @property string $timezone
* @property bool $lazyload
* @property string $mail_login
* @property bool $mark_updated_article_unread

View File

@@ -57,6 +57,7 @@ return array(
'portrait' => 'Na výšku',
'square' => 'Čtverec',
),
'timezone' => 'Time zone', // TODO
'title' => 'Zobrazení',
'width' => array(
'content' => 'Šířka obsahu',

View File

@@ -57,6 +57,7 @@ return array(
'portrait' => 'Hochformat',
'square' => 'Quadrat',
),
'timezone' => 'Time zone', // TODO
'title' => 'Anzeige',
'width' => array(
'content' => 'Inhaltsbreite',

View File

@@ -57,6 +57,7 @@ return array(
'portrait' => 'Portrait', // TODO
'square' => 'Square', // TODO
),
'timezone' => 'Time zone', // TODO
'title' => 'Display', // TODO
'width' => array(
'content' => 'Content width', // TODO

View File

@@ -57,6 +57,7 @@ return array(
'portrait' => 'Portrait', // IGNORE
'square' => 'Square', // IGNORE
),
'timezone' => 'Time zone', // IGNORE
'title' => 'Display', // IGNORE
'width' => array(
'content' => 'Content width', // IGNORE

View File

@@ -57,6 +57,7 @@ return array(
'portrait' => 'Portrait',
'square' => 'Square',
),
'timezone' => 'Time zone',
'title' => 'Display',
'width' => array(
'content' => 'Content width',

View File

@@ -57,6 +57,7 @@ return array(
'portrait' => 'Retrato',
'square' => 'Cuadrado',
),
'timezone' => 'Time zone', // TODO
'title' => 'Visualización',
'width' => array(
'content' => 'Ancho de contenido',

View File

@@ -57,6 +57,7 @@ return array(
'portrait' => 'Portrait', // IGNORE
'square' => 'Carrée',
),
'timezone' => 'Fuseau horaire',
'title' => 'Affichage',
'width' => array(
'content' => 'Largeur du contenu',

View File

@@ -57,6 +57,7 @@ return array(
'portrait' => 'Portrait', // TODO
'square' => 'Square', // TODO
),
'timezone' => 'Time zone', // TODO
'title' => 'תצוגה',
'width' => array(
'content' => 'רוחב התוכן',

View File

@@ -57,6 +57,7 @@ return array(
'portrait' => 'Portrait', // TODO
'square' => 'Square', // TODO
),
'timezone' => 'Time zone', // TODO
'title' => 'Display', // TODO
'width' => array(
'content' => 'Content width', // TODO

View File

@@ -57,6 +57,7 @@ return array(
'portrait' => 'Ritratto',
'square' => 'Squadrata',
),
'timezone' => 'Time zone', // TODO
'title' => 'Visualizzazione',
'width' => array(
'content' => 'Larghezza contenuto',

View File

@@ -57,6 +57,7 @@ return array(
'portrait' => 'ポートレート',
'square' => '四角',
),
'timezone' => 'Time zone', // TODO
'title' => 'ディスプレイ',
'width' => array(
'content' => 'コンテンツ幅',

View File

@@ -57,6 +57,7 @@ return array(
'portrait' => '세로 방향',
'square' => '정사각형',
),
'timezone' => 'Time zone', // TODO
'title' => '표시',
'width' => array(
'content' => '내용 표시 너비',

View File

@@ -57,6 +57,7 @@ return array(
'portrait' => 'Staand',
'square' => 'Vierkant',
),
'timezone' => 'Tijdzone',
'title' => 'Opmaak',
'width' => array(
'content' => 'Inhoud breedte',

View File

@@ -57,6 +57,7 @@ return array(
'portrait' => 'Retrach',
'square' => 'Carrat',
),
'timezone' => 'Time zone', // TODO
'title' => 'Afichatge',
'width' => array(
'content' => 'Largor del contengut',

View File

@@ -57,6 +57,7 @@ return array(
'portrait' => 'Portret',
'square' => 'Kwadrat',
),
'timezone' => 'Time zone', // TODO
'title' => 'Wyświetlanie',
'width' => array(
'content' => 'Rozmiar treści',

View File

@@ -57,6 +57,7 @@ return array(
'portrait' => 'Modo retrato',
'square' => 'Modo quadrado',
),
'timezone' => 'Time zone', // TODO
'title' => 'Exibição',
'width' => array(
'content' => 'Largura do conteúdo',

View File

@@ -57,6 +57,7 @@ return array(
'portrait' => 'Вертикальный',
'square' => 'Квадратный',
),
'timezone' => 'Time zone', // TODO
'title' => 'Отображение',
'width' => array(
'content' => 'Ширина содержимого',

View File

@@ -57,6 +57,7 @@ return array(
'portrait' => 'Nastojato',
'square' => 'Štvorec',
),
'timezone' => 'Time zone', // TODO
'title' => 'Zobraziť',
'width' => array(
'content' => 'Šírka obsahu',

View File

@@ -57,6 +57,7 @@ return array(
'portrait' => 'Portre',
'square' => 'Kare',
),
'timezone' => 'Time zone', // TODO
'title' => 'Görünüm',
'width' => array(
'content' => 'İçerik genişliği',

View File

@@ -57,6 +57,7 @@ return array(
'portrait' => '纵向',
'square' => '方形',
),
'timezone' => 'Time zone', // TODO
'title' => '显示',
'width' => array(
'content' => '内容宽度',

View File

@@ -57,6 +57,7 @@ return array(
'portrait' => '肖像',
'square' => '方塊',
),
'timezone' => 'Time zone', // TODO
'title' => '顯示',
'width' => array(
'content' => '內容寬度',

View File

@@ -15,6 +15,18 @@
</select>
</div>
<div class="form-group">
<label for="new_user_timezone"><?= _t('conf.display.timezone') ?></label>
<select name="new_user_timezone" id="new_user_timezone">
<?php $timezones = array_merge([''], DateTimeZone::listIdentifiers()); ?>
<?php foreach ($timezones as $timezone): ?>
<option value="<?= $timezone ?>"<?= $timezone === '' ? ' selected="selected"' : '' ?>>
<?= $timezone == '' ? _t('gen.short.by_default') . ' (' . ini_get('date.timezone') . ')' : $timezone ?>
</option>
<?php endforeach; ?>
</select>
</div>
<div class="form-group">
<label for="new_user_name"><?= _t('gen.auth.username') ?></label>
<input id="new_user_name" name="new_user_name" type="text" size="16" required="required" autocomplete="off"

View File

@@ -25,6 +25,25 @@
</div>
</div>
<div class="form-group">
<label class="group-name" for="language"><?= _t('conf.display.timezone') ?></label>
<div class="group-controls">
<select name="timezone" id="timezone" data-leave-validation="<?= FreshRSS_Context::$user_conf->timezone ?>">
<?php
$timezones = array_merge([''], DateTimeZone::listIdentifiers());
if (!in_array(FreshRSS_Context::$user_conf->timezone, $timezones, true)) {
FreshRSS_Context::$user_conf->timezone = '';
}
?>
<?php foreach ($timezones as $timezone): ?>
<option value="<?= $timezone ?>"<?= FreshRSS_Context::$user_conf->timezone === $timezone ? ' selected="selected"' : '' ?>>
<?= $timezone == '' ? _t('gen.short.by_default') . ' (' . ini_get('date.timezone') . ')' : $timezone ?>
</option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="form-group">
<label class="group-name" for="theme"><?= _t('conf.display.theme') ?></label>
<div class="group-controls">

View File

@@ -15,8 +15,6 @@
<input type="hidden" name="originController" value="<?= Minz_Request::controllerName() ?>" />
<input type="hidden" name="originAction" value="<?= Minz_Request::actionName() ?>" />
<div class="form-group">
<label class="group-name" for="new_user_language"><?= _t('admin.user.language') ?></label>
<div class="group-controls">
@@ -30,6 +28,20 @@
</div>
</div>
<div class="form-group">
<label class="group-name" for="new_user_timezone"><?= _t('conf.display.timezone') ?></label>
<div class="group-controls">
<select name="new_user_timezone" id="new_user_timezone">
<?php $timezones = array_merge([''], DateTimeZone::listIdentifiers()); ?>
<?php foreach ($timezones as $timezone): ?>
<option value="<?= $timezone ?>"<?= $timezone === '' ? ' selected="selected"' : '' ?>>
<?= $timezone == '' ? _t('gen.short.by_default') . ' (' . ini_get('date.timezone') . ')' : $timezone ?>
</option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="form-group">
<label class="group-name" for="new_user_name"><?= _t('admin.user.username') ?></label>
<div class="group-controls">

View File

@@ -7,6 +7,8 @@ return array (
'enabled' => true,
'is_admin' => false,
'language' => 'en',
// A timezone identifier such as 'Europe/Paris' https://php.net/timezones or blank for server default
'timezone' => '',
'archiving' => [
'keep_period' => 'P3M',
'keep_max' => 200,