mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-06-20 01:48:01 +02:00
File a file link via ajax
This commit is contained in:
parent
727cdc83b3
commit
4cc524dedd
@ -1233,6 +1233,7 @@ class filemanager_ui
|
|||||||
|
|
||||||
$arr = array(
|
$arr = array(
|
||||||
'msg' => '',
|
'msg' => '',
|
||||||
|
'action' => $action,
|
||||||
'errs' => 0,
|
'errs' => 0,
|
||||||
'dirs' => 0,
|
'dirs' => 0,
|
||||||
'files' => 0,
|
'files' => 0,
|
||||||
@ -1301,11 +1302,31 @@ class filemanager_ui
|
|||||||
$arr['props'] = $props;
|
$arr['props'] = $props;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
// Upload, then link
|
||||||
|
case 'link':
|
||||||
|
// First upload
|
||||||
|
$arr = self::ajax_action('upload', $selected, $dir, $props);
|
||||||
|
$app_dir = egw_link::vfs_path($props['entry']['app'],$props['entry']['id'],'',true);
|
||||||
|
|
||||||
|
foreach($arr['uploaded'] as $file)
|
||||||
|
{
|
||||||
|
$target=egw_vfs::concat($dir,egw_vfs::encodePathComponent($file['name']));
|
||||||
|
if (egw_vfs::file_exists($target) && $app_dir)
|
||||||
|
{
|
||||||
|
if (!egw_vfs::file_exists($app_dir)) egw_vfs::mkdir($app_dir);
|
||||||
|
error_log("Symlinking $target to $app_dir");
|
||||||
|
egw_vfs::symlink($target, egw_vfs::concat($app_dir,egw_vfs::encodePathComponent($file['name'])));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Must return to avoid adding to $response again
|
||||||
|
return;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
$arr['msg'] = self::action($action, $selected, $dir, $arr['errs'], $arr['dirs'], $arr['files']);
|
$arr['msg'] = self::action($action, $selected, $dir, $arr['errs'], $arr['dirs'], $arr['files']);
|
||||||
}
|
}
|
||||||
$response->data($arr);
|
$response->data($arr);
|
||||||
//error_log(__METHOD__."('$action',".array2string($selected).') returning '.array2string($arr));
|
//error_log(__METHOD__."('$action',".array2string($selected).') returning '.array2string($arr));
|
||||||
|
return $arr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -215,9 +215,22 @@ app.classes.filemanager = AppJS.extend(
|
|||||||
}
|
}
|
||||||
|
|
||||||
var props = widget.getInstanceManager().getValues(widget.getRoot());
|
var props = widget.getInstanceManager().getValues(widget.getRoot());
|
||||||
egw.json('filemanager_ui::ajax_action', ['upload', widget.getValue(), path, props],
|
egw.json('filemanager_ui::ajax_action', [action == 'save_as' ? 'upload' : 'link', widget.getValue(), path, props],
|
||||||
app.filemanager._upload_callback, app.filemanager, true, this
|
function(_data)
|
||||||
).sendRequest(true);
|
{
|
||||||
|
app.filemanager._upload_callback(_data);
|
||||||
|
|
||||||
|
// Remove successful after a delay
|
||||||
|
for(var file in _data.uploaded)
|
||||||
|
{
|
||||||
|
if(!_data.uploaded[file].confirm || _data.uploaded[file].confirmed)
|
||||||
|
{
|
||||||
|
// Remove that file from file widget...
|
||||||
|
widget.remove_file(_data.uploaded[file].name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, app.filemanager, true, this
|
||||||
|
).sendRequest(true);
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -257,7 +270,7 @@ app.classes.filemanager = AppJS.extend(
|
|||||||
uploaded[this.my_data.file].name = _value;
|
uploaded[this.my_data.file].name = _value;
|
||||||
delete uploaded[this.my_data.file].confirm;
|
delete uploaded[this.my_data.file].confirm;
|
||||||
// send overwrite-confirmation and/or rename request to server
|
// send overwrite-confirmation and/or rename request to server
|
||||||
egw.json('filemanager_ui::ajax_action', ['upload', uploaded, this.my_data.path, this.my_data.props],
|
egw.json('filemanager_ui::ajax_action', [this.my_data.action, uploaded, this.my_data.path, this.my_data.props],
|
||||||
that._upload_callback, that, true, that
|
that._upload_callback, that, true, that
|
||||||
).sendRequest();
|
).sendRequest();
|
||||||
return;
|
return;
|
||||||
@ -275,6 +288,7 @@ app.classes.filemanager = AppJS.extend(
|
|||||||
_data.uploaded[file].name, buttons, file);
|
_data.uploaded[file].name, buttons, file);
|
||||||
// setting required data for callback in as my_data
|
// setting required data for callback in as my_data
|
||||||
dialog.my_data = {
|
dialog.my_data = {
|
||||||
|
action: _data.action,
|
||||||
file: file,
|
file: file,
|
||||||
path: _data.path,
|
path: _data.path,
|
||||||
data: _data.uploaded[file],
|
data: _data.uploaded[file],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user