Switch to iCalComponent rather than iCalendar.

This commit is contained in:
Andrew McMillan 2008-11-10 11:49:54 +13:00
parent 2c4a620967
commit d360f220f5

View File

@ -80,28 +80,34 @@ function calendar_to_xml( $properties, $item ) {
if ( isset($properties['calendar-data']) || isset($properties['displayname']) ) { if ( isset($properties['calendar-data']) || isset($properties['displayname']) ) {
if ( !$request->AllowedTo('all') && $session->user_no != $item->user_no ){ if ( !$request->AllowedTo('all') && $session->user_no != $item->user_no ){
// the user is not admin / owner of this calendarlooking at his calendar and can not admin the other cal // the user is not admin / owner of this calendarlooking at his calendar and can not admin the other cal
/** @todo We should examine the ORGANIZER and ATTENDEE fields in the event. If this person is there then they should see this, and perhaps get alarms also */
if ( $item->class == 'CONFIDENTIAL' ) { if ( $item->class == 'CONFIDENTIAL' ) {
$ical = new iCalendar( array( "icalendar" => $caldav_data) ); $ical = new iCalComponent( $caldav_data );
$resources = $ical->GetComponents('VTIMEZONE',false);
$first = $resources[0];
// if the event is confidential we fake one that just says "Busy" // if the event is confidential we fake one that just says "Busy"
$confidential = new iCalendar( array( $confidential = new iCalComponent();
'SUMMARY' => translate('Busy'), 'CLASS' => 'CONFIDENTIAL', $confidential->SetType($first->GetType());
'DTSTART' => $ical->Get('DTSTART') $confidential->AddProperty( 'SUMMARY', translate('Busy') );
) ); $confidential->AddProperty( 'CLASS', 'CONFIDENTIAL' );
$rrule = $ical->Get('RRULE'); $confidential->SetProperties( $first->GetProperties('DTSTART'), 'DTSTART' );
if ( isset($rrule) && $rrule != '' ) $confidential->Set('RRULE', $rrule); $confidential->SetProperties( $first->GetProperties('RRULE'), 'RRULE' );
$duration = $ical->Get('DURATION'); $confidential->SetProperties( $first->GetProperties('DURATION'), 'DURATION' );
if ( isset($duration) && $duration != "" ) { $confidential->SetProperties( $first->GetProperties('DTEND'), 'DTEND' );
$confidential->Set('DURATION', $duration ); $ical->SetComponents(array($confidential),$confidential->GetType());
}
else { $caldav_data = $ical->Render();
$confidential->Set('DTEND', $ical->Get('DTEND') );
}
$caldav_data = $confidential->Render( true, $item->caldav_type );
} }
elseif ( isset($c->hide_alarm) && $c->hide_alarm ) { elseif ( isset($c->hide_alarm) && $c->hide_alarm ) {
// Otherwise we hide the alarms (if configured to) // Otherwise we hide the alarms (if configured to)
$ical = new iCalendar( array( "icalendar" => $caldav_data) ); $ical = new iCalComponent( $caldav_data );
$ical->component->ClearComponents('VALARM'); $timezones = $ical->GetComponents('VTIMEZONE',true);
$resources = $ical->GetComponents('VTIMEZONE',false);
foreach( $resources AS $k => $v ) {
$v->ClearComponents('VALARM');
}
$ical->SetComponents($timezones + $resources);
$caldav_data = $ical->render(true, $caldav_type ); $caldav_data = $ical->render(true, $caldav_type );
} }
} }