Maxime Delorme suggested that we should do this differently now that

the iCalendar class is more functional.  I agree.
This commit is contained in:
Andrew McMillan 2007-10-28 18:19:14 +13:00
parent a79967dfa8
commit c2794db775
2 changed files with 12 additions and 6 deletions

View File

@ -45,6 +45,10 @@ else if ( $qry->rows > 1 ) {
*/ */
include_once("iCalendar.php"); include_once("iCalendar.php");
$response = iCalendar::iCalHeader(); $response = iCalendar::iCalHeader();
$collqry = new PgQuery( "SELECT * FROM collection WHERE collection.user_no = ? AND collection.dav_name = ?;", $request->user_no, $request->path);
if ( $collqry->Exec("GET") && $collection = $collqry->Fetch() ) {
$response .= "X-WR-CALNAME:$collection->dav_displayname\r\n";
}
$timezones = array(); $timezones = array();
while( $event = $qry->Fetch() ) { while( $event = $qry->Fetch() ) {
$ical = new iCalendar( array( "icalendar" => $event->caldav_data ) ); $ical = new iCalendar( array( "icalendar" => $event->caldav_data ) );
@ -63,7 +67,8 @@ else if ( $qry->rows > 1 ) {
} }
elseif ( $c->hide_alarm ) { elseif ( $c->hide_alarm ) {
// Otherwise we hide the alarms (if configured to) // Otherwise we hide the alarms (if configured to)
$response .= $ical->Render( false, $event->caldav_type, $ical->DefaultPropertyList() ); $ical->component->ClearComponents('VALARM');
$response .= $ical->render(true, $event->caldav_type );
} }
else { else {
$response .= $ical->Render( false, $event->caldav_type ); $response .= $ical->Render( false, $event->caldav_type );

View File

@ -73,14 +73,15 @@ function calendar_to_xml( $properties, $item ) {
if ( $item->class == 'CONFIDENTIAL' ) { if ( $item->class == 'CONFIDENTIAL' ) {
// if the event is confidential we fake one that just says "Busy" // if the event is confidential we fake one that just says "Busy"
$displayname = translate("Busy"); $displayname = translate("Busy");
$ical = new iCalendar( array( "icalendar" => $item->caldav_data) ); $ical = new iCalendar( array( "icalendar" => $caldav_data) );
$ical->Put( 'SUMMARY', $displayname ); $ical->Put( 'SUMMARY', $displayname );
$caldav_data = $ical->render(true, $item->caldav_type, $ical->DefaultPropertyList() ); $caldav_data = $ical->render(true, $caldav_type, $ical->DefaultPropertyList() );
} }
elseif ( $c->hide_alarm ) { elseif ( $c->hide_alarm ) {
// Otherwise we hide the alarms (if configured to) // Otherwise we hide the alarms (if configured to)
$ical = new iCalendar( array( "icalendar" => $item->caldav_data) ); $ical = new iCalendar( array( "icalendar" => $caldav_data) );
$caldav_data = $ical->render(true, $item->caldav_type, $ical->DefaultPropertyList() ); $ical->component->ClearComponents('VALARM');
$caldav_data = $ical->render(true, $caldav_type );
} }
} }
} }
@ -90,7 +91,7 @@ function calendar_to_xml( $properties, $item ) {
foreach( $properties AS $k => $v ) { foreach( $properties AS $k => $v ) {
switch( $k ) { switch( $k ) {
case 'GETCONTENTLENGTH': case 'GETCONTENTLENGTH':
$contentlength = strlen($item->caldav_data); $contentlength = strlen($caldav_data);
$prop->NewElement("getcontentlength", $contentlength ); $prop->NewElement("getcontentlength", $contentlength );
break; break;
case 'CALENDAR-DATA': case 'CALENDAR-DATA':