From 4328a0c9064a282befa4e0db3fe21792cf85b028 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Thu, 2 Oct 2008 11:04:51 +0000 Subject: [PATCH] Fixed links stream wrapper and link class, to work with storage=db --- phpgwapi/inc/class.egw_link.inc.php | 14 ++++++++++---- phpgwapi/inc/class.links_stream_wrapper.inc.php | 8 +++++--- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/phpgwapi/inc/class.egw_link.inc.php b/phpgwapi/inc/class.egw_link.inc.php index f431f438c4..13ed5fc72c 100644 --- a/phpgwapi/inc/class.egw_link.inc.php +++ b/phpgwapi/inc/class.egw_link.inc.php @@ -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 "

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'

\n"; + echo "

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'

\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 diff --git a/phpgwapi/inc/class.links_stream_wrapper.inc.php b/phpgwapi/inc/class.links_stream_wrapper.inc.php index 6b6ad261c0..c4e9963cb9 100644 --- a/phpgwapi/inc/class.links_stream_wrapper.inc.php +++ b/phpgwapi/inc/class.links_stream_wrapper.inc.php @@ -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;