Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic Vfs structure #18

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion api/js/etemplate/et2_widget_link.js
Expand Up @@ -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
Expand Down
15 changes: 13 additions & 2 deletions api/js/jsapi/egw_links.js
Expand Up @@ -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
{
Expand Down Expand Up @@ -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;
},
};
});
46 changes: 37 additions & 9 deletions api/src/Link.php
Expand Up @@ -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
*
Expand All @@ -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;
}
}
}
}
Expand Down
12 changes: 12 additions & 0 deletions api/src/Vfs/Links/StreamWrapper.php
Expand Up @@ -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
Expand Down