mirror of
https://github.com/moodle/moodle.git
synced 2025-06-04 23:25:35 +02:00
MDL-60817 core_repository: Show a warning if file extension is modified
This commit is contained in:
parent
73f8c56dfc
commit
17ddce9676
@ -114,8 +114,10 @@ class core_files_renderer extends plugin_renderer_base {
|
||||
array('unknownoriginal', 'repository'), array('confirmdeletefolder', 'repository'),
|
||||
array('confirmdeletefilewithhref', 'repository'), array('confirmrenamefolder', 'repository'),
|
||||
array('confirmrenamefile', 'repository'), array('newfolder', 'repository'), array('edit', 'moodle'),
|
||||
['nofilesselected', 'repository'], ['confirmdeleteselectedfile', 'repository'],
|
||||
['selectall', 'moodle'], ['deselectall', 'moodle'], ['selectallornone', 'form'],
|
||||
array('originalextensionchange', 'repository'), array('originalextensionremove', 'repository'),
|
||||
array('aliaseschange', 'repository'), ['nofilesselected', 'repository'],
|
||||
['confirmdeleteselectedfile', 'repository'], ['selectall', 'moodle'], ['deselectall', 'moodle'],
|
||||
['selectallornone', 'form'],
|
||||
)
|
||||
);
|
||||
if ($this->page->requires->should_create_one_time_item_now('core_file_managertemplate')) {
|
||||
|
@ -29,6 +29,7 @@ $string['add'] = 'Add';
|
||||
$string['addfile'] = 'Add...';
|
||||
$string['addfiletext'] = 'Add file';
|
||||
$string['addplugin'] = 'Add a repository plugin';
|
||||
$string['aliaseschange'] = 'There are {$a} alias/shortcut files that use this file as their source. If you proceed then those aliases will be converted to true copies.';
|
||||
$string['allowexternallinks'] = 'Allow external links';
|
||||
$string['areamainfile'] = 'Main file';
|
||||
$string['coursebackup'] = 'Course backups';
|
||||
@ -68,7 +69,7 @@ $string['configsyncimagetimeout'] = 'Timeout in seconds for downloading an image
|
||||
$string['confirmdelete'] = 'Are you sure you want to delete the repository {$a}? If you choose "Continue and download", file references to external contents will be downloaded to Moodle. This could take a long time to process.';
|
||||
$string['confirmdeletefile'] = 'Are you sure you want to delete this file?';
|
||||
$string['confirmdeleteselectedfile'] = 'Are you sure you want to delete the selected {$a} file(s)?';
|
||||
$string['confirmrenamefile'] = 'Are you sure you want to rename/move this file? There are {$a} alias/shortcut files that use this file as their source. If you proceed then those aliases will be converted to true copies.';
|
||||
$string['confirmrenamefile'] = 'Are you sure you want to rename/move this file?';
|
||||
$string['confirmdeletefilewithhref'] = 'Are you sure you want to delete this file? There are {$a} alias/shortcut files that use this file as their source. If you proceed then those aliases will be converted to true copies.';
|
||||
$string['confirmdeletefolder'] = 'Are you sure you want to delete this folder? All files and subfolders will be deleted.';
|
||||
$string['confirmremove'] = 'Are you sure you want to remove this repository plugin, its options and <strong>all of its instances</strong> - {$a}? If you choose "Continue and download", file references to external contents will be downloaded to Moodle. This could take a long time to process.';
|
||||
@ -187,6 +188,8 @@ $string['norepositoriesexternalavailable'] = 'Sorry, none of your current reposi
|
||||
$string['notyourinstances'] = 'You can not view/edit repository instances of another user';
|
||||
$string['off'] = 'Enabled but hidden';
|
||||
$string['original'] = 'Original';
|
||||
$string['originalextensionchange'] = 'The original file extension has been modified as a part of the file name change. Changing the extension from ".{$a->originalextension}" to ".{$a->newextension}" could potentially cause some side effects.';
|
||||
$string['originalextensionremove'] = 'The original file extension has been removed as a part of the file name change. Removing the extension ".{$a}" could potentially cause some side effects.';
|
||||
$string['openpicker'] = 'Choose a file...';
|
||||
$string['operation'] = 'Operation';
|
||||
$string['on'] = 'Enabled and visible';
|
||||
|
@ -773,10 +773,38 @@ M.form_filemanager.init = function(Y, options) {
|
||||
this.print_msg(M.util.get_string('enternewname', 'repository'), 'error');
|
||||
return;
|
||||
}
|
||||
if ((filenamechanged || filepathchanged) && !confirmed && fileinfo.refcount) {
|
||||
dialog_options.message = M.util.get_string('confirmrenamefile', 'repository', fileinfo.refcount);
|
||||
this.show_confirm_dialog(dialog_options);
|
||||
return;
|
||||
|
||||
if ((filenamechanged || filepathchanged) && !confirmed) {
|
||||
var warnings = '';
|
||||
var originalfilenamearr = fileinfo.fullname.split('.');
|
||||
var originalextension = (originalfilenamearr.length > 1) ? originalfilenamearr.pop() : "";
|
||||
var newfilenamearr = newfilename.split('.');
|
||||
var newextension = (newfilenamearr.length > 1) ? newfilenamearr.pop() : "";
|
||||
|
||||
if (newextension !== originalextension) {
|
||||
if (newextension === "") {
|
||||
var string = M.util.get_string('originalextensionremove', 'repository', originalextension);
|
||||
} else {
|
||||
var stringvars = {
|
||||
originalextension: originalextension,
|
||||
newextension: newextension
|
||||
}
|
||||
string = M.util.get_string('originalextensionchange', 'repository', stringvars);
|
||||
}
|
||||
warnings = warnings.concat('<li>', string, '</li>');
|
||||
}
|
||||
if (fileinfo.refcount) {
|
||||
var string = M.util.get_string('aliaseschange', 'repository', fileinfo.refcount);
|
||||
warnings = warnings.concat('<li>', string, '</li>');
|
||||
}
|
||||
if (warnings.length > 0) {
|
||||
var message = '';
|
||||
var confirmmsg = M.util.get_string('confirmrenamefile', 'repository', fileinfo.refcount);
|
||||
dialog_options.message = message.concat('<p>', confirmmsg, '</p>',
|
||||
'<ul class="p-x-2">', warnings, '</ul>');
|
||||
this.show_confirm_dialog(dialog_options);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (filenamechanged || filepathchanged || licensechanged || authorchanged) {
|
||||
params = {filepath:fileinfo.filepath, filename:fileinfo.fullname,
|
||||
|
Loading…
x
Reference in New Issue
Block a user