mirror of
https://github.com/moodle/moodle.git
synced 2025-04-22 17:02:03 +02:00
MDL-41211 tool_uploadcourse: Passing restore file path to processor
This commit is contained in:
parent
50ff861263
commit
8a4b2b944d
@ -58,11 +58,12 @@ class tool_uploadcourse_step2_form extends tool_uploadcourse_base_form {
|
||||
$mform->disabledIf('options[shortnametemplate]', 'options[mode]', 'eq', tool_uploadcourse_processor::MODE_CREATE_OR_UPDATE);
|
||||
$mform->disabledIf('options[shortnametemplate]', 'options[mode]', 'eq', tool_uploadcourse_processor::MODE_UPDATE_ONLY);
|
||||
|
||||
// Restore file is not in the array options on purpose, because formslib can't handle it!
|
||||
$contextid = $this->_customdata['contextid'];
|
||||
$mform->addElement('hidden', 'contextid', $contextid);
|
||||
$mform->setType('contextid', PARAM_INT);
|
||||
$mform->addElement('filepicker', 'options[restorefile]', get_string('templatefile', 'tool_uploadcourse'));
|
||||
$mform->addHelpButton('options[restorefile]', 'templatefile', 'tool_uploadcourse');
|
||||
$mform->addElement('filepicker', 'restorefile', get_string('templatefile', 'tool_uploadcourse'));
|
||||
$mform->addHelpButton('restorefile', 'templatefile', 'tool_uploadcourse');
|
||||
|
||||
$mform->addElement('text', 'options[templatecourse]', get_string('coursetemplatename', 'tool_uploadcourse'));
|
||||
$mform->setType('options[templatecourse]', PARAM_TEXT);
|
||||
|
@ -78,6 +78,13 @@ if ($form2data = $mform2->is_cancelled()) {
|
||||
|
||||
$options = (array) $form2data->options;
|
||||
$defaults = (array) $form2data->defaults;
|
||||
|
||||
// Restorefile deserves its own logic because formslib does not really appreciate
|
||||
// when the name of a filepicker is an array...
|
||||
$options['restorefile'] = '';
|
||||
if (!empty($form2data->restorefile)) {
|
||||
$options['restorefile'] = $mform2->save_temp_file('restorefile');
|
||||
}
|
||||
$processor = new tool_uploadcourse_processor($cir, $options, $defaults);
|
||||
|
||||
echo $OUTPUT->header();
|
||||
@ -91,6 +98,11 @@ if ($form2data = $mform2->is_cancelled()) {
|
||||
echo $OUTPUT->continue_button($returnurl);
|
||||
}
|
||||
|
||||
// Deleting the file after processing or preview.
|
||||
if (!empty($options['restorefile'])) {
|
||||
@unlink($options['restorefile']);
|
||||
}
|
||||
|
||||
} else {
|
||||
$processor = new tool_uploadcourse_processor($cir, $form1data->options, array());
|
||||
echo $OUTPUT->header();
|
||||
|
Loading…
x
Reference in New Issue
Block a user