mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-22 06:30:59 +01:00
first step for real timezones in EGroupware
This commit is contained in:
parent
1353ae511a
commit
610b629325
@ -204,6 +204,8 @@ class egw extends egw_minimal
|
||||
// init the translation class, necessary as own wakeup would run before our's
|
||||
translation::init();
|
||||
|
||||
$this->unset_datetime();
|
||||
|
||||
// verify the session
|
||||
$GLOBALS['egw']->verify_session();
|
||||
$GLOBALS['egw']->check_app_rights();
|
||||
@ -211,6 +213,14 @@ class egw extends egw_minimal
|
||||
$this->load_optional_classes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsetting datetime object, so time gets updated
|
||||
*/
|
||||
function unset_datetime()
|
||||
{
|
||||
unset($this->datetime);
|
||||
}
|
||||
|
||||
/**
|
||||
* load optional classes by mentioning them in egw_info[flags][enable_CLASS_class] => true
|
||||
*
|
||||
|
@ -315,9 +315,34 @@ class preferences
|
||||
echo 'default<pre>'; print_r($this->default); echo "</pre>\n";
|
||||
echo 'effectiv<pre>'; print_r($this->data); echo "</pre>\n";
|
||||
}
|
||||
$this->check_set_tz_offset();
|
||||
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checking new timezoen ('tz') pref and setting old tz_offset pref from it
|
||||
*
|
||||
*/
|
||||
function check_set_tz_offset()
|
||||
{
|
||||
$prefs =& $this->data['common'];
|
||||
|
||||
if (isset($prefs['tz']))
|
||||
{
|
||||
$GLOBALS['egw']->datetimezone = new DateTimeZone($prefs['tz']);
|
||||
$server_offset = date('Z');
|
||||
$GLOBALS['egw']->datetime_now = new DateTime('now',$GLOBALS['egw']->datetimezone);
|
||||
$utc_offset = $GLOBALS['egw']->datetime_now->getOffset();
|
||||
$user_now = $GLOBALS['egw']->datetime_now->format('Y-m-d H:i:s e (T)');
|
||||
$GLOBALS['egw_info']['user']['preferences']['common']['tz_offset'] = $prefs['tz_offset'] = ($utc_offset - $server_offset)/3600;
|
||||
|
||||
//echo "<p>".__METHOD__."() tz='{$prefs['tz']}'=$utc_offset=$user_now, server=date('Z')=$server_offset --> $prefs[tz_offset]</p>\n";
|
||||
|
||||
$GLOBALS['egw']->unset_datetime(); // to force an update
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* read preferences from repository and stores in an array
|
||||
*
|
||||
|
@ -1,15 +1,12 @@
|
||||
<?php
|
||||
/**************************************************************************\
|
||||
* eGroupWare - Preferences *
|
||||
* http://www.egroupware.org *
|
||||
* -------------------------------------------- *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms of the GNU General Public License as published by the *
|
||||
* Free Software Foundation; either version 2 of the License, or (at your *
|
||||
* option) any later version. *
|
||||
\**************************************************************************/
|
||||
|
||||
/* $Id$ */
|
||||
/**
|
||||
* EGroupware - Preferences
|
||||
*
|
||||
* @link http://www.egroupware.org
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package preferences
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
/* Setup some values to fill the array of this app's settings below */
|
||||
$templates = $GLOBALS['egw']->common->list_templates();
|
||||
@ -46,13 +43,52 @@
|
||||
{
|
||||
$format .= 'H:i';
|
||||
}
|
||||
/*
|
||||
for($i = -23.5; $i < 24.0; $i += 0.5)
|
||||
{
|
||||
$t = time() + round($i * 3600);
|
||||
$tz_offset[(string)$i] = sprintf('%3.1lf',$i) . ' ' . lang('hours').': ' . date($format,$t);
|
||||
}
|
||||
*/
|
||||
// prepare list of timezones from php, ignoring depricated ones and sort as follows
|
||||
$tzs = array(
|
||||
'Africa' => array(), // Contients
|
||||
'America' => array(),
|
||||
'Asia' => array(),
|
||||
'Australia' => array(),
|
||||
'Europe' => array(),
|
||||
'Atlantic' => array(), // Oceans
|
||||
'Pacific' => array(),
|
||||
'Indian' => array(),
|
||||
'Antarctica' => array(), // Poles
|
||||
'Arctic' => array(),
|
||||
'UTC' => array('UTC' => 'UTC'),
|
||||
);
|
||||
foreach(DateTimeZone::listIdentifiers() as $name)
|
||||
{
|
||||
list($continent,$rest) = explode('/',$name,2);
|
||||
if (!isset($tzs[$continent])) continue; // old depricated timezones
|
||||
$datetime = new DateTime('now',new DateTimeZone($name));
|
||||
$tzs[$continent][$name] = str_replace(array('_','/'),array(' ',' / '),$name).' '.$datetime->format($format);
|
||||
unset($datetime);
|
||||
}
|
||||
foreach($tzs as $continent => &$data)
|
||||
{
|
||||
natcasesort($data); // sort cities
|
||||
}
|
||||
unset($data);
|
||||
|
||||
// if user lang or installed langs contain a european language --> move Europe to top of tz list
|
||||
$langs = $GLOBALS['egw']->translation->get_installed_langs();
|
||||
if (array_intersect(array($GLOBALS['egw_info']['user']['preferences']['common']['lang'])+array_keys($langs),
|
||||
array('de','fr','it','nl','bg','ca','cs','da','el','es-es','et','eu','fi','hr','hu','lt','no','pl','pt','sk','sl','sv','tr','uk')))
|
||||
{
|
||||
$tzs = array_merge(array('Europe' => $tzs['Europe']),$tzs);
|
||||
}
|
||||
|
||||
$date_formats = array(
|
||||
'd.m.Y' => 'd.m.Y',
|
||||
'Y-m-d' => 'Y-m-d',
|
||||
'm/d/Y' => 'm/d/Y',
|
||||
'm-d-Y' => 'm-d-Y',
|
||||
'm.d.Y' => 'm.d.Y',
|
||||
@ -60,11 +96,9 @@
|
||||
'Y-d-m' => 'Y-d-m',
|
||||
'Y.d.m' => 'Y.d.m',
|
||||
'Y/m/d' => 'Y/m/d',
|
||||
'Y-m-d' => 'Y-m-d',
|
||||
'Y.m.d' => 'Y.m.d',
|
||||
'd/m/Y' => 'd/m/Y',
|
||||
'd-m-Y' => 'd-m-Y',
|
||||
'd.m.Y' => 'd.m.Y',
|
||||
'd-M-Y' => 'd-M-Y'
|
||||
);
|
||||
|
||||
@ -85,8 +119,6 @@
|
||||
'silver' => lang ('Silver theme')
|
||||
);
|
||||
|
||||
$langs = $GLOBALS['egw']->translation->get_installed_langs();
|
||||
|
||||
$user_apps = array();
|
||||
foreach($GLOBALS['egw_info']['user']['apps'] as $app => $data)
|
||||
{
|
||||
@ -111,7 +143,8 @@
|
||||
'firstall' => lang('Firstname').' '.lang('Lastname').' ['.lang('username').']',
|
||||
'lastall' => lang('Lastname').', '.lang('Firstname').' ['.lang('username').']',
|
||||
'allfirst' => '['.lang('username').'] '.lang('Firstname'). ' '.lang('Lastname'),
|
||||
'all' => '['.lang('username').'] '.lang('Lastname').', '.lang('Firstname')
|
||||
'all' => '['.lang('username').'] '.lang('Lastname').',
|
||||
'.lang('Firstname'),
|
||||
);
|
||||
|
||||
/* Settings array for this app */
|
||||
@ -173,6 +206,7 @@
|
||||
'xmlrpc' => True,
|
||||
'admin' => False
|
||||
),
|
||||
/*
|
||||
'tz_offset' => array(
|
||||
'type' => 'select',
|
||||
'label' => 'Time zone offset',
|
||||
@ -182,6 +216,16 @@
|
||||
'xmlrpc' => True,
|
||||
'admin' => False
|
||||
),
|
||||
*/
|
||||
'tz' => array(
|
||||
'type' => 'select',
|
||||
'label' => 'Time zone',
|
||||
'name' => 'tz',
|
||||
'values' => $tzs,
|
||||
'help' => 'Please select your timezone.',
|
||||
'xmlrpc' => True,
|
||||
'admin' => False
|
||||
),
|
||||
'dateformat' => array(
|
||||
'type' => 'select',
|
||||
'label' => 'Date format',
|
||||
|
Loading…
Reference in New Issue
Block a user