aboutsummaryrefslogtreecommitdiffstats
path: root/caldav.php
diff options
context:
space:
mode:
authorJack Bates <jablko@users.sourceforge.net>2006-04-14 02:50:09 +0000
committerJack Bates <jablko@users.sourceforge.net>2006-04-14 02:50:09 +0000
commit40e077eb346693da15662632a90e5df0ff305046 (patch)
treec00c8197ae733e7e56e61e2aacecbde2c6818082 /caldav.php
parentdfc4ff9ca8e46383d68320738b0336cf27458bab (diff)
downloadphpicalendar-40e077eb346693da15662632a90e5df0ff305046.tar.gz
phpicalendar-40e077eb346693da15662632a90e5df0ff305046.tar.bz2
phpicalendar-40e077eb346693da15662632a90e5df0ff305046.zip
* Depth: header support
* Committing current WebDAV library
Diffstat (limited to 'caldav.php')
-rw-r--r--caldav.php59
1 files changed, 32 insertions, 27 deletions
diff --git a/caldav.php b/caldav.php
index eb11ab7..d9c7ebc 100644
--- a/caldav.php
+++ b/caldav.php
@@ -148,13 +148,13 @@ class HTTP_CalDAV_Server_PHPiCalendar extends HTTP_CalDAV_Server {
return true;
}
- // FIXME Handle depth
// FIXME Use file_exists
function propfind($options, &$files) {
$files = array();
- $paths = array();
- $path = $options['path'];
- while (isset($path)) {
+ $paths = array(array($options['path'], 0));
+ while (!empty($paths)) {
+ list ($path, $depth) = array_pop($paths);
+
$file = array();
$file['path'] = $path;
@@ -168,18 +168,21 @@ class HTTP_CalDAV_Server_PHPiCalendar extends HTTP_CalDAV_Server {
if (is_dir($absolutePath)) {
$file['props'][] = $this->mkprop('resourcetype', 'collection');
- $handle = opendir($absolutePath);
- if (!$handle) {
- return;
- }
+ if ($depth < $options['depth']) {
+ $handle = opendir($absolutePath);
+ if (!$handle) {
+ return;
+ }
- while (($pathComponent = readdir($handle)) !== false) {
- if ($pathComponent != '.' && $pathComponent != '..') {
- $paths[] = $path != '' ? "$path/$pathComponent" :
- $pathComponent;
+ while (($pathComponent = readdir($handle)) !== false) {
+ if ($pathComponent != '.' && $pathComponent != '..') {
+ $paths[] = array($path != '' ?
+ "$path/$pathComponent" : $pathComponent,
+ $depth + 1);
+ }
}
+ closedir($handle);
}
- closedir($handle);
} else {
$file['props'][] = $this->mkprop('getcontentlength',
$stat['size']);
@@ -187,7 +190,6 @@ class HTTP_CalDAV_Server_PHPiCalendar extends HTTP_CalDAV_Server {
}
$files[] = $file;
- $path = array_pop($paths);
}
return true;
@@ -211,9 +213,10 @@ class HTTP_CalDAV_Server_PHPiCalendar extends HTTP_CalDAV_Server {
function report($options, &$files) {
$files = array();
- $paths = array();
- $path = $options['path'];
- while (isset($path)) {
+ $paths = array(array($options['path'], 0));
+ while (!empty($paths)) {
+ list ($path, $depth) = array_pop($paths);
+
$file = array();
$file['path'] = $path;
@@ -227,18 +230,21 @@ class HTTP_CalDAV_Server_PHPiCalendar extends HTTP_CalDAV_Server {
if (is_dir($absolutePath)) {
$file['props'][] = $this->mkprop('resourcetype', 'collection');
- $handle = opendir($absolutePath);
- if (!$handle) {
- return;
- }
+ if ($depth < $options['depth']) {
+ $handle = opendir($absolutePath);
+ if (!$handle) {
+ return;
+ }
- while (($pathComponent = readdir($handle)) !== false) {
- if ($pathComponent != '.' && $pathComponent != '..') {
- $paths[] = $path != '' ? "$path/$pathComponent" :
- $pathComponent;
+ while (($pathComponent = readdir($handle)) !== false) {
+ if ($pathComponent != '.' && $pathComponent != '..') {
+ $paths[] = array($path != '' ?
+ "$path/$pathComponent" : $pathComponent,
+ $depth + 1);
+ }
}
+ closedir($handle);
}
- closedir($handle);
} else {
$file['props'][] = $this->mkprop('getcontentlength',
$stat['size']);
@@ -246,7 +252,6 @@ class HTTP_CalDAV_Server_PHPiCalendar extends HTTP_CalDAV_Server {
}
$files[] = $file;
- $path = array_pop($paths);
}
return true;

© 2014-2024 Faster IT GmbH | imprint | privacy policy