Fix (pseudo) exception handling in CalDAV

This commit is contained in:
Jörg Lehrke 2010-02-26 12:30:17 +00:00
parent 96a47f2dff
commit 77dc590614
3 changed files with 39 additions and 39 deletions

View File

@ -802,6 +802,37 @@ class calendar_boupdate extends calendar_bo
return $Ok;
}
/**
* update the status of all participant for a given recurrence or for all recurrences since now (includes recur_date=0)
*
* @param array $new_event event-array with the new stati
* @param array $old_event event-array with the old stati
* @param int $recur_date=0 date to change, or 0 = all since now
*/
function update_status($new_event, $old_event , $recur_date=0)
{
if (!isset($new_event['participants'])) return;
// check the old list against the new list
foreach ($old_event['participants'] as $userid => $status)
{
if (!isset($new_event['participants'][$userid])){
// Attendee will be deleted this way
$new_event['participants'][$userid] = 'G';
}
elseif ($new_event['participants'][$userid] == $status)
{
// Same status -- nothing to do.
unset($new_event['participants'][$userid]);
}
}
// write the changes
foreach ($new_event['participants'] as $userid => $status)
{
$this->set_status($old_event, $userid, $status, $recur_date, true, false);
}
}
/**
* deletes an event
*

View File

@ -149,8 +149,9 @@ class calendar_groupdav extends groupdav_handler
foreach($events as $k => &$event)
{
if ($this->client_shared_uid_exceptions &&
$event['reference'] &&
($master = $this->bo->read($event['reference'], 0, false, 'server')) &&
$event['reference'] && $event['uid'] &&
($masterId = array_shift($this->bo->find_event(array('uid' => $event['uid']), 'master'))) &&
($master = $this->bo->read($masterId, 0, false, 'server')) &&
array_search($event['reference'], $master['recur_exception']) !== false)
{
// this exception will be handled with the series master
@ -475,8 +476,7 @@ class calendar_groupdav extends groupdav_handler
*/
static function fix_series(array &$events)
{
foreach($events as $n => $event) error_log(__METHOD__." $n before: ".array2string($event));
//$master =& $events[0];
//foreach($events as $n => $event) error_log(__METHOD__." $n before: ".array2string($event));
$bo = new calendar_boupdate();
@ -526,16 +526,16 @@ class calendar_groupdav extends groupdav_handler
{
if ($org_recurrence['id'] != $master['id']) // non-virtual recurrence
{
error_log(__METHOD__.'() deleting #'.$org_recurrence['id']);
//error_log(__METHOD__.'() deleting #'.$org_recurrence['id']);
$bo->delete($org_recurrence['id']); // might fail because of permissions
}
else // virtual recurrence
{
error_log(__METHOD__.'() ToDO: delete virtual exception '.$org_recurrence['reference'].' = '.date('Y-m-d H:i:s',$org_recurrence['reference']));
// todo: reset status and participants to master default
//error_log(__METHOD__.'() ToDO: delete virtual exception '.$org_recurrence['reference'].' = '.date('Y-m-d H:i:s',$org_recurrence['reference']));
$bo->update_status($master, $org_recurrence, $org_recurrence['reference']);
}
}
foreach($events as $n => $event) error_log(__METHOD__." $n after: ".array2string($event));
//foreach($events as $n => $event) error_log(__METHOD__." $n after: ".array2string($event));
}
/**

View File

@ -2683,37 +2683,6 @@ class calendar_ical extends calendar_boupdate
return $vcal->exportvCalendar();
}
/**
* update the status of all participant for a given recurrence or for all recurrences since now (includes recur_date=0)
*
* @param array $new_event event-array with the new stati
* @param array $old_event event-array with the old stati
* @param int $recur_date=0 date to change, or 0 = all since now
*/
function update_status($new_event, $old_event , $recur_date=0)
{
if (!isset($new_event['participants'])) return;
// check the old list against the new list
foreach ($old_event['participants'] as $userid => $status)
{
if (!isset($new_event['participants'][$userid])){
// Attendee will be deleted this way
$new_event['participants'][$userid] = 'G';
}
elseif ($new_event['participants'][$userid] == $status)
{
// Same status -- nothing to do.
unset($new_event['participants'][$userid]);
}
}
// write the changes
foreach ($new_event['participants'] as $userid => $status)
{
$this->set_status($old_event, $userid, $status, $recur_date, true, false);
}
}
/**
* generate and insert a VTIMEZONE entry to a vcalendar
*