"- first step of using new recurrence field

- fixed some wrong idention"
This commit is contained in:
Ralf Becker 2009-07-28 08:58:39 +00:00
parent 062f02987b
commit 5aa62b71b9

View File

@ -169,21 +169,21 @@ class calendar_ical extends calendar_boupdate
function &exportVCal($events, $version='1.0', $method='PUBLISH', $recur_date=0) function &exportVCal($events, $version='1.0', $method='PUBLISH', $recur_date=0)
{ {
$egwSupportedFields = array( $egwSupportedFields = array(
'CLASS' => array('dbName' => 'public'), 'CLASS' => 'public',
'SUMMARY' => array('dbName' => 'title'), 'SUMMARY' => 'title',
'DESCRIPTION' => array('dbName' => 'description'), 'DESCRIPTION' => 'description',
'LOCATION' => array('dbName' => 'location'), 'LOCATION' => 'location',
'DTSTART' => array('dbName' => 'start'), 'DTSTART' => 'start',
'DTEND' => array('dbName' => 'end'), 'DTEND' => 'end',
'ORGANIZER' => array('dbName' => 'owner'), 'ORGANIZER' => 'owner',
'ATTENDEE' => array('dbName' => 'participants'), 'ATTENDEE' => 'participants',
'RRULE' => array('dbName' => 'recur_type'), 'RRULE' => 'recur_type',
'EXDATE' => array('dbName' => 'recur_exception'), 'EXDATE' => 'recur_exception',
'PRIORITY' => array('dbName' => 'priority'), 'PRIORITY' => 'priority',
'TRANSP' => array('dbName' => 'non_blocking'), 'TRANSP' => 'non_blocking',
'CATEGORIES' => array('dbName' => 'category'), 'CATEGORIES' => 'category',
'UID' => array('dbName' => 'uid'), 'UID' => 'uid',
'RECURRENCE-ID' => array('dbName' => 'reference'), 'RECURRENCE-ID' => 'recurrence',
); );
if (!is_array($this->supportedFields)) $this->setSupportedFields(); if (!is_array($this->supportedFields)) $this->setSupportedFields();
@ -209,7 +209,7 @@ class calendar_ical extends calendar_boupdate
if (!is_array($events)) $events = array($events); if (!is_array($events)) $events = array($events);
while ($event = array_pop($events)) while (($event = array_pop($events)))
{ {
if (!is_array($event) if (!is_array($event)
&& !($event = $this->read($event, $recur_date, false, $date_format))) && !($event = $this->read($event, $recur_date, false, $date_format)))
@ -258,9 +258,7 @@ class calendar_ical extends calendar_boupdate
} }
} }
foreach($egwSupportedFields as $icalFieldName => $egwFieldInfo) foreach($egwSupportedFields as $icalFieldName => $egwFieldName)
{
if ($this->supportedFields[$egwFieldInfo['dbName']])
{ {
$values[$icalFieldName] = array(); $values[$icalFieldName] = array();
switch($icalFieldName) switch($icalFieldName)
@ -580,24 +578,11 @@ class calendar_ical extends calendar_boupdate
} }
} }
} }
elseif ($event['reference']) elseif ($event['recurrence'] && $event['reference'])
{ {
// $event['reference'] is a calendar_id, not a timestamp // $event['reference'] is a calendar_id, not a timestamp
if (!($revent = $this->read($event['reference']))) break; // referenced event does not exist 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($exception_start); $arr = $this->date2array($exception_start);
@ -612,11 +597,11 @@ class calendar_ical extends calendar_boupdate
{ {
if ($servertime) if ($servertime)
{ {
$attributes['RECURRENCE-ID'] = date('Ymd\THis', $exception_start); $attributes['RECURRENCE-ID'] = date('Ymd\THis', $event['recurrence']);
} }
else else
{ {
$attributes['RECURRENCE-ID'] = $exception_start; $attributes['RECURRENCE-ID'] = $event['recurrence'];
} }
} }
unset($revent); unset($revent);
@ -633,7 +618,7 @@ class calendar_ical extends calendar_boupdate
$size = -1; $size = -1;
$noTruncate = false; $noTruncate = false;
} }
$value = $event[$egwFieldInfo['dbName']]; $value = $event[$egwFieldName];
$cursize = strlen($value); $cursize = strlen($value);
if (($size > 0) && $cursize > $size) { if (($size > 0) && $cursize > $size) {
if ($noTruncate) { if ($noTruncate) {
@ -652,7 +637,6 @@ class calendar_ical extends calendar_boupdate
break; break;
} }
} }
}
if($this->productManufacturer == 'nokia') { if($this->productManufacturer == 'nokia') {
if($event['special'] == '1') { if($event['special'] == '1') {
@ -1557,9 +1541,11 @@ class calendar_ical extends calendar_boupdate
$vcardData['end'] = $dtend_ts; $vcardData['end'] = $dtend_ts;
break; break;
case 'RECURRENCE-ID': case 'RECURRENCE-ID':
// event['reference'] is a cal_id, not a date! // ToDo or check:
// setting it to a date makes no sense, not setting it keeps an existing correct reference // - do we need to set reference (cal_id of orginal series)
//$vcardData['reference'] = $attributes['value']; // - do we need to add that recurrence as recure exception to the original series
// --> original series should be found by searching for a series with same UID (backend)
$vcardData['recurrence'] = $attributes['value'];
break; break;
case 'LOCATION': case 'LOCATION':
$vcardData['location'] = $attributes['value']; $vcardData['location'] = $attributes['value'];
@ -2131,5 +2117,4 @@ class calendar_ical extends calendar_boupdate
$this->set_status($old_event, $userid, $status, $recur_date, true); $this->set_status($old_event, $userid, $status, $recur_date, true);
} }
} }
} }