mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-22 16:03:47 +01:00
use new prompt to allow to rename uploaded file, if it would overwrite an already existing one, also use dialog for delete confirmation
This commit is contained in:
parent
78449edd4c
commit
288469e66c
@ -454,62 +454,6 @@ class filemanager_ui
|
||||
$tpl->exec('filemanager.filemanager_ui.index',$content,$sel_options,$readonlys,array('nm' => $content['nm']));
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a file upload would overwrite an existing file and get a user confirmation in that case
|
||||
*
|
||||
* @param string $id id of the input
|
||||
* @param string|array $names name(s) (incl. client-path) of the file(s) to upload
|
||||
* @param string $dir current vfs directory
|
||||
* @return string xajax output
|
||||
*/
|
||||
static function ajax_check_upload_target($id,$names,$dir)
|
||||
{
|
||||
$response = new xajaxResponse();
|
||||
|
||||
//$response->addAlert(__METHOD__."('$id',".array2string($name).",'$dir')");
|
||||
|
||||
$ask_overwrite = array();
|
||||
foreach((array)$names as $name)
|
||||
{
|
||||
$name = explode('/',str_replace('\\','/',$name)); // in case of win clients
|
||||
$name = array_pop($name);
|
||||
|
||||
// encode chars which special meaning in url/vfs (some like / get removed!)
|
||||
$path = egw_vfs::concat($dir,egw_vfs::encodePathComponent($name));
|
||||
|
||||
if(egw_vfs::deny_script($path))
|
||||
{
|
||||
$response->addAlert(lang('You are NOT allowed to upload a script!'));
|
||||
$response->addScript("document.getElementById('$id').value='';");
|
||||
$ask_overwrite = array();
|
||||
break;
|
||||
}
|
||||
elseif (egw_vfs::stat($path))
|
||||
{
|
||||
if (egw_vfs::is_dir($path))
|
||||
{
|
||||
$response->addAlert(lang("There's already a directory with that name!"));
|
||||
$response->addScript("document.getElementById('$id').value='';");
|
||||
$ask_overwrite = array();
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
$ask_overwrite[] = egw_vfs::decodePath($path);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// do nothing new file
|
||||
}
|
||||
}
|
||||
if ($ask_overwrite)
|
||||
{
|
||||
$response->addScript("if (!confirm('".addslashes(lang('Do you want to overwrite the existing file %1?',implode(', ',$ask_overwrite)))."')) document.getElementById('$id').value='';");
|
||||
}
|
||||
return $response->getXML();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the configured start directory for the current user
|
||||
*
|
||||
@ -1313,6 +1257,10 @@ class filemanager_ui
|
||||
++$arr['errs'];
|
||||
unset($selected[$tmp_name]);
|
||||
}
|
||||
elseif (egw_vfs::is_dir($path))
|
||||
{
|
||||
$data['confirm'] = 'is_dir';
|
||||
}
|
||||
elseif (!$data['confirmed'] && egw_vfs::stat($path))
|
||||
{
|
||||
$data['confirm'] = true;
|
||||
|
@ -204,55 +204,48 @@ app.filemanager = AppJS.extend(
|
||||
{
|
||||
if (_data.msg) window.egw_refresh(_data.msg, this.appname);
|
||||
|
||||
//var send_confirmation_back = false;
|
||||
var that = this;
|
||||
for(var file in _data.uploaded)
|
||||
{
|
||||
if (_data.uploaded[file].confirm && !_data.uploaded[file].confirmed)
|
||||
{
|
||||
et2_createWidget("dialog",{
|
||||
callback: function(button_id, value) {
|
||||
if (button_id == "overwrite")
|
||||
{
|
||||
value.data.confirmed = true;
|
||||
var uploaded = {};
|
||||
uploaded[value.file] = value.data;
|
||||
var request = new egw_json_request('filemanager_ui::ajax_action', ['upload', uploaded, value.path], that);
|
||||
request.sendRequest(false, that._upload_callback, that);
|
||||
}
|
||||
},
|
||||
buttons: [
|
||||
{text: egw.lang("Overwrite"), id: "overwrite", class: "ui-priority-primary", "default": true},
|
||||
//{text: egw.lang("Rename"), id:"rename"},
|
||||
var buttons = [
|
||||
{text: egw.lang("Yes"), id: "overwrite", class: "ui-priority-primary", "default": true},
|
||||
{text: egw.lang("Rename"), id:"rename"},
|
||||
{text: egw.lang("Cancel"), id:"cancel"},
|
||||
].reverse(),
|
||||
title: egw.lang('File already exists', _data.uploaded[file].name),
|
||||
//template:"/egroupware/addressbook/templates/default/edit.xet",
|
||||
value: {
|
||||
name: _data.uploaded[file].name,
|
||||
file: file,
|
||||
data: _data.uploaded[file],
|
||||
path: _data.path
|
||||
];
|
||||
if (_data.uploaded[file].confirm === "is_dir")
|
||||
buttons.shift();
|
||||
var dialog = et2_dialog.show_prompt(function(_button_id, _value) {
|
||||
var uploaded = {};
|
||||
uploaded[this.my_data.file] = this.my_data.data;
|
||||
switch (_button_id)
|
||||
{
|
||||
case "overwrite":
|
||||
uploaded[this.my_data.file].confirmed = true;
|
||||
// fall through
|
||||
case "rename":
|
||||
uploaded[this.my_data.file].name = _value;
|
||||
delete uploaded[this.my_data.file].confirm;
|
||||
// send overwrite-confirmation and/or rename request to server
|
||||
var request = new egw_json_request('filemanager_ui::ajax_action', ['upload', uploaded, this.my_data.path], that);
|
||||
request.sendRequest(false, that._upload_callback, that);
|
||||
return;
|
||||
}
|
||||
},
|
||||
message: egw.lang('Do you want to overwrite existing file <b>%1</b> in directory <b>%2</b>?', _data.uploaded[file].name, _data.path),
|
||||
dialog_type: et2_dialog.QUESTION_MESSAGE
|
||||
});
|
||||
/*if (confirm(egw.lang('Overwrite %1?', _data.uploaded[file].name)))
|
||||
{
|
||||
send_confirmation_back = true;
|
||||
_data.uploaded[file].confirmed = true;
|
||||
}*/
|
||||
_data.uploaded[file].confirm === "is_dir" ?
|
||||
egw.lang("There's already a directory with that name!") :
|
||||
egw.lang('Do you want to overwrite existing file <b>%1</b> in directory <b>%2</b>?', _data.uploaded[file].name, _data.path),
|
||||
egw.lang('File <b>%1</b> already exists', _data.uploaded[file].name),
|
||||
_data.uploaded[file].name, buttons, file);
|
||||
// setting required data for callback in as my_data
|
||||
dialog.my_data = {
|
||||
file: file,
|
||||
path: _data.path,
|
||||
data: _data.uploaded[file]
|
||||
};
|
||||
}
|
||||
/*else
|
||||
{
|
||||
delete _data.uploaded[file];
|
||||
}*/
|
||||
}
|
||||
/*if (send_confirmation_back)
|
||||
{
|
||||
var request = new egw_json_request('filemanager_ui::ajax_action', ['upload', _data.uploaded, _data.path], this);
|
||||
request.sendRequest(false, this._upload_callback, this);
|
||||
}*/
|
||||
},
|
||||
|
||||
/**
|
||||
@ -337,9 +330,22 @@ app.filemanager = AppJS.extend(
|
||||
*/
|
||||
action: function(_action, _elems)
|
||||
{
|
||||
if (typeof _action.data.confirm == 'undefined'|| confirm(_action.data.confirm))
|
||||
var paths = this._elems2paths(_elems);
|
||||
if (typeof _action.data.confirm != 'undefined')
|
||||
{
|
||||
this._do_action(_action.id, this._elems2paths(_elems));
|
||||
var that = this;
|
||||
var action_id = _action.id;
|
||||
et2_dialog.show_dialog(function(button_id,value)
|
||||
{
|
||||
if (button_id != et2_dialog.NO_BUTTON)
|
||||
{
|
||||
that._do_action(action_id, paths);
|
||||
}
|
||||
}, _action.data.confirm, egw.lang('Confirmation required'), et2_dialog.BUTTONS_YES_NO, et2_dialog.QUESTION_MESSAGE);
|
||||
}
|
||||
else
|
||||
{
|
||||
this._do_action(_action.id, paths);
|
||||
}
|
||||
},
|
||||
|
||||
@ -568,7 +574,7 @@ app.filemanager = AppJS.extend(
|
||||
|
||||
if (_path == path)
|
||||
{
|
||||
var ids = ['button[linkpaste]', 'button[paste]', 'button[createdir]', 'button[symlink]', 'upload[]'];
|
||||
var ids = ['button[linkpaste]', 'button[paste]', 'button[createdir]', 'button[symlink]', 'upload'];
|
||||
for(var i=0; i < ids.length; ++i)
|
||||
{
|
||||
var widget = this.et2.getWidgetById(ids[i]);
|
||||
|
@ -76,6 +76,7 @@ directory successfully created. filemanager de Verzeichnis erfolgreich angelegt.
|
||||
directory with documents to insert entries filemanager de Verzeichnis mit Dokumenten zum Einfügen von Daten
|
||||
display and modification of content filemanager de Anzeigen und Verändern des Inhaltes
|
||||
display of content filemanager de Anzeigen des Inhaltes
|
||||
do you want to overwrite existing file <b>%1</b> in directory <b>%2</b>? filemanager de Wollen Sie die bestehende Datei <b>%1</b> im Verzeichnis <b>%2</b> überschreiben?
|
||||
do you want to overwrite the existing file %1? filemanager de Wollen Sie die existierende Datei %1 überschreiben?
|
||||
download filemanager de Herunterladen
|
||||
edit comments filemanager de Kommentare bearbeiten
|
||||
@ -103,6 +104,7 @@ favorites filemanager de Favoriten
|
||||
file filemanager de Datei
|
||||
file %1 could not be created. filemanager de Die Datei %1 konnte nicht erzeugt werden
|
||||
file %1 may be too big. contact your systemadministrator for further info filemanager de Die Datei %1 ist eventuell zu gross. Kontaktieren Sie Ihren Systemadministrator für weiterreichende Informationen.
|
||||
file <b>%1</b> already exists filemanager de Es gibt schon eine Datei <b>%1</b>
|
||||
file deleted. filemanager de Datei gelöscht.
|
||||
file names cannot contain "%1" filemanager de Dateinamen dürfen "%1" nicht enthalten
|
||||
file or directory not found! filemanager de Datei oder Verzeichnis nicht gefunden!
|
||||
|
@ -76,6 +76,7 @@ directory successfully created. filemanager en Directory successfully created.
|
||||
directory with documents to insert entries filemanager en Directory with documents to insert entries
|
||||
display and modification of content filemanager en Display and modification of content
|
||||
display of content filemanager en Display of content
|
||||
do you want to overwrite existing file <b>%1</b> in directory <b>%2</b>? filemanager en Do you want to overwrite existing file <b>%1</b> in directory <b>%2</b>?
|
||||
do you want to overwrite the existing file %1? filemanager en Do you want to overwrite the existing file %1?
|
||||
download filemanager en Download
|
||||
edit comments filemanager en Edit comments
|
||||
@ -103,6 +104,7 @@ favorites filemanager en Favorites
|
||||
file filemanager en File
|
||||
file %1 could not be created. filemanager en File %1 could not be created.
|
||||
file %1 may be too big. contact your systemadministrator for further info filemanager en File %1 might be too big.
|
||||
file <b>%1</b> already exists filemanager en File <b>%1</b> already exists
|
||||
file deleted. filemanager en File deleted.
|
||||
file names cannot contain "%1" filemanager en File names cannot contain "%1"
|
||||
file or directory not found! filemanager en File or directory not found!
|
||||
|
Loading…
Reference in New Issue
Block a user