Commit 0b1f14a3 authored by Ruslan Kabalin's avatar Ruslan Kabalin
Browse files

filebrowser: error message on manipulation with unexisting file/folder


Signed-off-by: default avatarRuslan Kabalin <ruslan.kabalin@luns.net.uk>
parent 7aed289a
......@@ -806,7 +806,19 @@ function pieform_element_filebrowser_update(Pieform $form, $element, $data) {
global $USER;
$collide = !empty($data['collide']) ? $data['collide'] : 'fail';
$artefact = artefact_instance_from_id($data['artefact']);
try {
$artefact = artefact_instance_from_id($data['artefact']);
}
catch (ArtefactNotFoundException $e) {
$parentfolder = $element['folder'] ? $element['folder'] : null;
$result = array(
'error' => true,
'message' => get_string('editingfailed', 'artefact.file'),
'newlist' => pieform_element_filebrowser_build_filelist($form, $element, $parentfolder),
);
return $result;
}
if (!$USER->can_edit_artefact($artefact) || $artefact->get('locked')) {
return array('error' => true, 'message' => get_string('noeditpermission', 'mahara'));
}
......@@ -859,16 +871,29 @@ function pieform_element_filebrowser_update(Pieform $form, $element, $data) {
function pieform_element_filebrowser_delete(Pieform $form, $element, $artefact) {
global $USER;
$artefact = artefact_instance_from_id($artefact);
try {
$artefact = artefact_instance_from_id($artefact);
}
catch (ArtefactNotFoundException $e) {
$parentfolder = $element['folder'] ? $element['folder'] : null;
$result = array(
'error' => true,
'message' => get_string('deletingfailed', 'artefact.file'),
'newlist' => pieform_element_filebrowser_build_filelist($form, $element, $parentfolder),
);
return $result;
}
if (!$USER->can_edit_artefact($artefact) || $artefact->get('locked')) {
return array('error' => true, get_string('nodeletepermission', 'mahara'));
}
$parentfolder = $artefact->get('parent');
$artefact->delete();
return array(
'error' => false,
'deleted' => true,
'message' => get_string('filethingdeleted', 'artefact.file',
'error' => false,
'deleted' => true,
'message' => get_string('filethingdeleted', 'artefact.file',
get_string($artefact->get('artefacttype'), 'artefact.file') . ' ' . $artefact->get('title')),
'quotaused' => $USER->get('quotaused'),
'quota' => $USER->get('quota'),
......@@ -882,7 +907,17 @@ function pieform_element_filebrowser_move(Pieform $form, $element, $data) {
$artefactid = $data['artefact']; // Artefact being moved
$newparentid = $data['newparent']; // Folder to move it to
$artefact = artefact_instance_from_id($artefactid);
try {
$artefact = artefact_instance_from_id($artefactid);
}
catch (ArtefactNotFoundException $e) {
$result = array(
'error' => true,
'message' => get_string('movingfailed', 'artefact.file'),
'newlist' => pieform_element_filebrowser_build_filelist($form, $element, $data['folder']),
);
return $result;
}
if (!$USER->can_edit_artefact($artefact)) {
return array('error' => true, 'message' => get_string('movefailednotowner', 'artefact.file'));
......@@ -898,7 +933,18 @@ function pieform_element_filebrowser_move(Pieform $form, $element, $data) {
if ($newparentid == $artefact->get('parent')) {
return array('error' => false, 'message' => get_string('filealreadyindestination', 'artefact.file'));
}
$newparent = artefact_instance_from_id($newparentid);
try {
$newparent = artefact_instance_from_id($newparentid);
}
catch (ArtefactNotFoundException $e) {
$parentfolder = $element['folder'] ? $element['folder'] : null;
$result = array(
'error' => true,
'message' => get_string('movingfailed', 'artefact.file'),
'newlist' => pieform_element_filebrowser_build_filelist($form, $element, $data['folder']),
);
return $result;
}
if (!$USER->can_edit_artefact($newparent)) {
return array('error' => true, 'message' => get_string('movefailednotowner', 'artefact.file'));
}
......
......@@ -57,6 +57,7 @@ $string['maxquotatoolow'] = 'The maximum quota cannot be lower than the default
$string['maxquotaexceeded'] = 'You specified a quota above the maximum available setting for this site (%s). Try specifying a lower value or contact the site administrator to have them increase the maximum quota.';
$string['maxquotaexceededform'] = 'Please specify a file quota of less than %s.';
$string['maxquotadescription'] = 'You can set the maximum quota that an administrator can give to a user. Existing user quotas will not be affected.';
$string['deletingfailed'] = 'Deleting failed: file or folder does not exists any more';
$string['deletefile?'] = 'Are you sure you want to delete this file?';
$string['deletefolder?'] = 'Are you sure you want to delete this folder?';
$string['Description'] = 'Description';
......@@ -67,6 +68,7 @@ $string['downloadfile'] = 'Download %s';
$string['downloadoriginalversion'] = 'Download the original version';
$string['editfile'] = 'Edit file';
$string['editfolder'] = 'Edit folder';
$string['editingfailed'] = 'Editing failed: file or folder does not exists any more';
$string['emptyfolder'] = 'Empty folder';
$string['file'] = 'File'; // Capitalised to be consistent with names of all the other artefact types
$string['File'] = 'File';
......@@ -106,6 +108,7 @@ $string['movefaileddestinationnotfolder'] = 'You can only move files into folder
$string['movefailednotfileartefact'] = 'Only file, folder and image artefacts can be moved.';
$string['movefailednotowner'] = 'You do not have permission to move the file into this folder';
$string['movefailed'] = 'Move failed.';
$string['movingfailed'] = 'Moving failed: file or folder does not exists any more';
$string['nametoolong'] = 'That name is too long. Please choose a shorter one.';
$string['nofilesfound'] = 'No files found';
$string['notpublishable'] = 'You do not have permission to publish this file';
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment