MDL-83543 core: Move download complete status handling to Excel library
When a form is validated, all validation buttons are automatically locked to prevent them from being sent twice by mistake. When the form returns a file instead of redirecting to a new HTML page, a mechanism (\core_form\util::form_download_complete()) must be called to reactivate the form's validation buttons. This mechanism is called for CSV files (file lib/csvlib.class.php), but not when downloading xls files. The mechanism is only called when downloading grades in Excel format (file grade/export/xls/grade_export_xls.php). The patch proposes to call this mechanism globally for all Excel file downloads (file lib/excellib.class.php), and not just for grade downloads (file grade/export/xls/grade_export_xls.php).
This commit is contained in:
@@ -45,9 +45,6 @@ class grade_export_xls extends grade_export {
|
||||
|
||||
$strgrades = get_string('grades');
|
||||
|
||||
// If this file was requested from a form, then mark download as complete (before sending headers).
|
||||
\core_form\util::form_download_complete();
|
||||
|
||||
// Calculate file name
|
||||
$shortname = format_string($this->course->shortname, true, array('context' => context_course::instance($this->course->id)));
|
||||
$downloadfilename = clean_filename("$shortname $strgrades.xls");
|
||||
|
||||
@@ -110,6 +110,9 @@ class MoodleExcelWorkbook {
|
||||
public function close() {
|
||||
global $CFG;
|
||||
|
||||
// If this file was requested from a form, then mark download as complete.
|
||||
\core_form\util::form_download_complete();
|
||||
|
||||
foreach ($this->objspreadsheet->getAllSheets() as $sheet) {
|
||||
$sheet->setSelectedCells('A1');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user