diff options
author | Jack Bates <jablko@users.sourceforge.net> | 2006-04-13 05:10:24 +0000 |
---|---|---|
committer | Jack Bates <jablko@users.sourceforge.net> | 2006-04-13 05:10:24 +0000 |
commit | 428ef55248c513015bc3233cf62c0e9db0dfbb3a (patch) | |
tree | 05ded9ab63ef157aded0ca1075607ae7da49945c /caldav.php | |
parent | 4ec912ca0ff14694f7cc8ae7d6a01d084847a5f9 (diff) | |
download | phpicalendar-428ef55248c513015bc3233cf62c0e9db0dfbb3a.tar.gz phpicalendar-428ef55248c513015bc3233cf62c0e9db0dfbb3a.tar.bz2 phpicalendar-428ef55248c513015bc3233cf62c0e9db0dfbb3a.zip |
* Almost working preliminary REPORT support
* ReportParser successfully parses calendar-data request values
* _componentParser almost parses iCalendar files & limits by calendar-data request value
* TODO Determine whether _componentParser is rejecting valid iCalendar files
* TODO Reduce duplicate code by factoring special property handling out of propfind_response_helper
* TODO Push filtering parser into bennu?
Diffstat (limited to 'caldav.php')
-rw-r--r-- | caldav.php | 58 |
1 files changed, 42 insertions, 16 deletions
@@ -7,6 +7,12 @@ require_once(BASE . 'functions/calendar_functions.php'); require_once('/home/jablko/public_html/gallery2/modules/webdav/lib/HTTP/WebDAV/Server.php'); require_once(BASE . 'lib/HTTP/CalDAV/Server.php'); +require_once(BASE . 'lib/bennu/bennu.class.php'); +require_once(BASE . 'lib/bennu/iCalendar_components.php'); +require_once(BASE . 'lib/bennu/iCalendar_parameters.php'); +require_once(BASE . 'lib/bennu/iCalendar_properties.php'); +require_once(BASE . 'lib/bennu/iCalendar_rfc2445.php'); + class HTTP_CalDAV_Server_PHPiCalendar extends HTTP_CalDAV_Server { function getBasePath() { global $calendar_path; @@ -81,7 +87,7 @@ class HTTP_CalDAV_Server_PHPiCalendar extends HTTP_CalDAV_Server { } if (is_file($absolutePath)) { - $options['mimetype'] = 'text/calendar'; + $options['mimetype'] = mime_content_type($absolutePath); $stat = stat($absolutePath); $options['mtime'] = $stat['mtime']; @@ -169,7 +175,8 @@ class HTTP_CalDAV_Server_PHPiCalendar extends HTTP_CalDAV_Server { while (($pathComponent = readdir($handle)) !== false) { if ($pathComponent != '.' && $pathComponent != '..') { - $paths[] = "$path/$pathComponent"; + $paths[] = $path != '' ? "$path/$pathComponent" : + $pathComponent; } } closedir($handle); @@ -202,25 +209,44 @@ class HTTP_CalDAV_Server_PHPiCalendar extends HTTP_CalDAV_Server { return $handle; } - function report($options, &$responses) { - global $ALL_CALENDARS_COMBINED; + function report($options, &$files) { + $files = array(); + $paths = array(); + $path = $options['path']; + while (isset($path)) { + $file = array(); + $file['path'] = $path; - $responses = array(); - $paths = availableCalendars(null, null, $ALL_CALENDARS_COMBINED); - foreach ($paths as $path) { - $response = array(); + $absolutePath = HTTP_CalDAV_Server_PHPiCalendar::getBasePath() . + '/' . $path; + $stat = stat($absolutePath); + $file['props'] = array(); + $file['props'][] = $this->mkprop('creationdate', $stat['ctime']); + $file['props'][] = $this->mkprop('getlastmodified', $stat['mtime']); - $response['ns_hash'] = array(); - $response['ns_hash']['urn:ietf:params:xml:ns:caldav'] = 'C'; + if (is_dir($absolutePath)) { + $file['props'][] = $this->mkprop('resourcetype', 'collection'); - $response['href'] = $this->getHref(array_pop(explode('/', $path))); - $response['propstat'] = array(); + $handle = opendir($absolutePath); + if (!$handle) { + return; + } - $props = array(); - $props[] = $this->mkprop('urn:ietf:params:xml:ns:caldav', 'calendar-data', file_get_contents($path)); + while (($pathComponent = readdir($handle)) !== false) { + if ($pathComponent != '.' && $pathComponent != '..') { + $paths[] = $path != '' ? "$path/$pathComponent" : + $pathComponent; + } + } + closedir($handle); + } else { + $file['props'][] = $this->mkprop('getcontentlength', + $stat['size']); + $file['props'][] = $this->mkprop('resourcetype', null); + } - $response['propstat']['200 OK'] = $props; - $responses[] = $response; + $files[] = $file; + $path = array_pop($paths); } return true; |