mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-06-25 04:11:49 +02:00
Impoved support for recurrences if device timezone differs from event timezone
This commit is contained in:
parent
f0be57c0d2
commit
4088b81c5c
@ -100,6 +100,13 @@ class calendar_ical extends calendar_boupdate
|
|||||||
*/
|
*/
|
||||||
var $tzid = null;
|
var $tzid = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cached timezone data
|
||||||
|
*
|
||||||
|
* @var array id => data
|
||||||
|
*/
|
||||||
|
protected static $tz_cache = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Device CTCap Properties
|
* Device CTCap Properties
|
||||||
*
|
*
|
||||||
@ -384,30 +391,8 @@ class calendar_ical extends calendar_boupdate
|
|||||||
// dont use "virtual" exceptions created by participant status for GroupDAV or file export
|
// dont use "virtual" exceptions created by participant status for GroupDAV or file export
|
||||||
if (!in_array($this->productManufacturer,array('file','groupdav')))
|
if (!in_array($this->productManufacturer,array('file','groupdav')))
|
||||||
{
|
{
|
||||||
$participants = $this->so->get_participants($event['id'], 0);
|
$tz_id = ($tzid != $event['tzid'] ? $tzid : null);
|
||||||
|
$days = $this->so->get_recurrence_exceptions($event, $tz_id);
|
||||||
// Check if the stati for all participants are identical for all recurrences
|
|
||||||
foreach ($participants as $uid => $attendee)
|
|
||||||
{
|
|
||||||
switch ($attendee['type'])
|
|
||||||
{
|
|
||||||
case 'u': // account
|
|
||||||
case 'c': // contact
|
|
||||||
case 'e': // email address
|
|
||||||
$recurrences = $this->so->get_recurrences($event['id'], $uid);
|
|
||||||
foreach ($recurrences as $rdate => $recur_status)
|
|
||||||
{
|
|
||||||
if ($rdate && $recur_status != $recurrences[0])
|
|
||||||
{
|
|
||||||
// Every distinct status results in an exception
|
|
||||||
$days[] = $rdate;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default: // We don't handle the rest
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (is_array($event['recur_exception']))
|
if (is_array($event['recur_exception']))
|
||||||
{
|
{
|
||||||
@ -687,13 +672,11 @@ class calendar_ical extends calendar_boupdate
|
|||||||
{
|
{
|
||||||
$time = new egw_time($time,egw_time::$server_timezone);
|
$time = new egw_time($time,egw_time::$server_timezone);
|
||||||
}
|
}
|
||||||
static $timezone;
|
if (!isset(self::$tz_cache[$tzid]))
|
||||||
static $timezone_tzid;
|
|
||||||
if (is_null($timezone) || $timezone_tzid != $tzid)
|
|
||||||
{
|
{
|
||||||
$timezone = calendar_timezones::DateTimeZone($timezone_tzid = $tzid);
|
self::$tz_cache[$tzid] = calendar_timezones::DateTimeZone($tzid);
|
||||||
}
|
}
|
||||||
$time->setTimezone($timezone);
|
$time->setTimezone(self::$tz_cache[$tzid]);
|
||||||
$params['TZID'] = $tzid;
|
$params['TZID'] = $tzid;
|
||||||
|
|
||||||
return $time->format('Ymd\THis');
|
return $time->format('Ymd\THis');
|
||||||
|
@ -90,6 +90,14 @@ class calendar_so
|
|||||||
*/
|
*/
|
||||||
const STATUS_SORT = "CASE cal_status WHEN 'U' THEN 1 WHEN 'T' THEN 2 WHEN 'A' THEN 3 WHEN 'R' THEN 4 ELSE 0 END ASC";
|
const STATUS_SORT = "CASE cal_status WHEN 'U' THEN 1 WHEN 'T' THEN 2 WHEN 'A' THEN 3 WHEN 'R' THEN 4 ELSE 0 END ASC";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cached timezone data
|
||||||
|
*
|
||||||
|
* @var array id => data
|
||||||
|
*/
|
||||||
|
protected static $tz_cache = array();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor of the socal class
|
* Constructor of the socal class
|
||||||
*/
|
*/
|
||||||
@ -1433,16 +1441,30 @@ ORDER BY cal_user_type, cal_usre_id
|
|||||||
* Gets the exception days of a given recurring event caused by
|
* Gets the exception days of a given recurring event caused by
|
||||||
* irregular participant stati
|
* irregular participant stati
|
||||||
*
|
*
|
||||||
* @param array $event Recurring Event.
|
* @param array $event Recurring Event.
|
||||||
|
* @param string tz_id=null timezone for exports (null for event's timezone)
|
||||||
*
|
*
|
||||||
* @return array Array of exception days (false for non-recurring events).
|
* @return array Array of exception days (false for non-recurring events).
|
||||||
*/
|
*/
|
||||||
function get_recurrence_exceptions(&$event)
|
function get_recurrence_exceptions(&$event, $tz_id=null)
|
||||||
{
|
{
|
||||||
$cal_id = (int) $event['id'];
|
$cal_id = (int) $event['id'];
|
||||||
if (!$cal_id || $event['recur_type'] == MCAL_RECUR_NONE) return false;
|
if (!$cal_id || $event['recur_type'] == MCAL_RECUR_NONE) return false;
|
||||||
|
|
||||||
$days = array();
|
$days = array();
|
||||||
|
$first_start = $recur_start = '';
|
||||||
|
|
||||||
|
if (!empty($tz_id))
|
||||||
|
{
|
||||||
|
// set export timezone
|
||||||
|
if(!isset(self::$tz_cache[$tz_id]))
|
||||||
|
{
|
||||||
|
self::$tz_cache[$tz_id] = calendar_timezones::DateTimeZone($tz_id);
|
||||||
|
}
|
||||||
|
$starttime = new egw_time($event['start'], egw_time::$server_timezone);
|
||||||
|
$starttime->setTimezone(self::$tz_cache[$tz_id]);
|
||||||
|
$first_start = $starttime->format('His');
|
||||||
|
}
|
||||||
|
|
||||||
$participants = $this->get_participants($event['id'], 0);
|
$participants = $this->get_participants($event['id'], 0);
|
||||||
|
|
||||||
@ -1457,10 +1479,20 @@ ORDER BY cal_user_type, cal_usre_id
|
|||||||
$recurrences = $this->get_recurrences($event['id'], $uid);
|
$recurrences = $this->get_recurrences($event['id'], $uid);
|
||||||
foreach ($recurrences as $recur_date => $recur_status)
|
foreach ($recurrences as $recur_date => $recur_status)
|
||||||
{
|
{
|
||||||
if ($recur_date && $recur_status != $recurrences[0])
|
if ($recur_date)
|
||||||
{
|
{
|
||||||
// Every distinct status results in an exception
|
if (!empty($tz_id))
|
||||||
$days[] = $recur_date;
|
{
|
||||||
|
$time = new egw_time($recur_date, egw_time::$server_timezone);
|
||||||
|
$time->setTimezone(self::$tz_cache[$tz_id]);
|
||||||
|
$recur_start = $time->format('His');
|
||||||
|
}
|
||||||
|
if ($recur_status != $recurrences[0]
|
||||||
|
|| !empty($tz_id) && $first_start != $recur_start)
|
||||||
|
{
|
||||||
|
// Every distinct status or starttime results in an exception
|
||||||
|
$days[] = $recur_date;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user