forked from extern/egroupware
Some modifications required by CalDAV
This commit is contained in:
parent
d2e9143213
commit
6587e340fc
@ -968,7 +968,7 @@ class egw_vfs extends vfs_stream_wrapper
|
||||
* lock a ressource/path
|
||||
*
|
||||
* @param string $path path or url
|
||||
* @param string $token
|
||||
* @param string &$token
|
||||
* @param int &$timeout
|
||||
* @param string &$owner
|
||||
* @param string &$scope
|
||||
@ -977,7 +977,7 @@ class egw_vfs extends vfs_stream_wrapper
|
||||
* @param boolean $check_writable=true should we check if the ressource is writable, before granting locks, default yes
|
||||
* @return boolean true on success
|
||||
*/
|
||||
function lock($path,$token,&$timeout,&$owner,&$scope,&$type,$update=false,$check_writable=true)
|
||||
static function lock($path,&$token,&$timeout,&$owner,&$scope,&$type,$update=false,$check_writable=true)
|
||||
{
|
||||
// we require write rights to lock/unlock a resource
|
||||
if (!$path || $update && !$token || $check_writable && !egw_vfs::is_writable($path))
|
||||
@ -987,6 +987,11 @@ class egw_vfs extends vfs_stream_wrapper
|
||||
// remove the lock info evtl. set in the cache
|
||||
unset(self::$lock_cache[$path]);
|
||||
|
||||
if ($timeout < 1000000) // < 1000000 is a relative timestamp, so we add the current time
|
||||
{
|
||||
$timeout += time();
|
||||
}
|
||||
|
||||
if ($update) // Lock Update
|
||||
{
|
||||
if (($ret = (boolean)($row = self::$db->select(self::LOCK_TABLE,array('lock_owner','lock_exclusive','lock_write'),array(
|
||||
@ -1021,6 +1026,7 @@ class egw_vfs extends vfs_stream_wrapper
|
||||
}
|
||||
if (!$token)
|
||||
{
|
||||
require_once('HTTP/WebDAV/Server.php');
|
||||
$token = HTTP_WebDAV_Server::_new_locktoken();
|
||||
}
|
||||
try {
|
||||
@ -1052,7 +1058,7 @@ class egw_vfs extends vfs_stream_wrapper
|
||||
* @param boolean $check_writable=true should we check if the ressource is writable, before granting locks, default yes
|
||||
* @return boolean true on success
|
||||
*/
|
||||
function unlock($path,$token,$check_writable=true)
|
||||
static function unlock($path,$token,$check_writable=true)
|
||||
{
|
||||
// we require write rights to lock/unlock a resource
|
||||
if ($check_writable && !egw_vfs::is_writable($path))
|
||||
@ -1077,7 +1083,7 @@ class egw_vfs extends vfs_stream_wrapper
|
||||
* @param string resource path to check for locks
|
||||
* @return array|boolean false if there's no lock, else array with lock info
|
||||
*/
|
||||
function checkLock($path)
|
||||
static function checkLock($path)
|
||||
{
|
||||
if (isset(self::$lock_cache[$path]))
|
||||
{
|
||||
@ -1109,6 +1115,18 @@ class egw_vfs extends vfs_stream_wrapper
|
||||
return self::$lock_cache[$path] = $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mapps entries of applications to a path for the locking
|
||||
*
|
||||
* @param string $app
|
||||
* @param int|string $id
|
||||
* @return string
|
||||
*/
|
||||
static function app_entry_lock_path($app,$id)
|
||||
{
|
||||
return "/apps/$app/entry/$id";
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise our static vars
|
||||
*/
|
||||
|
@ -248,37 +248,37 @@ class vfs_webdav_server extends HTTP_WebDAV_Server_Filesystem
|
||||
}
|
||||
|
||||
/**
|
||||
* LOCK method handler
|
||||
*
|
||||
* @param array general parameter passing array
|
||||
* @return bool true on success
|
||||
*/
|
||||
* LOCK method handler
|
||||
*
|
||||
* @param array general parameter passing array
|
||||
* @return bool true on success
|
||||
*/
|
||||
function LOCK(&$options)
|
||||
{
|
||||
error_log(__METHOD__.'('.str_replace(array("\n",' '),'',print_r($options,true)).')');
|
||||
// TODO recursive locks on directories not supported yet
|
||||
// TODO recursive locks on directories not supported yet
|
||||
if (is_dir($this->base . $options['path']) && !empty($options['depth']))
|
||||
{
|
||||
return '409 Conflict';
|
||||
}
|
||||
$options['timeout'] = time()+300; // 5min. hardcoded
|
||||
{
|
||||
return '409 Conflict';
|
||||
}
|
||||
$options['timeout'] = time()+300; // 5min. hardcoded
|
||||
|
||||
// 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;
|
||||
// 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* UNLOCK method handler
|
||||
*
|
||||
* @param array general parameter passing array
|
||||
* @return bool true on success
|
||||
*/
|
||||
* UNLOCK method handler
|
||||
*
|
||||
* @param array general parameter passing array
|
||||
* @return bool true on success
|
||||
*/
|
||||
function UNLOCK(&$options)
|
||||
{
|
||||
error_log(__METHOD__.'('.str_replace(array("\n",' '),'',print_r($options,true)).')');
|
||||
@ -286,13 +286,13 @@ class vfs_webdav_server extends HTTP_WebDAV_Server_Filesystem
|
||||
}
|
||||
|
||||
/**
|
||||
* checkLock() helper
|
||||
*
|
||||
* @param string resource path to check for locks
|
||||
* @return bool true on success
|
||||
*/
|
||||
* checkLock() helper
|
||||
*
|
||||
* @param string resource path to check for locks
|
||||
* @return bool true on success
|
||||
*/
|
||||
function checkLock($path)
|
||||
{
|
||||
return egw_vfs::checkLock($path);
|
||||
return egw_vfs::checkLock($path);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user