* Calendar: Fix notification timezone issues (#2746)

This commit is contained in:
Jörg Lehrke 2010-11-01 19:17:57 +00:00
parent 89b8f68f7e
commit b3e551e74b

View File

@ -581,7 +581,7 @@ class calendar_boupdate extends calendar_bo
$GLOBALS['egw']->preferences->__construct($user); $GLOBALS['egw']->preferences->__construct($user);
$GLOBALS['egw_info']['user']['preferences'] = $GLOBALS['egw']->preferences->read_repository(); $GLOBALS['egw_info']['user']['preferences'] = $GLOBALS['egw']->preferences->read_repository();
} }
$senderid = $GLOBALS['egw_info']['user']['account_id']; $senderid = $this->user;
$event = $msg_type == MSG_ADDED || $msg_type == MSG_MODIFIED ? $new_event : $old_event; $event = $msg_type == MSG_ADDED || $msg_type == MSG_MODIFIED ? $new_event : $old_event;
switch($msg_type) switch($msg_type)
@ -667,6 +667,10 @@ class calendar_boupdate extends calendar_bo
} }
} }
$user_prefs = $GLOBALS['egw_info']['user']['preferences']; $user_prefs = $GLOBALS['egw_info']['user']['preferences'];
$startdate = new egw_time($event['start']);
$enddate = new egw_time($event['start']);
$modified = new egw_time($event['modified']);
if ($old_event != False) $olddate = new egw_time($old_event['start']);
foreach($to_notify as $userid => $statusid) foreach($to_notify as $userid => $statusid)
{ {
if ($this->debug > 0) error_log(__METHOD__." trying to notify $userid, with $statusid"); if ($this->debug > 0) error_log(__METHOD__." trying to notify $userid, with $statusid");
@ -697,18 +701,36 @@ class calendar_boupdate extends calendar_bo
$GLOBALS['egw']->accounts->get_account_name($userid,$lid,$details['to-firstname'],$details['to-lastname']); $GLOBALS['egw']->accounts->get_account_name($userid,$lid,$details['to-firstname'],$details['to-lastname']);
$details['to-fullname'] = $GLOBALS['egw']->common->display_fullname('',$details['to-firstname'],$details['to-lastname']); $details['to-fullname'] = $GLOBALS['egw']->common->display_fullname('',$details['to-firstname'],$details['to-lastname']);
$GLOBALS['egw_info']['user']['preferences']['common']['tz_offset'] = $part_prefs['common']['tz_offset'];
$GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] = $part_prefs['common']['timeformat'];
$GLOBALS['egw_info']['user']['preferences']['common']['dateformat'] = $part_prefs['common']['dateformat'];
$GLOBALS['egw']->datetime->tz_offset = 3600 * (int) $GLOBALS['egw_info']['user']['preferences']['common']['tz_offset'];
// event is in user-time of current user, now we need to calculate the tz-difference to the notified user and take it into account // event is in user-time of current user, now we need to calculate the tz-difference to the notified user and take it into account
$tz_diff = $GLOBALS['egw_info']['user']['preferences']['common']['tz_offset'] - $this->common_prefs['tz_offset']; if (!isset($part_prefs['common']['tz'])) $part_prefs['common']['tz'] = $GLOBALS['egw_info']['server']['server_timezone'];
if($old_event != False) $details['olddate'] = $this->format_date($old_event['start']+$tz_diff); $timezone = new DateTimeZone($part_prefs['common']['tz']);
$details['startdate'] = $this->format_date($event['start']+$tz_diff); $timeformat = $part_prefs['common']['timeformat'];
$details['enddate'] = $this->format_date($event['end']+$tz_diff); switch($timeformat)
{
case '24':
$timeformat = 'H:i';
break;
case '12':
$timeformat = 'h:i a';
break;
}
$timeformat = $part_prefs['common']['dateformat'] . ', ' . $timeformat;
$startdate->setTimezone($timezone);
$details['startdate'] = $startdate->format($timeformat);
$enddate->setTimezone($timezone);
$details['enddate'] = $enddate->format($timeformat);
$modified->setTimezone($timezone);
$details['updated'] = $modified->format($timeformat) . ', ' . common::grab_owner_name($event['modifier']);
if ($old_event != False)
{
$olddate->setTimezone($timezone);
$details['olddate'] = $olddate->format($timeformat);
}
list($subject,$body) = explode("\n",$GLOBALS['egw']->preferences->parse_notify($notify_msg,$details),2); list($subject,$body) = explode("\n",$GLOBALS['egw']->preferences->parse_notify($notify_msg,$details),2);
switch($part_prefs['calendar']['update_format']) switch($part_prefs['calendar']['update_format'])
@ -765,7 +787,7 @@ class calendar_boupdate extends calendar_bo
} }
// restore the enviroment (preferences->read_repository() sets the timezone!) // restore the enviroment (preferences->read_repository() sets the timezone!)
$GLOBALS['egw_info']['user'] = $temp_user; $GLOBALS['egw_info']['user'] = $temp_user;
if ($GLOBALS['egw']->preferences->account_id != $temp_user['account_id'] || isset($preferences)) if ($GLOBALS['egw']->preferences->account_id != $temp_user['account_id'])
{ {
$GLOBALS['egw']->preferences->__construct($temp_user['account_id']); $GLOBALS['egw']->preferences->__construct($temp_user['account_id']);
$GLOBALS['egw_info']['user']['preferences'] = $GLOBALS['egw']->preferences->read_repository(); $GLOBALS['egw_info']['user']['preferences'] = $GLOBALS['egw']->preferences->read_repository();
@ -1156,7 +1178,6 @@ class calendar_boupdate extends calendar_bo
if ($updateTS) if ($updateTS)
{ {
$GLOBALS['egw']->contenthistory->updateTimeStamp('calendar', $cal_id, 'modify', $this->now); $GLOBALS['egw']->contenthistory->updateTimeStamp('calendar', $cal_id, 'modify', $this->now);
//$this->so->updateModified($cal_id, $this->now, $this->user);
} }
static $status2msg = array( static $status2msg = array(
@ -1386,12 +1407,12 @@ class calendar_boupdate extends calendar_bo
$var['owner'] = Array( $var['owner'] = Array(
'field' => lang('Owner'), 'field' => lang('Owner'),
'data' => $GLOBALS['egw']->common->grab_owner_name($event['owner']) 'data' => common::grab_owner_name($event['owner'])
); );
$var['updated'] = Array( $var['updated'] = Array(
'field' => lang('Updated'), 'field' => lang('Updated'),
'data' => $this->format_date($event['modtime']).', '.$GLOBALS['egw']->common->grab_owner_name($event['modifier']) 'data' => $this->format_date($event['modtime']).', '.common::grab_owner_name($event['modifier'])
); );
$var['access'] = Array( $var['access'] = Array(
@ -1469,7 +1490,6 @@ class calendar_boupdate extends calendar_bo
$alarm['time'] = $this->date2ts($alarm['time'],true); // user to server-time $alarm['time'] = $this->date2ts($alarm['time'],true); // user to server-time
$GLOBALS['egw']->contenthistory->updateTimeStamp('calendar', $cal_id, 'modify', $this->now); $GLOBALS['egw']->contenthistory->updateTimeStamp('calendar', $cal_id, 'modify', $this->now);
//$this->so->updateModified($cal_id, $this->now, $this->user);
return $this->so->save_alarm($cal_id,$alarm, $this->now); return $this->so->save_alarm($cal_id,$alarm, $this->now);
} }
@ -1490,7 +1510,6 @@ class calendar_boupdate extends calendar_bo
} }
$GLOBALS['egw']->contenthistory->updateTimeStamp('calendar', $cal_id, 'modify', $this->now); $GLOBALS['egw']->contenthistory->updateTimeStamp('calendar', $cal_id, 'modify', $this->now);
//$this->so->updateModified($cal_id, $this->now, $this->user);
return $this->so->delete_alarm($id, $this->now); return $this->so->delete_alarm($id, $this->now);
} }