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']));
$vcal->setAttribute('VERSION', $version);
$vcal->setAttribute('METHOD', $method);
$events_exported = false;
if (!is_array($events)) $events = array($events);
@ -893,9 +894,10 @@ class calendar_ical extends calendar_boupdate
}
}
$vcal->addComponent($vevent);
$events_exported = true;
}
$retval = $vcal->exportvCalendar();
$retval = $events_exported ? $vcal->exportvCalendar() : false;
if ($this->log)
{
error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
@ -1070,7 +1072,7 @@ class calendar_ical extends calendar_boupdate
if (!isset($event['participants'][$uid]))
{
// Add it back in
$event['participants'][$uid] = $event['participant_types']['r'][substr($uid,1)] = $status;
$event['participants'][$uid] = $status;
}
}
break;
@ -1083,7 +1085,14 @@ class calendar_ical extends calendar_boupdate
else
{
// 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)
{
@ -1094,7 +1103,6 @@ class calendar_ical extends calendar_boupdate
// If this is an updated meeting, and the client doesn't support
// participants OR the event no longer contains participants, add them back
unset($event['participants']);
unset($event['participant_types']);
}
else
{
@ -1119,20 +1127,19 @@ class calendar_ical extends calendar_boupdate
}
}
}
}
foreach ($event_info['stored_event']['participants'] as $uid => $status)
{
// Is it a resource and no longer present in the event?
if ($uid[0] == 'r' && !isset($event['participants'][$uid]))
foreach ($event_info['stored_event']['participants'] as $uid => $status)
{
if ($this->log)
// Is it a resource and no longer present in the event?
if ($uid[0] == 'r' && !isset($event['participants'][$uid]))
{
error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
"() Restore resource $uid to status $status\n",3,$this->logfile);
if ($this->log)
{
error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
"() Restore resource $uid to status $status\n",3,$this->logfile);
}
// Add it back in
$event['participants'][$uid] = $status;
}
// Add it back in
$event['participants'][$uid] = $event['participant_types']['r'][substr($uid,1)] = $status;
}
}
@ -1188,7 +1195,9 @@ class calendar_ical extends calendar_boupdate
$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 = calendar_so::combine_status($status, 1, 'CHAIR');
@ -1198,7 +1207,7 @@ class calendar_ical extends calendar_boupdate
{
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 ($uid == $event['owner'])
@ -1499,46 +1508,49 @@ class calendar_ical extends calendar_boupdate
$event_info['stored_event'] = $this->read($updated_id, 0, false, 'server');
}
// update status depending on the given event type
switch ($event_info['type'])
if (isset($event['participants']))
{
case 'SINGLE':
case 'SERIES-MASTER':
case 'SERIES-EXCEPTION':
case 'SERIES-EXCEPTION-PROPAGATE':
if (is_array($event_info['stored_event'])) // status update requires a stored event
{
if ($event_info['acl_edit'])
// update status depending on the given event type
switch ($event_info['type'])
{
case 'SINGLE':
case 'SERIES-MASTER':
case 'SERIES-EXCEPTION':
case 'SERIES-EXCEPTION-PROPAGATE':
if (is_array($event_info['stored_event'])) // status update requires a stored event
{
// update all participants if we have the right to do that
$this->update_status($event, $event_info['stored_event']);
if ($event_info['acl_edit'])
{
// update all participants if we have the right to do that
$this->update_status($event, $event_info['stored_event']);
}
elseif (isset($event['participants'][$this->user]) || isset($event_info['stored_event']['participants'][$this->user]))
{
// update the users status only
$this->set_status($event_info['stored_event']['id'], $this->user,
($event['participants'][$this->user] ? $event['participants'][$this->user] : 'R'), 0, true);
}
}
elseif (isset($event['participants'][$this->user]) || isset($event_info['stored_event']['participants'][$this->user]))
{
// update the users status only
$this->set_status($event_info['stored_event']['id'], $this->user,
($event['participants'][$this->user] ? $event['participants'][$this->user] : 'R'), 0, true);
}
}
break;
break;
case 'SERIES-PSEUDO-EXCEPTION':
if (is_array($event_info['master_event'])) // status update requires a stored master event
{
$recurrence = $this->date2usertime($event['recurrence']);
if ($event_info['acl_edit'])
case 'SERIES-PSEUDO-EXCEPTION':
if (is_array($event_info['master_event'])) // status update requires a stored master event
{
// update all participants if we have the right to do that
$this->update_status($event, $event_info['stored_event'], $recurrence);
$recurrence = $this->date2usertime($event['recurrence']);
if ($event_info['acl_edit'])
{
// update all participants if we have the right to do that
$this->update_status($event, $event_info['stored_event'], $recurrence);
}
elseif (isset($event['participants'][$this->user]) || isset($event_info['master_event']['participants'][$this->user]))
{
// update the users status only
$this->set_status($event_info['master_event']['id'], $this->user,
($event['participants'][$this->user] ? $event['participants'][$this->user] : 'R'), $recurrence, true);
}
}
elseif (isset($event['participants'][$this->user]) || isset($event_info['master_event']['participants'][$this->user]))
{
// update the users status only
$this->set_status($event_info['master_event']['id'], $this->user,
($event['participants'][$this->user] ? $event['participants'][$this->user] : 'R'), $recurrence, true);
}
}
break;
break;
}
}
// choose which id to return to the client
@ -1864,6 +1876,7 @@ class calendar_ical extends calendar_boupdate
case 'd750i':
case 'p910i':
case 'g705i':
case 'w890i':
$this->supportedFields = $defaultFields['basic'];
break;
default:
@ -2491,7 +2504,7 @@ class calendar_ical extends calendar_boupdate
{
//Horde::logMessage("vevent2egw: set status to " . $status,
// __FILE__, __LINE__, PEAR_LOG_DEBUG);
$event['participants'][$this->user] =
$vcardData['participants'][$this->user] =
calendar_so::combine_status($status);
}
$status = 'U'; // keep the group
@ -2532,12 +2545,12 @@ class calendar_ical extends calendar_boupdate
{
$attributes['params']['ROLE'] = 'CHAIR';
}
if (!isset($event['participants'][$uid]) ||
$event['participants'][$uid][0] != 'A')
if (!isset($vcardData['participants'][$uid]) ||
$vcardData['participants'][$uid][0] != 'A')
{
// for multiple entries the ACCEPT wins
// add quantity and role
$event['participants'][$uid] =
$vcardData['participants'][$uid] =
calendar_so::combine_status($status,
$attributes['params']['X-EGROUPWARE-QUANTITY'],
$attributes['params']['ROLE']);
@ -2545,11 +2558,11 @@ class calendar_ical extends calendar_boupdate
break;
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);
$event['participants'][$uid] =
$vcardData['participants'][$uid] =
calendar_so::combine_status($status, $quantity, 'CHAIR');
}
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
$event['owner'] = $this->user;
if (!isset($event['participants'][$uid]))
if (!isset($vcardData['participants'][$uid]))
{
// save the ORGANIZER as event CHAIR
$event['participants'][$uid] =
$vcardData['participants'][$uid] =
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)
{
if (!isset($new_event['participants'])) return;
// check the old list against the new list
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
foreach ($event_info['stored_event'] as $key => $value)
{
if (in_array($key, array('participants', 'participant_types')))
if ($key == 'participants')
{
unset($event[$key]);
continue;
@ -490,7 +490,6 @@ class calendar_sif extends calendar_boupdate
// not merge
// SIF clients do not support participants => add them back
unset($event['participants']);
unset($event['participant_types']);
if ($event['whole_day'] && $event['tzid'] != $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'] = $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_WEEKLY && !$event['recur_data'])
{
@ -833,14 +833,11 @@ class calendar_uiforms extends calendar_ui
// check if we should create an 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);
}
else
{
$event = $this->bo->read($cal_id,0,true); // read the 0-recurrence
$event = $this->bo->read($cal_id,0,true);
}
}
}
@ -1077,12 +1074,12 @@ class calendar_uiforms extends calendar_ui
$GLOBALS['egw']->js->set_onload("set_style_by_class('table','end_hide','display','".($content['duration'] && isset($sel_options['duration'][$content['duration']]) ? 'none' : 'block')."');");
$readonlys['recur_exception'] = !count($content['recur_exception']); // otherwise we get a delete button
if ($event['recur_type'] != MCAL_RECUR_NONE)
{
$onclick =& $etpl->get_cell_attribute('button[delete]','onclick');
$onclick = str_replace('Delete this event','Delete this series of recuring events',$onclick);
// some fundamental values of an existing series should not be changed by the user
$readonlys['start'] = $readonlys['whole_day'] = true;
$readonlys['recur_type'] = $readonlys['recur_data'] = true;
@ -1746,7 +1743,7 @@ class calendar_uiforms extends calendar_ui
'owner' => 'select-account',
'cat_id' => 'select-cat',
'non_blocking' => array(''=>lang('No'), 1=>lang('Yes')),
'start' => 'date-time',
'end' => 'date-time',
@ -1770,11 +1767,11 @@ class calendar_uiforms extends calendar_ui
if($content['recur_type'] || $content['recurrence']) {
$content['history']['filter'] = array(
'(history_status NOT LIKE \'participants%\' OR (history_status LIKE \'participants%\' AND (
history_new_value LIKE \'%' . bo_tracking::ONE2N_SEPERATOR . $content['recurrence'] . '\' OR
history_new_value LIKE \'%' . bo_tracking::ONE2N_SEPERATOR . $content['recurrence'] . '\' OR
history_old_value LIKE \'%' . bo_tracking::ONE2N_SEPERATOR . $content['recurrence'] . '\')))'
);
}
// Translate labels
$tracking = new calendar_tracking();
foreach($tracking->field2label as $field => $label) {