Commit 6bc8319d authored by Manfred Kutas's avatar Manfred Kutas

ZP-1322 All-day event created in Outlook stretches over 2 days in

Webapp.

Released under the Affero GNU General Public License (AGPL) version 3.
parent 4c5f014c
...@@ -315,6 +315,7 @@ class MAPIMapping { ...@@ -315,6 +315,7 @@ class MAPIMapping {
"isrecurring" => "PT_BOOLEAN:PSETID_Appointment:0x8223", "isrecurring" => "PT_BOOLEAN:PSETID_Appointment:0x8223",
"recurringstate" => "PT_BINARY:PSETID_Appointment:0x8216", "recurringstate" => "PT_BINARY:PSETID_Appointment:0x8216",
"timezonetag" => "PT_BINARY:PSETID_Appointment:0x8233", "timezonetag" => "PT_BINARY:PSETID_Appointment:0x8233",
"timezonedesc" => "PT_STRING8:PSETID_Appointment:0x8234",
"recurrenceend" => "PT_SYSTIME:PSETID_Appointment:0x8236", "recurrenceend" => "PT_SYSTIME:PSETID_Appointment:0x8236",
"responsestatus" => "PT_LONG:PSETID_Appointment:0x8218", "responsestatus" => "PT_LONG:PSETID_Appointment:0x8218",
"commonstart" => "PT_SYSTIME:PSETID_Common:0x8516", "commonstart" => "PT_SYSTIME:PSETID_Common:0x8516",
......
...@@ -215,18 +215,31 @@ class MAPIProvider { ...@@ -215,18 +215,31 @@ class MAPIProvider {
$message->organizername = w2u($messageprops[$appointmentprops["representingname"]]); $message->organizername = w2u($messageprops[$appointmentprops["representingname"]]);
} }
if(isset($messageprops[$appointmentprops["timezonetag"]])) $appTz = false; // if the appointment has some timezone information saved on the server
if (!empty($messageprops[$appointmentprops["timezonetag"]])) {
$tz = $this->getTZFromMAPIBlob($messageprops[$appointmentprops["timezonetag"]]); $tz = $this->getTZFromMAPIBlob($messageprops[$appointmentprops["timezonetag"]]);
$appTz = true;
}
elseif (!empty($messageprops[$appointmentprops["timezonedesc"]])) {
// Windows uses UTC in timezone description in opposite to mstzones in TimezoneUtil which uses GMT
$wintz = str_replace("UTC", "GMT", $messageprops[$appointmentprops["timezonedesc"]]);
$tz = TimezoneUtil::GetFullTZFromTZName(TimezoneUtil::GetTZNameFromWinTZ($wintz));
$appTz = true;
}
else { else {
// set server default timezone (correct timezone should be configured!) // set server default timezone (correct timezone should be configured!)
$tz = TimezoneUtil::GetFullTZ(); $tz = TimezoneUtil::GetFullTZ();
} }
$message->timezone = base64_encode(TimezoneUtil::GetSyncBlobFromTZ($tz));
if(isset($messageprops[$appointmentprops["isrecurring"]]) && $messageprops[$appointmentprops["isrecurring"]]) { if(isset($messageprops[$appointmentprops["isrecurring"]]) && $messageprops[$appointmentprops["isrecurring"]]) {
// Process recurrence // Process recurrence
$message->recurrence = new SyncRecurrence(); $message->recurrence = new SyncRecurrence();
$this->getRecurrence($mapimessage, $messageprops, $message, $message->recurrence, $tz); $this->getRecurrence($mapimessage, $messageprops, $message, $message->recurrence, $tz);
// outlook seems to honour the timezone information contrary to other clients
if (Request::IsOutlook()) {
$message->timezone = base64_encode(TimezoneUtil::GetSyncBlobFromTZ($tz));
}
} }
// Do attendees // Do attendees
...@@ -343,6 +356,24 @@ class MAPIProvider { ...@@ -343,6 +356,24 @@ class MAPIProvider {
$message->busystatus = fbTentative; $message->busystatus = fbTentative;
} }
// All-day events might appear as 24h (or multiple of it) long when they start not exactly at midnight (+/- bias of the timezone)
if (isset($message->alldayevent) && $message->alldayevent) {
$localStartTime = localtime($message->starttime, 1);
// The appointment is all-day but doesn't start at midnight.
// If it was created in another timezone and we have that information,
// set the startime to the midnight of the current timezone.
if ($appTz && ($localStartTime['tm_hour'] || $localStartTime['tm_min'])) {
$duration = $message->endtime - $message->starttime;
ZLog::Write(LOGLEVEL_DEBUG, "MAPIProvider->getAppointment(): all-day event starting not midnight.");
$serverTz = TimezoneUtil::GetFullTZ();
ZLog::Write(LOGLEVEL_DEBUG, print_r($serverTz, 1));
$message->starttime = $this->getGMTTimeByTZ($this->getLocaltimeByTZ($message->starttime, $tz), $serverTz);
$message->endtime = $message->starttime + $duration;
}
}
return $message; return $message;
} }
...@@ -1293,6 +1324,10 @@ class MAPIProvider { ...@@ -1293,6 +1324,10 @@ class MAPIProvider {
$this->setASbody($appointment->asbody, $props, $appointmentprops); $this->setASbody($appointment->asbody, $props, $appointmentprops);
} }
if ($tz !== false) {
$props[$appointmentprops["timezonetag"]] = $this->getMAPIBlobFromTZ($tz);
}
if(isset($appointment->recurrence)) { if(isset($appointment->recurrence)) {
// Set PR_ICON_INDEX to 1025 to show correct icon in category view // Set PR_ICON_INDEX to 1025 to show correct icon in category view
$props[$appointmentprops["icon"]] = 1025; $props[$appointmentprops["icon"]] = 1025;
......
...@@ -1378,4 +1378,28 @@ class TimezoneUtil { ...@@ -1378,4 +1378,28 @@ class TimezoneUtil {
ZLog::Write(LOGLEVEL_DEBUG, sprintf("TimezoneUtil::GetPhpSupportedTimezone(): '%s' is not a PHP supported timezone. Returning default timezone: '%s'", $timezone, $dtz)); ZLog::Write(LOGLEVEL_DEBUG, sprintf("TimezoneUtil::GetPhpSupportedTimezone(): '%s' is not a PHP supported timezone. Returning default timezone: '%s'", $timezone, $dtz));
return $dtz; return $dtz;
} }
/**
* Returns official timezone name from windows timezone name.
* E.g. "W Europe Standard Time" for "(GMT+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna".
*
* @param string $winTz Timezone name in windows
*
* @access public
* @return string timezone name
*/
public static function GetTZNameFromWinTZ($winTz = false) {
// Return "GMT Standard Time" per default
if ($winTz === false) {
return self::$mstzones['085'][0];
}
foreach (self::$mstzones as $mskey => $msdefs) {
if ($winTz == $msdefs[1]) {
return $msdefs[0];
}
}
return self::$mstzones['085'][0];
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment