Commit 750a630c authored by Ruslan Kabalin's avatar Ruslan Kabalin
Browse files

filebrowser: keep maximum upload size notice up to date.


Signed-off-by: default avatarRuslan Kabalin <ruslan.kabalin@luns.net.uk>
parent 1bd5eb88
......@@ -742,6 +742,7 @@ function pieform_element_filebrowser_upload(Pieform $form, $element, $data) {
$result['newlist'] = pieform_element_filebrowser_build_filelist($form, $element, $parentfolder, $newid);
$result['quota'] = $USER->get('quota');
$result['quotaused'] = $USER->get('quotaused');
$result['maxuploadsize'] = display_size(get_max_upload_size(!$institution && !$group));
return $result;
}
......@@ -893,6 +894,8 @@ function pieform_element_filebrowser_update(Pieform $form, $element, $data) {
function pieform_element_filebrowser_delete(Pieform $form, $element, $artefact) {
global $USER;
$institution = $form->get_property('institution');
$group = $form->get_property('group');
try {
$artefact = artefact_instance_from_id($artefact);
......@@ -919,6 +922,7 @@ function pieform_element_filebrowser_delete(Pieform $form, $element, $artefact)
get_string($artefact->get('artefacttype'), 'artefact.file') . ' ' . $artefact->get('title')),
'quotaused' => $USER->get('quotaused'),
'quota' => $USER->get('quota'),
'maxuploadsize' => display_size(get_max_upload_size(!$institution && !$group)),
'newlist' => pieform_element_filebrowser_build_filelist($form, $element, $parentfolder),
);
}
......
......@@ -567,6 +567,10 @@ function FileBrowser(idprefix, folderid, config, globalconfig) {
self.form = form; // ????
if (data.uploaded || data.error || data.deleted) {
self.callback_feedback(data); // add/update message
if (data.maxuploadsize) {
// keep max upload size up to date
replaceChildNodes(self.id + '_userfile_maxuploadsize', '(' + get_string('maxuploadsize') + ' ' + data.maxuploadsize + ')');
}
}
// Only update the file listing if the user hasn't changed folders yet
if (data.newlist && (data.folder == self.folderid || data.changedfolder)) {
......
......@@ -130,6 +130,7 @@ class PluginArtefactFile extends PluginArtefact {
'folderappearsinviews',
'foldernamerequired',
'foldernotempty',
'maxuploadsize',
'nametoolong',
'namefieldisrequired',
'uploadingfiletofolder',
......
......@@ -52,7 +52,8 @@
<tr class="uploadform">
<th><label>{str tag='File' section='artefact.file'}</label></th>
<td>
<div id="{$prefix}_userfile_container"><input type="file" class="file" id="{$prefix}_userfile" name="userfile" size="40" /> ({str tag=maxuploadsize section=artefact.file} {$maxuploadsize})</div>
<span id="{$prefix}_userfile_container"><input type="file" class="file" id="{$prefix}_userfile" name="userfile" size="40" /></span>
<span id="{$prefix}_userfile_maxuploadsize">({str tag=maxuploadsize section=artefact.file} {$maxuploadsize})</span>
<noscript><input type="submit" class="submit" name="{$prefix}_upload" id="{$prefix}_upload" value="{str tag=upload section=artefact.file}" /></noscript>
<script>setNodeAttribute('{$prefix}_userfile', 'disabled', true);</script>
</td>
......
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