Fixed links stream wrapper and link class, to work with storage=db

This commit is contained in:
Ralf Becker 2008-10-02 11:04:51 +00:00
parent 7ac2a20db3
commit 4328a0c906
2 changed files with 15 additions and 7 deletions

View File

@ -67,6 +67,10 @@ class egw_link extends solink
* appname used for returned attached files (!= 'filemanager'!)
*/
const VFS_APPNAME = 'file'; // pseudo-appname for own file-attachments in vfs, this is NOT the vfs-app
/**
* Baseurl for the attachments in the vfs
*/
const VFS_BASEURL = 'vfs://default/apps';
/**
* Turns on debug-messages
*/
@ -704,7 +708,8 @@ class egw_link extends solink
*/
static function vfs_path($app,$id='',$file='')
{
$path = links_stream_wrapper::BASEURL;
$path = self::VFS_BASEURL;
if ($app)
{
$path .= '/'.$app;
@ -719,6 +724,7 @@ class egw_link extends solink
}
}
}
$path = egw_vfs::resolve_url($path);
//error_log(__METHOD__."($app,$id,$file)=$path");
return $path;
}
@ -740,14 +746,14 @@ class egw_link extends solink
*/
static function attach_file($app,$id,$file,$comment='')
{
$entry_dir = self::vfs_path($app,$id);
if (self::DEBUG)
{
echo "<p>attach_file: app='$app', id='$id', tmp_name='$file[tmp_name]', name='$file[name]', size='$file[size]', type='$file[type]', path='$file[path]', ip='$file[ip]', comment='$comment'</p>\n";
echo "<p>attach_file: app='$app', id='$id', tmp_name='$file[tmp_name]', name='$file[name]', size='$file[size]', type='$file[type]', path='$file[path]', ip='$file[ip]', comment='$comment', entry_dir='$entry_dir'</p>\n";
}
$entry_dir = self::vfs_path($app,$id);
if (file_exists($entry_dir) || ($Ok = mkdir($entry_dir,0,true)))
{
$Ok = copy($file['tmp_name'],$fname = $entry_dir.'/'.$file['name']) &&
$Ok = copy($file['tmp_name'],$fname = egw_vfs::concat($entry_dir,$file['name'])) &&
($stat = links_stream_wrapper::url_stat($fname,0));
}
else

View File

@ -164,9 +164,11 @@ class links_stream_wrapper extends sqlfs_stream_wrapper
*/
static function mkdir($path,$mode,$options)
{
if($path[0] != '/') $path = parse_url($path,PHP_URL_PATH);
if($path[0] != '/')
{
if (strpos($path,'?') !== false) $query = parse_url($path,PHP_URL_QUERY);
$path = parse_url($path,PHP_URL_PATH).($query ? '?'.$query : '');
}
list(,$apps,$app,$id,$rel_path) = explode('/',$path,5);
$ret = false;