* Calendar/CalDAV: fixed wrong time in notification mails caused by updates via CalDAV (not web interface), if user-timezone differs from server

This commit is contained in:
Ralf Becker 2013-01-31 15:15:48 +00:00
parent 9d142fec14
commit a8e6f13304
2 changed files with 15 additions and 1 deletions

View File

@ -625,7 +625,7 @@ class calendar_boupdate extends calendar_bo
*/
function send_update($msg_type,$to_notify,$old_event,$new_event=null,$user=0)
{
//error_log(__METHOD__."($msg_type,".array2string($to_notify).",...)");
//error_log(__METHOD__."($msg_type,".array2string($to_notify).",...) ".array2string($new_event));
if (!is_array($to_notify))
{
$to_notify = array();
@ -644,6 +644,12 @@ class calendar_boupdate extends calendar_bo
{
return False;
}
// check if default timezone is set correctly to server-timezone (ical-parser messes with it!!!)
if ($GLOBALS['egw_info']['server']['server_timezone'] && ($tz = date_default_timezone_get()) != $GLOBALS['egw_info']['server']['server_timezone'])
{
$restore_tz = $tz;
date_default_timezone_set($GLOBALS['egw_info']['server']['server_timezone']);
}
$temp_user = $GLOBALS['egw_info']['user']; // save user-date of the enviroment to restore it after
if (!$user)
@ -745,6 +751,7 @@ class calendar_boupdate extends calendar_bo
$enddate = new egw_time($event['end']);
$modified = new egw_time($event['modified']);
if ($old_event) $olddate = new egw_time($old_event['start']);
//error_log(__METHOD__."() date_default_timezone_get()=".date_default_timezone_get().", user-timezone=".egw_time::$user_timezone->getName().", startdate=".$startdate->format().", enddate=".$enddate->format().", updated=".$modified->format().", olddate=".($olddate ? $olddate->format() : ''));
foreach($to_notify as $userid => $statusid)
{
unset($res_info);
@ -860,6 +867,7 @@ class calendar_boupdate extends calendar_bo
$olddate->setTimezone($timezone);
$details['olddate'] = $olddate->format($timeformat);
}
//error_log(__METHOD__."() userid=$userid, timezone=".$timezone->getName().", startdate=$details[startdate], enddate=$details[enddate], updated=$details[updated], olddate=$details[olddate]");
list($subject,$notify_body) = explode("\n",$GLOBALS['egw']->preferences->parse_notify($notify_msg,$details),2);
$popup = '';
@ -957,6 +965,9 @@ class calendar_boupdate extends calendar_bo
{
translation::init();
}
// restore timezone, in case we had to reset it to server-timezone
if ($restore_tz) date_default_timezone_set($restore_tz);
return true;
}

View File

@ -16,6 +16,9 @@ require_once EGW_SERVER_ROOT.'/phpgwapi/inc/horde/lib/core.php';
/**
* iCal import and export via Horde iCalendar classes
*
* @ToDo: NOT changing default-timezone as it messes up timezone calculation of timestamps eg. in calendar_boupdate::send_update
* (currently fixed by restoring server-timezone in calendar_boupdate::send_update)
*/
class calendar_ical extends calendar_boupdate
{