Fix various recurring event issues

This commit is contained in:
Jörg Lehrke 2010-02-24 15:05:00 +00:00
parent 85b6ba5ef0
commit b2b8b35383
3 changed files with 83 additions and 72 deletions

View File

@ -211,6 +211,7 @@ class calendar_ical extends calendar_boupdate
strtoupper($GLOBALS['egw_info']['user']['preferences']['common']['lang'])); strtoupper($GLOBALS['egw_info']['user']['preferences']['common']['lang']));
$vcal->setAttribute('VERSION', $version); $vcal->setAttribute('VERSION', $version);
$vcal->setAttribute('METHOD', $method); $vcal->setAttribute('METHOD', $method);
$events_exported = false;
if (!is_array($events)) $events = array($events); if (!is_array($events)) $events = array($events);
@ -893,9 +894,10 @@ class calendar_ical extends calendar_boupdate
} }
} }
$vcal->addComponent($vevent); $vcal->addComponent($vevent);
$events_exported = true;
} }
$retval = $vcal->exportvCalendar(); $retval = $events_exported ? $vcal->exportvCalendar() : false;
if ($this->log) if ($this->log)
{ {
error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ . error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
@ -1070,7 +1072,7 @@ class calendar_ical extends calendar_boupdate
if (!isset($event['participants'][$uid])) if (!isset($event['participants'][$uid]))
{ {
// Add it back in // Add it back in
$event['participants'][$uid] = $event['participant_types']['r'][substr($uid,1)] = $status; $event['participants'][$uid] = $status;
} }
} }
break; break;
@ -1083,7 +1085,14 @@ class calendar_ical extends calendar_boupdate
else else
{ {
// no merge // no merge
if (!isset($this->supportedFields['participants']) || !count($event['participants'])) if(!isset($this->supportedFields['category']))
{
$event['category'] = $event_info['stored_event']['category'];
}
if (!isset($this->supportedFields['participants'])
|| !$event['participants']
|| !is_array($event['participants'])
|| !count($event['participants']))
{ {
if ($this->log) if ($this->log)
{ {
@ -1094,7 +1103,6 @@ class calendar_ical extends calendar_boupdate
// If this is an updated meeting, and the client doesn't support // If this is an updated meeting, and the client doesn't support
// participants OR the event no longer contains participants, add them back // participants OR the event no longer contains participants, add them back
unset($event['participants']); unset($event['participants']);
unset($event['participant_types']);
} }
else else
{ {
@ -1119,8 +1127,6 @@ class calendar_ical extends calendar_boupdate
} }
} }
} }
}
foreach ($event_info['stored_event']['participants'] as $uid => $status) foreach ($event_info['stored_event']['participants'] as $uid => $status)
{ {
// Is it a resource and no longer present in the event? // Is it a resource and no longer present in the event?
@ -1132,7 +1138,8 @@ class calendar_ical extends calendar_boupdate
"() Restore resource $uid to status $status\n",3,$this->logfile); "() Restore resource $uid to status $status\n",3,$this->logfile);
} }
// Add it back in // Add it back in
$event['participants'][$uid] = $event['participant_types']['r'][substr($uid,1)] = $status; $event['participants'][$uid] = $status;
}
} }
} }
@ -1188,7 +1195,9 @@ class calendar_ical extends calendar_boupdate
$event['owner'] = $this->user; $event['owner'] = $this->user;
} }
if (!is_array($event['participants']) || !count($event['participants'])) if (!$event['participants']
|| !is_array($event['participants'])
|| !count($event['participants']))
{ {
$status = $event['owner'] == $this->user ? 'A' : 'U'; $status = $event['owner'] == $this->user ? 'A' : 'U';
$status = calendar_so::combine_status($status, 1, 'CHAIR'); $status = calendar_so::combine_status($status, 1, 'CHAIR');
@ -1198,7 +1207,7 @@ class calendar_ical extends calendar_boupdate
{ {
foreach ($event['participants'] as $uid => $status) foreach ($event['participants'] as $uid => $status)
{ {
// Is it a resource and no longer present in the event? // if the client did not give us a proper status => set default
if ($status[0] == 'X') if ($status[0] == 'X')
{ {
if ($uid == $event['owner']) if ($uid == $event['owner'])
@ -1499,6 +1508,8 @@ class calendar_ical extends calendar_boupdate
$event_info['stored_event'] = $this->read($updated_id, 0, false, 'server'); $event_info['stored_event'] = $this->read($updated_id, 0, false, 'server');
} }
if (isset($event['participants']))
{
// update status depending on the given event type // update status depending on the given event type
switch ($event_info['type']) switch ($event_info['type'])
{ {
@ -1540,6 +1551,7 @@ class calendar_ical extends calendar_boupdate
} }
break; break;
} }
}
// choose which id to return to the client // choose which id to return to the client
switch ($event_info['type']) switch ($event_info['type'])
@ -1864,6 +1876,7 @@ class calendar_ical extends calendar_boupdate
case 'd750i': case 'd750i':
case 'p910i': case 'p910i':
case 'g705i': case 'g705i':
case 'w890i':
$this->supportedFields = $defaultFields['basic']; $this->supportedFields = $defaultFields['basic'];
break; break;
default: default:
@ -2491,7 +2504,7 @@ class calendar_ical extends calendar_boupdate
{ {
//Horde::logMessage("vevent2egw: set status to " . $status, //Horde::logMessage("vevent2egw: set status to " . $status,
// __FILE__, __LINE__, PEAR_LOG_DEBUG); // __FILE__, __LINE__, PEAR_LOG_DEBUG);
$event['participants'][$this->user] = $vcardData['participants'][$this->user] =
calendar_so::combine_status($status); calendar_so::combine_status($status);
} }
$status = 'U'; // keep the group $status = 'U'; // keep the group
@ -2532,12 +2545,12 @@ class calendar_ical extends calendar_boupdate
{ {
$attributes['params']['ROLE'] = 'CHAIR'; $attributes['params']['ROLE'] = 'CHAIR';
} }
if (!isset($event['participants'][$uid]) || if (!isset($vcardData['participants'][$uid]) ||
$event['participants'][$uid][0] != 'A') $vcardData['participants'][$uid][0] != 'A')
{ {
// for multiple entries the ACCEPT wins // for multiple entries the ACCEPT wins
// add quantity and role // add quantity and role
$event['participants'][$uid] = $vcardData['participants'][$uid] =
calendar_so::combine_status($status, calendar_so::combine_status($status,
$attributes['params']['X-EGROUPWARE-QUANTITY'], $attributes['params']['X-EGROUPWARE-QUANTITY'],
$attributes['params']['ROLE']); $attributes['params']['ROLE']);
@ -2545,11 +2558,11 @@ class calendar_ical extends calendar_boupdate
break; break;
case 'ORGANIZER': case 'ORGANIZER':
if (isset($event['participants'][$uid])) if (isset($vcardData['participants'][$uid]))
{ {
$status = $event['participants'][$uid]; $status = $vcardData['participants'][$uid];
calendar_so::split_status($status, $quantity, $role); calendar_so::split_status($status, $quantity, $role);
$event['participants'][$uid] = $vcardData['participants'][$uid] =
calendar_so::combine_status($status, $quantity, 'CHAIR'); calendar_so::combine_status($status, $quantity, 'CHAIR');
} }
if (is_numeric($uid) && ($uid == $this->calendarOwner || !$this->calendarOwner)) if (is_numeric($uid) && ($uid == $this->calendarOwner || !$this->calendarOwner))
@ -2561,10 +2574,10 @@ class calendar_ical extends calendar_boupdate
{ {
// we must insert a CHAIR participant to keep the ORGANIZER // we must insert a CHAIR participant to keep the ORGANIZER
$event['owner'] = $this->user; $event['owner'] = $this->user;
if (!isset($event['participants'][$uid])) if (!isset($vcardData['participants'][$uid]))
{ {
// save the ORGANIZER as event CHAIR // save the ORGANIZER as event CHAIR
$event['participants'][$uid] = $vcardData['participants'][$uid] =
calendar_so::combine_status('U', 1, 'CHAIR'); calendar_so::combine_status('U', 1, 'CHAIR');
} }
} }
@ -2781,6 +2794,8 @@ class calendar_ical extends calendar_boupdate
*/ */
function update_status($new_event, $old_event , $recur_date=0) function update_status($new_event, $old_event , $recur_date=0)
{ {
if (!isset($new_event['participants'])) return;
// check the old list against the new list // check the old list against the new list
foreach ($old_event['participants'] as $userid => $status) foreach ($old_event['participants'] as $userid => $status)
{ {

View File

@ -477,7 +477,7 @@ class calendar_sif extends calendar_boupdate
// overwrite with server data for merge // overwrite with server data for merge
foreach ($event_info['stored_event'] as $key => $value) foreach ($event_info['stored_event'] as $key => $value)
{ {
if (in_array($key, array('participants', 'participant_types'))) if ($key == 'participants')
{ {
unset($event[$key]); unset($event[$key]);
continue; continue;
@ -490,7 +490,6 @@ class calendar_sif extends calendar_boupdate
// not merge // not merge
// SIF clients do not support participants => add them back // SIF clients do not support participants => add them back
unset($event['participants']); unset($event['participants']);
unset($event['participant_types']);
if ($event['whole_day'] && $event['tzid'] != $event_info['stored_event']['tzid']) if ($event['whole_day'] && $event['tzid'] != $event_info['stored_event']['tzid'])
{ {
if (!isset(self::$tz_cache[$event_info['stored_event']['tzid']])) if (!isset(self::$tz_cache[$event_info['stored_event']['tzid']]))

View File

@ -238,7 +238,7 @@ class calendar_uiforms extends calendar_ui
$event['end']['hour'] = 23; $event['end']['minute'] = $event['end']['second'] = 59; unset($event['end']['raw']); $event['end']['hour'] = 23; $event['end']['minute'] = $event['end']['second'] = 59; unset($event['end']['raw']);
$event['end'] = $this->bo->date2ts($event['end']); $event['end'] = $this->bo->date2ts($event['end']);
} }
// some checks for recurances, if you give a date, make it a weekly repeating event and visa versa // some checks for recurrences, if you give a date, make it a weekly repeating event and visa versa
if ($event['recur_type'] == MCAL_RECUR_NONE && $event['recur_data']) $event['recur_type'] = MCAL_RECUR_WEEKLY; if ($event['recur_type'] == MCAL_RECUR_NONE && $event['recur_data']) $event['recur_type'] = MCAL_RECUR_WEEKLY;
if ($event['recur_type'] == MCAL_RECUR_WEEKLY && !$event['recur_data']) if ($event['recur_type'] == MCAL_RECUR_WEEKLY && !$event['recur_data'])
{ {
@ -833,14 +833,11 @@ class calendar_uiforms extends calendar_ui
// check if we should create an exception // check if we should create an exception
if ($_GET['exception']) if ($_GET['exception'])
{ {
// exception: preserv participants of this event and merge it with the 0-recurrence
$participants = array('participants' => $event['participants'],'participant_types' => $event['participant_types']);
$event = array_merge($this->bo->read($cal_id,0,true),$participants);
$msg = $this->_create_exception($event,$preserv); $msg = $this->_create_exception($event,$preserv);
} }
else else
{ {
$event = $this->bo->read($cal_id,0,true); // read the 0-recurrence $event = $this->bo->read($cal_id,0,true);
} }
} }
} }