diff --git a/api/js/etemplate/et2_widget_link.js b/api/js/etemplate/et2_widget_link.js index 7097580789f..ca447da9728 100644 --- a/api/js/etemplate/et2_widget_link.js +++ b/api/js/etemplate/et2_widget_link.js @@ -1710,7 +1710,12 @@ var et2_link_list = (function(){ "use strict"; return et2_link_string.extend( if(link_data.app == 'file') { // File info is always the same - var url = '/apps/'+link_data.app2+'/'+link_data.id2+'/'+decodeURIComponent(link_data.id); + var path = { + id: decodeURIComponent(link_data.id), + id2: link_data.id2, + app2: link_data.app2, + } + var url = self.egw().getVfsPath( path ); if(typeof url == 'string' && url.indexOf('webdav.php')) { // URL is url to file in webdav, so get rid of that part diff --git a/api/js/jsapi/egw_links.js b/api/js/jsapi/egw_links.js index c783d595702..c498914d7ab 100644 --- a/api/js/jsapi/egw_links.js +++ b/api/js/jsapi/egw_links.js @@ -146,7 +146,7 @@ egw.extend('links', egw.MODULE_GLOBAL, function() { if (typeof _path.path == 'undefined') { - path = '/apps/'+_path.app2+'/'+_path.id2+'/'+_path.id; + path = this.getVfsPath( _path ); } else { @@ -492,6 +492,17 @@ egw.extend('links', egw.MODULE_GLOBAL, function() select.append(option); } }); - } + },+ + /** + * Get Vfs Path + * + * @param object _path + * @returns string vfs path + */ + getVfsPath: function( _path ) + { + var req = this.json('EGroupware\\Api\\Link::ajax_vfs_path',[_path],null,this,false).sendRequest(); + return req.responseJSON.response[0].data; + }, }; }); diff --git a/api/src/Link.php b/api/src/Link.php index 89ab367c5ec..5ba193cea88 100644 --- a/api/src/Link.php +++ b/api/src/Link.php @@ -1128,6 +1128,19 @@ static function get_registry($app,$name) return isset($reg) ? $reg[$name] : false; } + /** + * Ajax function to access vfs_path + * + * @param array $_path + * @return string path + */ + public static function ajax_vfs_path( $_path ) + { + $path = self::vfs_path( $_path['app2'], $_path['id2'], $_path['id'], true ); + $response = Json\Response::get(); + $response->data( $path ); + } + /** * path to the attached files of $app/$ip or the directory for $app if no $id,$file given * @@ -1145,23 +1158,38 @@ static function vfs_path($app,$id='',$file='',$just_the_path=false) if ($app) { - if( isset(self::$app_register[$app]) ) { + if( isset(self::$app_register[$app]) ) + { $reg = self::$app_register[$app]; - if( isset($reg['file_dir']) ) { + if( isset($reg['file_dir']) ) + { $app = $reg['file_dir']; } } - $path .= '/'.$app; - - if ($id) + if ( Hooks::exists( 'vfs_create_structure', $app ) ) { - $path .= '/'.$id; - - if ($file) + $hook = Hooks::process( array( + 'location' => 'vfs_create_structure', + 'app' => $app, + 'path' => $path, + 'id' => $id, + 'file' => $file, + )); + $path = $hook[ $app ]; + } + else + { + $path .= '/'.$app; + if ($id) { - $path .= '/'.$file; + $path .= '/'.$id; + + if ($file) + { + $path .= '/'.$file; + } } } } diff --git a/api/src/Vfs/Links/StreamWrapper.php b/api/src/Vfs/Links/StreamWrapper.php index 90f5bd474b8..0669b72ba11 100644 --- a/api/src/Vfs/Links/StreamWrapper.php +++ b/api/src/Vfs/Links/StreamWrapper.php @@ -86,6 +86,18 @@ static function check_extended_acl($url,$check) list(,$apps,$app,$id,$rel_path) = explode('/',$path,5); + if ( Api\Hooks::exists( 'vfs_read_structure', $app ) ) + { + $hook = Api\Hooks::process( array( + 'location' => 'vfs_read_structure', + 'url' => $url, + 'app' => $app, + 'id' => $id, + 'rel_path' => $rel_path, + )); + $id = $hook[ $app ]; + } + if ($apps != 'apps') { $access = false; // no access to anything, but /apps