forked from extern/egroupware
"more RECURRENCE-ID stuff:
- disabling it on import, as we cant overwrite a cal_id with a timestamp - fixing it on export, finding the closest exception to return it - using array_merge to merge virtual and real exceptions, as + overwrites numeric keys"
This commit is contained in:
parent
81a4097818
commit
86db825cbf
@ -137,7 +137,8 @@ class calendar_ical extends calendar_boupdate
|
|||||||
*
|
*
|
||||||
* @param array $_clientProperties client properties
|
* @param array $_clientProperties client properties
|
||||||
*/
|
*/
|
||||||
function __construct(&$_clientProperties = array()) {
|
function __construct(&$_clientProperties = array())
|
||||||
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
|
|
||||||
$this->clientProperties = $_clientProperties;
|
$this->clientProperties = $_clientProperties;
|
||||||
@ -161,7 +162,7 @@ class calendar_ical extends calendar_boupdate
|
|||||||
$egwSupportedFields = array(
|
$egwSupportedFields = array(
|
||||||
'CLASS' => array('dbName' => 'public'),
|
'CLASS' => array('dbName' => 'public'),
|
||||||
'SUMMARY' => array('dbName' => 'title'),
|
'SUMMARY' => array('dbName' => 'title'),
|
||||||
'DESCRIPTION' => array('dbName' => 'description'),
|
'DESCRIPTION' => array('dbName' => 'description'),
|
||||||
'LOCATION' => array('dbName' => 'location'),
|
'LOCATION' => array('dbName' => 'location'),
|
||||||
'DTSTART' => array('dbName' => 'start'),
|
'DTSTART' => array('dbName' => 'start'),
|
||||||
'DTEND' => array('dbName' => 'end'),
|
'DTEND' => array('dbName' => 'end'),
|
||||||
@ -171,9 +172,9 @@ class calendar_ical extends calendar_boupdate
|
|||||||
'EXDATE' => array('dbName' => 'recur_exception'),
|
'EXDATE' => array('dbName' => 'recur_exception'),
|
||||||
'PRIORITY' => array('dbName' => 'priority'),
|
'PRIORITY' => array('dbName' => 'priority'),
|
||||||
'TRANSP' => array('dbName' => 'non_blocking'),
|
'TRANSP' => array('dbName' => 'non_blocking'),
|
||||||
'CATEGORIES' => array('dbName' => 'category'),
|
'CATEGORIES' => array('dbName' => 'category'),
|
||||||
'UID' => array('dbName' => 'uid'),
|
'UID' => array('dbName' => 'uid'),
|
||||||
'RECURRENCE-ID' => array('dbName' => 'reference'),
|
'RECURRENCE-ID' => array('dbName' => 'reference'),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!is_array($this->supportedFields)) $this->setSupportedFields();
|
if (!is_array($this->supportedFields)) $this->setSupportedFields();
|
||||||
@ -456,33 +457,37 @@ class calendar_ical extends calendar_boupdate
|
|||||||
case 'EXDATE':
|
case 'EXDATE':
|
||||||
if ($event['recur_type'] == MCAL_RECUR_NONE) break;
|
if ($event['recur_type'] == MCAL_RECUR_NONE) break;
|
||||||
$days = array();
|
$days = array();
|
||||||
$participants = $this->so->get_participants($event['id'], 0);
|
// dont use "virtual" exceptions created by participant status for GroupDAV or file export
|
||||||
|
if (!in_array($this->productManufacturer,array('file','groupdav')))
|
||||||
// Check if the stati for all participants are identical for all recurrences
|
|
||||||
foreach ($participants as $uid => $attendee)
|
|
||||||
{
|
{
|
||||||
switch ($attendee['type'])
|
$participants = $this->so->get_participants($event['id'], 0);
|
||||||
|
|
||||||
|
// Check if the stati for all participants are identical for all recurrences
|
||||||
|
foreach ($participants as $uid => $attendee)
|
||||||
{
|
{
|
||||||
case 'u': // account
|
switch ($attendee['type'])
|
||||||
case 'c': // contact
|
{
|
||||||
case 'e': // email address
|
case 'u': // account
|
||||||
$recurrences = $this->so->get_recurrences($event['id'], $uid);
|
case 'c': // contact
|
||||||
foreach ($recurrences as $rdate => $recur_status)
|
case 'e': // email address
|
||||||
{
|
$recurrences = $this->so->get_recurrences($event['id'], $uid);
|
||||||
if ($rdate && $recur_status != $recurrences[0])
|
foreach ($recurrences as $rdate => $recur_status)
|
||||||
{
|
{
|
||||||
// Every distinct status results in an exception
|
if ($rdate && $recur_status != $recurrences[0])
|
||||||
$days[] = $rdate;
|
{
|
||||||
|
// Every distinct status results in an exception
|
||||||
|
$days[] = $rdate;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
break;
|
default: // We don't handle the rest
|
||||||
default: // We don't handle the rest
|
break;
|
||||||
break;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (is_array($event['recur_exception']))
|
if (is_array($event['recur_exception']))
|
||||||
{
|
{
|
||||||
$days = $days + $event['recur_exception'];
|
$days = array_merge($days,$event['recur_exception']); // can NOT use +, as it overwrites numeric indexes
|
||||||
}
|
}
|
||||||
if (!empty($days))
|
if (!empty($days))
|
||||||
{
|
{
|
||||||
@ -569,11 +574,24 @@ class calendar_ical extends calendar_boupdate
|
|||||||
elseif ($event['reference'])
|
elseif ($event['reference'])
|
||||||
{
|
{
|
||||||
// $event['reference'] is a calendar_id, not a timestamp
|
// $event['reference'] is a calendar_id, not a timestamp
|
||||||
$revent = $this->read($event['reference']);
|
if (!($revent = $this->read($event['reference']))) break; // referenced event does not exist
|
||||||
|
|
||||||
|
// find recur_exception closest to $event['start'],
|
||||||
|
// as our db-model does NOT store for which recurrence the exception is
|
||||||
|
$exception_start = $exception_diff = null;
|
||||||
|
foreach($revent['recur_exception'] as $exception)
|
||||||
|
{
|
||||||
|
if (!isset($exception_start) || $exception_diff > abs($exception-$event['start']))
|
||||||
|
{
|
||||||
|
$exception_start = $exception;
|
||||||
|
$exception_diff = abs($exception-$event['start']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!isset($exception_start)) break; // referenced event has no exception
|
||||||
|
|
||||||
if ($this->isWholeDay($revent))
|
if ($this->isWholeDay($revent))
|
||||||
{
|
{
|
||||||
$arr = $this->date2array($revent['start']);
|
$arr = $this->date2array($exception_start);
|
||||||
$vevent->setAttribute('RECURRENCE-ID', array(
|
$vevent->setAttribute('RECURRENCE-ID', array(
|
||||||
'year' => $arr['year'],
|
'year' => $arr['year'],
|
||||||
'month' => $arr['month'],
|
'month' => $arr['month'],
|
||||||
@ -585,11 +603,11 @@ class calendar_ical extends calendar_boupdate
|
|||||||
{
|
{
|
||||||
if ($servertime)
|
if ($servertime)
|
||||||
{
|
{
|
||||||
$attributes['RECURRENCE-ID'] = date('Ymd\THis', $revent['start']);
|
$attributes['RECURRENCE-ID'] = date('Ymd\THis', $exception_start);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$attributes['RECURRENCE-ID'] = $revent['start'];
|
$attributes['RECURRENCE-ID'] = $exception_start;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unset($revent);
|
unset($revent);
|
||||||
@ -778,6 +796,7 @@ class calendar_ical extends calendar_boupdate
|
|||||||
$Ok = false; // returning false, if file contains no components
|
$Ok = false; // returning false, if file contains no components
|
||||||
|
|
||||||
$vcal = new Horde_iCalendar;
|
$vcal = new Horde_iCalendar;
|
||||||
|
error_log(__LINE__.__METHOD__.__FILE__.print_r($_vcalData,true));
|
||||||
if (!$vcal->parsevCalendar($_vcalData))
|
if (!$vcal->parsevCalendar($_vcalData))
|
||||||
{
|
{
|
||||||
return $Ok;
|
return $Ok;
|
||||||
@ -822,7 +841,7 @@ class calendar_ical extends calendar_boupdate
|
|||||||
|
|
||||||
if ($event['recur_type'] != MCAL_RECUR_NONE)
|
if ($event['recur_type'] != MCAL_RECUR_NONE)
|
||||||
{
|
{
|
||||||
// No RECCURENCE-ID for series events
|
// No RECURRENCE-ID for series events
|
||||||
$event['reference'] = 0;
|
$event['reference'] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1528,7 +1547,9 @@ class calendar_ical extends calendar_boupdate
|
|||||||
$vcardData['end'] = $dtend_ts;
|
$vcardData['end'] = $dtend_ts;
|
||||||
break;
|
break;
|
||||||
case 'RECURRENCE-ID':
|
case 'RECURRENCE-ID':
|
||||||
$vcardData['reference'] = $attributes['value'];
|
// event['reference'] is a cal_id, not a date!
|
||||||
|
// setting it to a date makes no sense, not setting it keeps an existing correct reference
|
||||||
|
//$vcardData['reference'] = $attributes['value'];
|
||||||
break;
|
break;
|
||||||
case 'LOCATION':
|
case 'LOCATION':
|
||||||
$vcardData['location'] = $attributes['value'];
|
$vcardData['location'] = $attributes['value'];
|
||||||
|
Loading…
Reference in New Issue
Block a user