From 2e64a4fc8e61398c3b901fdc3876ccf388de6496 Mon Sep 17 00:00:00 2001 From: Andrew McMillan Date: Sun, 4 Nov 2007 13:49:22 +1300 Subject: [PATCH] Tidy up the response. --- inc/caldav-PROPFIND.php | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/inc/caldav-PROPFIND.php b/inc/caldav-PROPFIND.php index 8f0db966..cb86923e 100644 --- a/inc/caldav-PROPFIND.php +++ b/inc/caldav-PROPFIND.php @@ -383,16 +383,12 @@ function collection_to_xml( $collection ) { } } - if ( count($not_found->content) > 0 ) { - $status = new XMLElement("status", "HTTP/1.1 404 Not Found" ); - $propstat = new XMLElement( "propstat", array( $not_found, $status) ); - $response[] = $propstat; + if ( is_array($not_found->content) && count($not_found->content) > 0 ) { + $response[] = new XMLElement( "propstat", array( $not_found, new XMLElement("status", "HTTP/1.1 404 Not Found" )) ); } - if ( count($denied->content) > 0 ) { - $status = new XMLElement("status", "HTTP/1.1 403 Forbidden" ); - $propstat = new XMLElement( "propstat", array( $denied, $status) ); - $response[] = $propstat; + if ( is_array($denied->content) && count($denied->content) > 0 ) { + $response[] = new XMLElement( "propstat", array( $denied, new XMLElement("status", "HTTP/1.1 403 Forbidden" )) ); } $response = new XMLElement( "response", $response ); @@ -482,16 +478,12 @@ function item_to_xml( $item ) { $href = new XMLElement("href", $url ); $response = array($href,$propstat); - if ( count($not_found->content) > 0 ) { - $status = new XMLElement("status", "HTTP/1.1 404 Not Found" ); - $propstat = new XMLElement( "propstat", array( $not_found, $status) ); - $response[] = $propstat; + if ( is_array($not_found->content) && count($not_found->content) > 0 ) { + $response[] = new XMLElement( "propstat", array( $not_found, new XMLElement("status", "HTTP/1.1 404 Not Found" )) ); } - if ( count($denied->content) > 0 ) { - $status = new XMLElement("status", "HTTP/1.1 403 Forbidden" ); - $propstat = new XMLElement( "propstat", array( $denied, $status) ); - $response[] = $propstat; + if ( is_array($denied->content) && count($denied->content) > 0 ) { + $response[] = new XMLElement( "propstat", array( $denied, new XMLElement("status", "HTTP/1.1 403 Forbidden" )) ); } $response = new XMLElement( "response", $response );