Commit ba5fd5a6 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Allow automatic upload on file selection to be disabled (part of workaround for bug #623648)


Signed-off-by: default avatarRichard Mansfield <richard.mansfield@catalyst.net.nz>
parent 456a2f1a
......@@ -107,6 +107,10 @@ function pieform_element_filebrowser(Pieform $form, $element) {
$smarty->assign('agreementtext', get_string('uploadcopyrightdefaultcontent', 'install'));
}
}
else if (!isset($config['simpleupload'])) {
$config['simpleupload'] = 1;
}
if ($config['upload']) {
$maxuploadsize = display_size(get_max_upload_size(!$institution && !$group));
$smarty->assign('maxuploadsize', $maxuploadsize);
......
......@@ -85,7 +85,12 @@ function FileBrowser(idprefix, folderid, config, globalconfig) {
}
});
}
connect(self.id + '_userfile', 'onchange', self.upload_submit);
if (self.config.submitbutton && $(self.id + '_uploadsubmit')) {
connect(self.id + '_uploadsubmit', 'onclick', self.upload_submit);
}
else {
connect(self.id + '_userfile', 'onchange', self.upload_submit);
}
}
this.upload_validate = function () {
......@@ -128,7 +133,12 @@ function FileBrowser(idprefix, folderid, config, globalconfig) {
'name':'userfile',
'size':40
}));
connect(self.id + '_userfile', 'onchange', self.upload_submit);
if (self.config.submitbutton && $(self.id + '_uploadsubmit')) {
connect(self.id + '_uploadsubmit', 'onclick', self.upload_submit);
}
else {
connect(self.id + '_userfile', 'onchange', self.upload_submit);
}
$(self.id + '_upload').value = 0;
return false;
}
......
......@@ -38,6 +38,9 @@
<table id="{$prefix}_upload_container" class="fileupload{if $tabs && !$tabs.upload} hidden{/if}">
<tbody>
{if $config.upload}
{* config.uploadagreement: disable the file chooser unless the agreement is checked *}
{* config.simpleupload: the form only contains a file chooser *}
{* config.submitbutton: add submit button even if js is enabled & don't start uploading as soon as a file is chosen *}
<input type="hidden" name="{$prefix}_uploadnumber" id="{$prefix}_uploadnumber" value="1" />
<input type="hidden" name="MAX_FILE_SIZE" value="{$phpmaxfilesize}" />
<tr><td colspan=2 id="{$prefix}_upload_messages"></td></tr>
......@@ -49,24 +52,24 @@
{$agreementtext|clean_html|safe}
</td>
</tr>
{/if}
<tr class="uploadform">
<th><label>{str tag='File' section='artefact.file'}</label></th>
<th><label>{if $config.simpleupload}{str tag='uploadfile' section='artefact.file'}{else}{str tag='File' section='artefact.file'}{/if}</label></th>
<td>
<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>
{if $config.uploadagreement}<script>setNodeAttribute('{$prefix}_userfile', 'disabled', true);</script>{/if}
</td>
</tr>
{else}
<tr>
<th><label>{str tag='uploadfile' section='artefact.file'}</label></th>
<tr class="uploadform">
<th></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>
{if $config.submitbutton}
<input type="submit" class="submit nojs-hidden-block" name="{$prefix}_uploadsubmit" id="{$prefix}_uploadsubmit" value="{str tag=upload section=artefact.file}" />
{/if}
<noscript><input type="submit" class="submit" name="{$prefix}_upload" id="{$prefix}_upload" value="{str tag=upload section=artefact.file}" /></noscript>
</td>
</tr>
{/if}
{/if}
{if $config.createfolder}
......
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