2006-05-26 03:47:05 +02:00
|
|
|
<?php
|
2006-05-28 04:39:39 +02:00
|
|
|
/**
|
2008-02-18 07:43:49 +01:00
|
|
|
* eGroupWare API: VFS - WebDAV access using the new stream wrapper VFS interface
|
2006-05-28 04:39:39 +02:00
|
|
|
*
|
2008-02-18 07:43:49 +01:00
|
|
|
* Using the PEAR HTTP/WebDAV/Server/Filesystem class (which need to be installed!)
|
2008-04-18 12:41:44 +02:00
|
|
|
*
|
2006-05-28 04:39:39 +02:00
|
|
|
* @link http://www.egroupware.org
|
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
2007-04-29 14:06:17 +02:00
|
|
|
* @package api
|
|
|
|
* @subpackage vfs
|
2006-05-28 04:39:39 +02:00
|
|
|
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
|
2008-02-18 07:43:49 +01:00
|
|
|
* @author Hartmut Holzgraefe <hartmut@php.net> original HTTP/WebDAV/Server/Filesystem class, of which some code is used
|
2007-04-29 14:06:17 +02:00
|
|
|
* @version $Id$
|
2006-05-28 04:39:39 +02:00
|
|
|
*/
|
2006-05-26 03:47:05 +02:00
|
|
|
|
2008-02-18 07:43:49 +01:00
|
|
|
require_once('HTTP/WebDAV/Server/Filesystem.php');
|
2006-05-26 03:47:05 +02:00
|
|
|
|
|
|
|
/**
|
2008-02-18 07:43:49 +01:00
|
|
|
* FileManger - WebDAV access using the new stream wrapper VFS interface
|
2006-05-26 03:47:05 +02:00
|
|
|
*
|
2008-02-18 07:43:49 +01:00
|
|
|
* Using the PEAR HTTP/WebDAV/Server/Filesystem class (which need to be installed!)
|
2008-04-18 12:41:44 +02:00
|
|
|
*
|
2008-05-20 07:16:49 +02:00
|
|
|
* @todo table to store properties
|
|
|
|
* @todo filesystem class uses PEAR's System::find in COPY, which we dont require nor know if it works on custom stream wrappers
|
2006-05-26 03:47:05 +02:00
|
|
|
*/
|
2008-04-18 12:41:44 +02:00
|
|
|
class vfs_webdav_server extends HTTP_WebDAV_Server_Filesystem
|
2006-05-26 03:47:05 +02:00
|
|
|
{
|
2008-05-13 10:34:19 +02:00
|
|
|
/**
|
|
|
|
* Realm of eGW's WebDAV server
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
const REALM = 'eGroupWare WebDAV server';
|
|
|
|
var $dav_powered_by = self::REALM;
|
2008-05-20 07:16:49 +02:00
|
|
|
var $http_auth_realm = self::REALM;
|
2008-04-18 12:41:44 +02:00
|
|
|
|
2007-04-29 14:06:17 +02:00
|
|
|
/**
|
2008-02-18 07:43:49 +01:00
|
|
|
* Base directory is the URL of our VFS root
|
2007-04-29 14:06:17 +02:00
|
|
|
*
|
2008-02-18 07:43:49 +01:00
|
|
|
* @var string
|
2007-04-29 14:06:17 +02:00
|
|
|
*/
|
2008-04-14 07:52:24 +02:00
|
|
|
var $base = egw_vfs::PREFIX;
|
2008-04-18 12:41:44 +02:00
|
|
|
|
2006-06-23 19:25:02 +02:00
|
|
|
/**
|
2006-06-23 19:43:07 +02:00
|
|
|
* Debug level: 0 = nothing, 1 = function calls, 2 = more info, eg. complete $_SERVER array
|
2008-04-18 12:41:44 +02:00
|
|
|
*
|
2006-06-23 19:25:02 +02:00
|
|
|
* The debug messages are send to the apache error_log
|
|
|
|
*
|
|
|
|
* @var integer
|
|
|
|
*/
|
2006-06-23 19:43:07 +02:00
|
|
|
var $debug = 0;
|
2006-05-26 03:47:05 +02:00
|
|
|
|
|
|
|
/**
|
2008-02-18 07:43:49 +01:00
|
|
|
* Serve a webdav request
|
2008-04-18 12:41:44 +02:00
|
|
|
*
|
2008-02-18 07:43:49 +01:00
|
|
|
* Reimplemented to not check our vfs base path with realpath and connect to mysql DB
|
|
|
|
*
|
|
|
|
* @access public
|
2008-04-18 12:41:44 +02:00
|
|
|
* @param string
|
2008-02-18 07:43:49 +01:00
|
|
|
*/
|
2008-04-18 12:41:44 +02:00
|
|
|
function ServeRequest($base = false)
|
2006-05-26 03:47:05 +02:00
|
|
|
{
|
2008-02-18 07:43:49 +01:00
|
|
|
// special treatment for litmus compliance test
|
|
|
|
// reply on its identifier header
|
|
|
|
// not needed for the test itself but eases debugging
|
2008-04-18 12:41:44 +02:00
|
|
|
if (function_exists('apache_request_headers'))
|
2006-05-26 03:47:05 +02:00
|
|
|
{
|
2008-04-18 12:41:44 +02:00
|
|
|
foreach (apache_request_headers() as $key => $value)
|
2006-06-23 19:25:02 +02:00
|
|
|
{
|
2008-05-01 13:44:55 +02:00
|
|
|
if (stristr($key, 'litmus'))
|
2008-04-18 12:41:44 +02:00
|
|
|
{
|
|
|
|
error_log("Litmus test $value");
|
2008-05-01 13:44:55 +02:00
|
|
|
header('X-Litmus-reply: '.$value);
|
2008-04-18 12:41:44 +02:00
|
|
|
}
|
2006-06-23 19:25:02 +02:00
|
|
|
}
|
2006-05-26 03:47:05 +02:00
|
|
|
}
|
2008-02-18 07:43:49 +01:00
|
|
|
// let the base class do all the work
|
|
|
|
HTTP_WebDAV_Server::ServeRequest();
|
2006-05-26 03:47:05 +02:00
|
|
|
}
|
2008-04-18 12:41:44 +02:00
|
|
|
|
2008-05-01 13:44:55 +02:00
|
|
|
/**
|
|
|
|
* DELETE method handler
|
|
|
|
*
|
|
|
|
* @param array general parameter passing array
|
|
|
|
* @return bool true on success
|
|
|
|
*/
|
|
|
|
function DELETE($options)
|
|
|
|
{
|
|
|
|
$path = $this->base . $options['path'];
|
2006-05-26 03:47:05 +02:00
|
|
|
|
2008-05-01 13:44:55 +02:00
|
|
|
if (!file_exists($path))
|
|
|
|
{
|
|
|
|
return '404 Not found';
|
|
|
|
}
|
2006-05-26 03:47:05 +02:00
|
|
|
|
2008-05-01 13:44:55 +02:00
|
|
|
if (is_dir($path))
|
|
|
|
{
|
2006-05-26 03:47:05 +02:00
|
|
|
|
2008-05-01 13:44:55 +02:00
|
|
|
/*$query = "DELETE FROM {$this->db_prefix}properties
|
|
|
|
WHERE path LIKE '".$this->_slashify($options["path"])."%'";
|
|
|
|
mysql_query($query); */
|
2008-04-18 12:41:44 +02:00
|
|
|
|
2008-05-01 13:44:55 +02:00
|
|
|
// recursive delete the directory
|
|
|
|
egw_vfs::remove($options['path']);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
unlink($path);
|
|
|
|
}
|
|
|
|
/*$query = "DELETE FROM {$this->db_prefix}properties
|
|
|
|
WHERE path = '$options[path]'";
|
|
|
|
mysql_query($query);*/
|
2008-04-18 12:41:44 +02:00
|
|
|
|
2008-05-01 13:44:55 +02:00
|
|
|
return '204 No Content';
|
|
|
|
}
|
2008-02-18 07:43:49 +01:00
|
|
|
|
2009-04-30 09:43:21 +02:00
|
|
|
/**
|
|
|
|
* COPY method handler
|
|
|
|
*
|
|
|
|
* @param array general parameter passing array
|
|
|
|
* @return bool true on success
|
|
|
|
*/
|
|
|
|
function COPY($options, $del=false)
|
|
|
|
{
|
|
|
|
// TODO Property updates still broken (Litmus should detect this?)
|
|
|
|
|
|
|
|
if (!empty($this->_SERVER["CONTENT_LENGTH"])) { // no body parsing yet
|
|
|
|
return "415 Unsupported media type";
|
|
|
|
}
|
|
|
|
|
|
|
|
// no copying to different WebDAV Servers yet
|
|
|
|
if (isset($options["dest_url"])) {
|
|
|
|
return "502 bad gateway";
|
|
|
|
}
|
|
|
|
|
|
|
|
$source = $this->base .$options["path"];
|
|
|
|
if (!file_exists($source)) return "404 Not found";
|
|
|
|
|
|
|
|
$dest = $this->base . $options["dest"];
|
|
|
|
$new = !file_exists($dest);
|
|
|
|
$existing_col = false;
|
|
|
|
|
|
|
|
if (!$new) {
|
|
|
|
if ($del && is_dir($dest)) {
|
|
|
|
if (!$options["overwrite"]) {
|
|
|
|
return "412 precondition failed";
|
|
|
|
}
|
|
|
|
$dest .= basename($source);
|
|
|
|
if (file_exists($dest)) {
|
|
|
|
$options["dest"] .= basename($source);
|
|
|
|
} else {
|
|
|
|
$new = true;
|
|
|
|
$existing_col = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!$new) {
|
|
|
|
if ($options["overwrite"]) {
|
|
|
|
$stat = $this->DELETE(array("path" => $options["dest"]));
|
|
|
|
if (($stat{0} != "2") && (substr($stat, 0, 3) != "404")) {
|
|
|
|
return $stat;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return "412 precondition failed";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (is_dir($source) && ($options["depth"] != "infinity")) {
|
|
|
|
// RFC 2518 Section 9.2, last paragraph
|
|
|
|
return "400 Bad request";
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($del) {
|
|
|
|
if (!rename($source, $dest)) {
|
|
|
|
return "500 Internal server error";
|
|
|
|
}
|
|
|
|
$destpath = $this->_unslashify($options["dest"]);
|
|
|
|
/*
|
|
|
|
if (is_dir($source)) {
|
|
|
|
$query = "UPDATE {$this->db_prefix}properties
|
|
|
|
SET path = REPLACE(path, '".$options["path"]."', '".$destpath."')
|
|
|
|
WHERE path LIKE '".$this->_slashify($options["path"])."%'";
|
|
|
|
mysql_query($query);
|
|
|
|
}
|
|
|
|
|
|
|
|
$query = "UPDATE {$this->db_prefix}properties
|
|
|
|
SET path = '".$destpath."'
|
|
|
|
WHERE path = '".$options["path"]."'";
|
|
|
|
mysql_query($query);
|
|
|
|
*/
|
|
|
|
} else {
|
|
|
|
if (is_dir($source)) {
|
|
|
|
$files = System::find($source);
|
|
|
|
$files = array_reverse($files);
|
|
|
|
} else {
|
|
|
|
$files = array($source);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!is_array($files) || empty($files)) {
|
|
|
|
return "500 Internal server error";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
foreach ($files as $file) {
|
|
|
|
if (is_dir($file)) {
|
|
|
|
$file = $this->_slashify($file);
|
|
|
|
}
|
|
|
|
|
|
|
|
$destfile = str_replace($source, $dest, $file);
|
|
|
|
|
|
|
|
if (is_dir($file)) {
|
|
|
|
if (!is_dir($destfile)) {
|
|
|
|
// TODO "mkdir -p" here? (only natively supported by PHP 5)
|
|
|
|
if (!@mkdir($destfile)) {
|
|
|
|
return "409 Conflict";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (!@copy($file, $destfile)) {
|
|
|
|
return "409 Conflict";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
$query = "INSERT INTO {$this->db_prefix}properties
|
|
|
|
SELECT *
|
|
|
|
FROM {$this->db_prefix}properties
|
|
|
|
WHERE path = '".$options['path']."'";
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
// adding Location header as shown in example in rfc2518 section 8.9.5
|
|
|
|
header('Location: '.$this->base_uri.$options['dest']);
|
|
|
|
|
|
|
|
return ($new && !$existing_col) ? "201 Created" : "204 No Content";
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2008-05-01 13:44:55 +02:00
|
|
|
* Get properties for a single file/resource
|
|
|
|
*
|
|
|
|
* @param string resource path
|
|
|
|
* @return array resource properties
|
|
|
|
*/
|
|
|
|
function fileinfo($path)
|
|
|
|
{
|
|
|
|
//error_log(__METHOD__."($path)");
|
|
|
|
// map URI path to filesystem path
|
|
|
|
$fspath = $this->base . $path;
|
|
|
|
|
|
|
|
// create result array
|
|
|
|
$info = array();
|
|
|
|
// TODO remove slash append code when base class is able to do it itself
|
|
|
|
$info['path'] = is_dir($fspath) ? $this->_slashify($path) : $path;
|
|
|
|
$info['props'] = array();
|
|
|
|
|
|
|
|
// no special beautified displayname here ...
|
2008-11-15 08:46:59 +01:00
|
|
|
$info['props'][] = HTTP_WebDAV_Server::mkprop ('displayname', egw_vfs::basename(self::_unslashify($path)));
|
2008-05-01 13:44:55 +02:00
|
|
|
|
|
|
|
// creation and modification time
|
|
|
|
$info['props'][] = HTTP_WebDAV_Server::mkprop ('creationdate', filectime($fspath));
|
|
|
|
$info['props'][] = HTTP_WebDAV_Server::mkprop ('getlastmodified', filemtime($fspath));
|
|
|
|
|
|
|
|
// type and size (caller already made sure that path exists)
|
|
|
|
if (is_dir($fspath)) {
|
|
|
|
// directory (WebDAV collection)
|
|
|
|
$info['props'][] = HTTP_WebDAV_Server::mkprop ('resourcetype', 'collection');
|
|
|
|
$info['props'][] = HTTP_WebDAV_Server::mkprop ('getcontenttype', 'httpd/unix-directory');
|
|
|
|
} else {
|
|
|
|
// plain file (WebDAV resource)
|
|
|
|
$info['props'][] = HTTP_WebDAV_Server::mkprop ('resourcetype', '');
|
|
|
|
if (egw_vfs::is_readable($path)) {
|
|
|
|
$info['props'][] = HTTP_WebDAV_Server::mkprop ('getcontenttype', egw_vfs::mime_content_type($path));
|
|
|
|
} else {
|
2008-02-18 07:43:49 +01:00
|
|
|
error_log(__METHOD__."($path) $fspath is not readable!");
|
2008-05-01 13:44:55 +02:00
|
|
|
$info['props'][] = HTTP_WebDAV_Server::mkprop ('getcontenttype', 'application/x-non-readable');
|
|
|
|
}
|
|
|
|
$info['props'][] = HTTP_WebDAV_Server::mkprop ('getcontentlength', filesize($fspath));
|
|
|
|
}
|
2008-05-13 15:13:38 +02:00
|
|
|
/* returning the supportedlock property causes Windows DAV provider and Konqueror to not longer work
|
2008-05-20 07:16:49 +02:00
|
|
|
ToDo: return it only if explicitly requested ($options['props'])
|
2008-05-01 13:44:55 +02:00
|
|
|
// supportedlock property
|
|
|
|
$info['props'][] = HTTP_WebDAV_Server::mkprop('supportedlock','
|
|
|
|
<D:lockentry>
|
|
|
|
<D:lockscope><D:exclusive/></D:lockscope>
|
|
|
|
<D:locktype><D:write/></D:lockscope>
|
|
|
|
</D:lockentry>
|
|
|
|
<D:lockentry>
|
|
|
|
<D:lockscope><D:shared/></D:lockscope>
|
|
|
|
<D:locktype><D:write/></D:lockscope>
|
|
|
|
</D:lockentry>');
|
2008-05-13 15:13:38 +02:00
|
|
|
*/
|
2008-05-01 13:44:55 +02:00
|
|
|
// ToDo: etag from inode and modification time
|
|
|
|
|
2008-02-18 07:43:49 +01:00
|
|
|
//error_log(__METHOD__."($path) info=".print_r($info,true));
|
2008-05-01 13:44:55 +02:00
|
|
|
return $info;
|
|
|
|
}
|
2006-05-26 03:47:05 +02:00
|
|
|
|
|
|
|
/**
|
2008-10-05 21:01:49 +02:00
|
|
|
* PROPFIND method handler
|
|
|
|
*
|
|
|
|
* Reimplemented to fetch all extra property of a PROPFIND request in one go.
|
|
|
|
*
|
|
|
|
* @param array general parameter passing array
|
|
|
|
* @param array return array for file properties
|
|
|
|
* @return bool true on success
|
|
|
|
*/
|
|
|
|
function PROPFIND(&$options, &$files)
|
|
|
|
{
|
|
|
|
if (!parent::PROPFIND($options,$files))
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
$path2n = array();
|
|
|
|
foreach($files['files'] as $n => $info)
|
|
|
|
{
|
|
|
|
if (!$n && substr($info['path'],-1) == '/')
|
|
|
|
{
|
|
|
|
$path2n[substr($info['path'],0,-1)] = $n;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$path2n[$info['path']] = $n;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($path2n && ($path2props = egw_vfs::propfind(array_keys($path2n),null)))
|
|
|
|
{
|
|
|
|
foreach($path2props as $path => $props)
|
|
|
|
{
|
|
|
|
$fileprops =& $files['files'][$path2n[$path]]['props'];
|
|
|
|
foreach($props as $prop)
|
|
|
|
{
|
|
|
|
if ($prop['ns'] == egw_vfs::DEFAULT_PROP_NAMESPACE && $prop['name'][0] == '#') // eGW's customfields
|
|
|
|
{
|
|
|
|
$prop['ns'] .= 'customfields/';
|
|
|
|
$prop['name'] = substr($prop['name'],1);
|
|
|
|
}
|
|
|
|
$fileprops[] = $prop;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2008-02-18 07:43:49 +01:00
|
|
|
* Used eg. by get
|
2006-05-26 03:47:05 +02:00
|
|
|
*
|
2008-02-18 07:43:49 +01:00
|
|
|
* @todo replace all calls to _mimetype with egw_vfs::mime_content_type()
|
|
|
|
* @param string $path
|
|
|
|
* @return string
|
2006-05-26 03:47:05 +02:00
|
|
|
*/
|
2008-02-18 07:43:49 +01:00
|
|
|
function _mimetype($path)
|
2006-05-26 03:47:05 +02:00
|
|
|
{
|
2008-02-18 07:43:49 +01:00
|
|
|
return egw_vfs::mime_content_type($path);
|
2006-05-26 03:47:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2008-01-15 04:49:18 +01:00
|
|
|
* PROPPATCH method handler
|
2008-04-18 12:41:44 +02:00
|
|
|
*
|
2008-01-15 04:49:18 +01:00
|
|
|
* The current version only allows Webdrive to set creation and modificaton dates.
|
|
|
|
* They are not stored as (arbitrary) WebDAV properties with their own namespace and name,
|
|
|
|
* but in the regular vfs attributes.
|
|
|
|
*
|
|
|
|
* @todo Store a properties in the DB and retrieve them in PROPFIND again.
|
|
|
|
* @param array general parameter passing array
|
|
|
|
* @return bool true on success
|
|
|
|
*/
|
2008-04-18 12:41:44 +02:00
|
|
|
function PROPPATCH(&$options)
|
2008-01-15 04:49:18 +01:00
|
|
|
{
|
2008-02-18 07:43:49 +01:00
|
|
|
$path = $GLOBALS['egw']->translation->convert($options['path'],'utf-8');
|
|
|
|
|
2008-05-01 13:44:55 +02:00
|
|
|
foreach ($options['props'] as $key => $prop) {
|
2008-01-17 06:40:38 +01:00
|
|
|
$attributes = array();
|
|
|
|
switch($prop['ns'])
|
|
|
|
{
|
|
|
|
// allow Webdrive to set creation and modification time
|
|
|
|
case 'http://www.southrivertech.com/':
|
|
|
|
switch($prop['name'])
|
|
|
|
{
|
|
|
|
case 'srt_modifiedtime':
|
|
|
|
case 'getlastmodified':
|
2008-02-18 07:43:49 +01:00
|
|
|
egw_vfs::touch($path,strtotime($prop['val']));
|
2008-01-17 06:40:38 +01:00
|
|
|
break;
|
2008-10-05 21:01:49 +02:00
|
|
|
//case 'srt_creationtime':
|
2008-02-18 07:43:49 +01:00
|
|
|
// not supported via the streamwrapper interface atm.
|
|
|
|
//$attributes['created'] = strtotime($prop['val']);
|
2008-10-05 21:01:49 +02:00
|
|
|
//break;
|
|
|
|
default:
|
|
|
|
if (!egw_vfs::proppatch($path,array($prop))) $options['props'][$key]['status'] = '403 Forbidden';
|
2008-01-17 06:40:38 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2008-04-18 12:41:44 +02:00
|
|
|
|
2008-01-17 06:40:38 +01:00
|
|
|
case 'DAV:':
|
|
|
|
switch($prop['name'])
|
|
|
|
{
|
|
|
|
// allow netdrive to change the modification time
|
|
|
|
case 'getlastmodified':
|
2008-02-18 07:43:49 +01:00
|
|
|
egw_vfs::touch($path,strtotime($prop['val']));
|
2008-01-17 06:40:38 +01:00
|
|
|
break;
|
|
|
|
// not sure why, the filesystem example of the WebDAV class does it ...
|
|
|
|
default:
|
2008-05-01 13:44:55 +02:00
|
|
|
$options['props'][$key]['status'] = '403 Forbidden';
|
2008-01-17 06:40:38 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2008-10-05 21:01:49 +02:00
|
|
|
|
|
|
|
case egw_vfs::DEFAULT_PROP_NAMESPACE.'customfields/': // eGW's customfields
|
|
|
|
$prop['ns'] = egw_vfs::DEFAULT_PROP_NAMESPACE;
|
|
|
|
$prop['name'] = '#'.$prop['name'];
|
|
|
|
// fall through
|
|
|
|
default:
|
|
|
|
if (!egw_vfs::proppatch($path,array($prop))) $options['props'][$key]['status'] = '403 Forbidden';
|
|
|
|
break;
|
2008-01-15 04:49:18 +01:00
|
|
|
}
|
2008-05-01 13:44:55 +02:00
|
|
|
if ($this->debug) $props[] = '('.$prop['ns'].')'.$prop['name'].'='.$prop['val'];
|
2008-01-15 04:49:18 +01:00
|
|
|
}
|
2008-01-17 06:40:38 +01:00
|
|
|
if ($this->debug)
|
|
|
|
{
|
2008-02-18 07:43:49 +01:00
|
|
|
error_log(__METHOD__.": path=$options[path], props=".implode(', ',$props));
|
|
|
|
if ($attributes) error_log(__METHOD__.": path=$options[path], set attributes=".str_replace("\n",' ',print_r($attributes,true)));
|
2008-01-17 06:40:38 +01:00
|
|
|
}
|
|
|
|
|
2008-05-01 13:44:55 +02:00
|
|
|
return ''; // this is as the filesystem example handler does it, no true or false ...
|
2008-01-15 04:49:18 +01:00
|
|
|
}
|
2008-04-18 12:41:44 +02:00
|
|
|
|
2008-05-01 13:44:55 +02:00
|
|
|
/**
|
2008-05-08 22:33:09 +02:00
|
|
|
* LOCK method handler
|
|
|
|
*
|
|
|
|
* @param array general parameter passing array
|
|
|
|
* @return bool true on success
|
|
|
|
*/
|
2008-05-01 13:44:55 +02:00
|
|
|
function LOCK(&$options)
|
|
|
|
{
|
2008-10-05 21:01:49 +02:00
|
|
|
if ($this->debug) error_log(__METHOD__.'('.str_replace(array("\n",' '),'',print_r($options,true)).')');
|
2008-05-08 22:33:09 +02:00
|
|
|
// TODO recursive locks on directories not supported yet
|
2008-05-01 13:44:55 +02:00
|
|
|
if (is_dir($this->base . $options['path']) && !empty($options['depth']))
|
2008-05-08 22:33:09 +02:00
|
|
|
{
|
|
|
|
return '409 Conflict';
|
|
|
|
}
|
|
|
|
$options['timeout'] = time()+300; // 5min. hardcoded
|
2008-05-01 13:44:55 +02:00
|
|
|
|
2008-05-08 22:33:09 +02:00
|
|
|
// dont know why, but HTTP_WebDAV_Server passes the owner in D:href tags, which get's passed unchanged to checkLock/PROPFIND
|
|
|
|
// that's wrong according to the standard and cadaver does not show it on discover --> strip_tags removes eventual tags
|
|
|
|
if (($ret = egw_vfs::lock($options['path'],$options['locktoken'],$options['timeout'],strip_tags($options['owner']),
|
|
|
|
$options['scope'],$options['type'],isset($options['update']))) && !isset($options['update']))
|
|
|
|
{
|
|
|
|
return $ret ? '200 OK' : '409 Conflict';
|
|
|
|
}
|
|
|
|
return $ret;
|
2008-05-01 13:44:55 +02:00
|
|
|
}
|
2008-02-18 07:43:49 +01:00
|
|
|
|
2008-05-01 13:44:55 +02:00
|
|
|
/**
|
2008-05-08 22:33:09 +02:00
|
|
|
* UNLOCK method handler
|
|
|
|
*
|
|
|
|
* @param array general parameter passing array
|
|
|
|
* @return bool true on success
|
|
|
|
*/
|
2008-05-01 13:44:55 +02:00
|
|
|
function UNLOCK(&$options)
|
|
|
|
{
|
2008-10-05 21:01:49 +02:00
|
|
|
if ($this->debug) error_log(__METHOD__.'('.str_replace(array("\n",' '),'',print_r($options,true)).')');
|
2008-05-01 13:44:55 +02:00
|
|
|
return egw_vfs::unlock($options['path'],$options['token']) ? '204 No Content' : '409 Conflict';
|
|
|
|
}
|
2008-04-18 12:41:44 +02:00
|
|
|
|
2008-05-01 13:44:55 +02:00
|
|
|
/**
|
2008-05-08 22:33:09 +02:00
|
|
|
* checkLock() helper
|
|
|
|
*
|
|
|
|
* @param string resource path to check for locks
|
|
|
|
* @return bool true on success
|
|
|
|
*/
|
2008-05-01 13:44:55 +02:00
|
|
|
function checkLock($path)
|
|
|
|
{
|
2008-05-08 22:33:09 +02:00
|
|
|
return egw_vfs::checkLock($path);
|
2008-05-01 13:44:55 +02:00
|
|
|
}
|
2006-05-26 03:47:05 +02:00
|
|
|
}
|