Fix wrong classification in get_event_info() and UID handling for CalDAV

This commit is contained in:
Jörg Lehrke 2010-02-11 20:50:35 +00:00
parent adf9a0917f
commit 65c06844e5
2 changed files with 27 additions and 22 deletions

View File

@ -1470,8 +1470,9 @@ class calendar_boupdate extends calendar_bo
'()[FOUND]:' . array2string($egwEvent)); '()[FOUND]:' . array2string($egwEvent));
} }
// Just a simple consistency check // Just a simple consistency check
if ($filter == 'master' && $egwEvent['recur_type'] != MCAL_RECUR_NONE || if ($filter == 'exact' ||
$filter == 'exact' || strpos($egwEvent['title'], $event['title']) === 0) $filter == 'master' && $egwEvent['recur_type'] != MCAL_RECUR_NONE ||
$filter != 'master' && strpos($egwEvent['title'], $event['title']) === 0)
{ {
$retval = $egwEvent['id']; $retval = $egwEvent['id'];
if ($egwEvent['recur_type'] != MCAL_RECUR_NONE && if ($egwEvent['recur_type'] != MCAL_RECUR_NONE &&
@ -1543,7 +1544,7 @@ class calendar_boupdate extends calendar_bo
} }
} }
} }
if ($filter != 'master') if ($filter != 'master' && $filter != 'exact' )
{ {
if (isset($event['whole_day']) && $event['whole_day']) if (isset($event['whole_day']) && $event['whole_day'])
{ {

View File

@ -35,14 +35,14 @@ class calendar_groupdav extends groupdav_handler
//'EXDATE' //'EXDATE'
//'RECURRENCE-ID' //'RECURRENCE-ID'
); );
/** /**
* Does client understand exceptions to be included in VCALENDAR component of series master sharing its UID * Does client understand exceptions to be included in VCALENDAR component of series master sharing its UID
* *
* That also means no EXDATE for these exceptions! * That also means no EXDATE for these exceptions!
* *
* Setting it to false, should give the old behavior used in 1.6 (hopefully) no client needs that. * Setting it to false, should give the old behavior used in 1.6 (hopefully) no client needs that.
* *
* @var boolean * @var boolean
*/ */
var $client_shared_uid_exceptions = true; var $client_shared_uid_exceptions = true;
@ -311,12 +311,12 @@ class calendar_groupdav extends groupdav_handler
header('ETag: '.$this->get_etag($event)); header('ETag: '.$this->get_etag($event));
return true; return true;
} }
/** /**
* Generate an iCal for the given event * Generate an iCal for the given event
* *
* Taking into account virtual an real exceptions for recuring events * Taking into account virtual an real exceptions for recuring events
* *
* @param array $event * @param array $event
* @return string * @return string
*/ */
@ -324,9 +324,9 @@ class calendar_groupdav extends groupdav_handler
{ {
static $handler = null; static $handler = null;
if (is_null($handler)) $handler = $this->_get_handler(); if (is_null($handler)) $handler = $this->_get_handler();
$events = array($event); $events = array($event);
// for recuring events we have to add the exceptions // for recuring events we have to add the exceptions
if ($this->client_shared_uid_exceptions && $event['recur_type'] && !empty($event['uid'])) if ($this->client_shared_uid_exceptions && $event['recur_type'] && !empty($event['uid']))
{ {
@ -338,12 +338,12 @@ class calendar_groupdav extends groupdav_handler
} }
return $handler->exportVCal($events,'2.0','PUBLISH'); return $handler->exportVCal($events,'2.0','PUBLISH');
} }
/** /**
* Get array with events of a series identified by its UID (master and all exceptions) * Get array with events of a series identified by its UID (master and all exceptions)
* *
* Maybe that should be part of calendar_bo * Maybe that should be part of calendar_bo
* *
* @param string $uid UID * @param string $uid UID
* @param calendar_bo $bo=null calendar_bo object to reuse for search call * @param calendar_bo $bo=null calendar_bo object to reuse for search call
* @return array * @return array
@ -370,7 +370,7 @@ class calendar_groupdav extends groupdav_handler
{ {
//error_log('real exception: '.array2string($recurrence)); //error_log('real exception: '.array2string($recurrence));
// remove from masters recur_exception, as exception is include // remove from masters recur_exception, as exception is include
// at least Lightning "understands" EXDATE as exception from what's included // at least Lightning "understands" EXDATE as exception from what's included
// in the whole resource / VCALENDAR component // in the whole resource / VCALENDAR component
// not removing it causes Lightning to remove the exception itself // not removing it causes Lightning to remove the exception itself
if (($k = array_search($recurrence['recurrence'],$master['recur_exception'])) !== false) if (($k = array_search($recurrence['recurrence'],$master['recur_exception'])) !== false)
@ -416,6 +416,10 @@ class calendar_groupdav extends groupdav_handler
return $event; return $event;
} }
$handler = $this->_get_handler(); $handler = $this->_get_handler();
if (!is_numeric($id) && ($foundEntries = $handler->find_event($options['content'], 'check')))
{
$id = array_shift($foundEntries);
}
if (!($cal_id = $handler->importVCal($options['content'],is_numeric($id) ? $id : -1, if (!($cal_id = $handler->importVCal($options['content'],is_numeric($id) ? $id : -1,
self::etag2value($this->http_if_match)))) self::etag2value($this->http_if_match))))
{ {
@ -432,22 +436,22 @@ class calendar_groupdav extends groupdav_handler
} }
return true; return true;
} }
/** /**
* Fix event series with exceptions, called by calendar_ical::importVCal(): * Fix event series with exceptions, called by calendar_ical::importVCal():
* a) only series master = first event got cal_id from URL * a) only series master = first event got cal_id from URL
* b) exceptions need to be checked if they are already in DB or new * b) exceptions need to be checked if they are already in DB or new
* c) recurrence-id of (real not virtual) exceptions need to be re-added to master * c) recurrence-id of (real not virtual) exceptions need to be re-added to master
* *
* @param array &$events * @param array &$events
*/ */
static function fix_series(array &$events) static function fix_series(array &$events)
{ {
foreach($events as $n => $event) error_log(__METHOD__." $n before: ".array2string($event)); foreach($events as $n => $event) error_log(__METHOD__." $n before: ".array2string($event));
$master =& $events[0]; $master =& $events[0];
$bo = new calendar_boupdate(); $bo = new calendar_boupdate();
// get array with orginal recurrences indexed by recurrence-id // get array with orginal recurrences indexed by recurrence-id
$org_recurrences = array(); $org_recurrences = array();
foreach(self::get_series($master['uid'],$bo) as $event) foreach(self::get_series($master['uid'],$bo) as $event)
@ -462,14 +466,14 @@ class calendar_groupdav extends groupdav_handler
foreach($events as &$recurrence) foreach($events as &$recurrence)
{ {
if ($recurrence['id'] || !$recurrence['recurrence']) continue; // master if ($recurrence['id'] || !$recurrence['recurrence']) continue; // master
// from now on we deal with exceptions // from now on we deal with exceptions
$org_recurrence = $org_recurrences[$recurrence['recurrence']]; $org_recurrence = $org_recurrences[$recurrence['recurrence']];
if (isset($org_recurrence)) // already existing recurrence if (isset($org_recurrence)) // already existing recurrence
{ {
error_log(__METHOD__.'() setting id #'.$org_recurrence['id']).' for '.$recurrence['recurrence'].' = '.date('Y-m-d H:i:s',$recurrence['recurrence']); error_log(__METHOD__.'() setting id #'.$org_recurrence['id']).' for '.$recurrence['recurrence'].' = '.date('Y-m-d H:i:s',$recurrence['recurrence']);
$recurrence['id'] = $org_recurrence['id']; $recurrence['id'] = $org_recurrence['id'];
// re-add (non-virtual) exceptions to master's recur_exception // re-add (non-virtual) exceptions to master's recur_exception
if ($recurrence['id'] != $master['id']) if ($recurrence['id'] != $master['id'])
{ {