mirror of
https://github.com/moodle/moodle.git
synced 2025-03-14 04:30:15 +01:00
MDL-38509 Save uploaded ZIP into a temporary location and redirect to validator
This commit is contained in:
parent
30bec5ba8d
commit
585b64a607
@ -95,6 +95,24 @@ class tool_installaddon_installer {
|
||||
return $this->installfromzipform;
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the ZIP file from the {@link tool_installaddon_installfromzip} form
|
||||
*
|
||||
* The file is saved into the given temporary location for inspection and eventual
|
||||
* deployment. The form is expected to be submitted and validated.
|
||||
*
|
||||
* @param tool_installaddon_installfromzip $form
|
||||
* @param string $targetdir full path to the directory where the ZIP should be stored to
|
||||
* @return string filename of the saved file relative to the given target
|
||||
*/
|
||||
public function save_installfromzip_file(tool_installaddon_installfromzip $form, $targetdir) {
|
||||
|
||||
$filename = clean_param($form->get_new_filename('zipfile'), PARAM_FILE);
|
||||
$form->save_file('zipfile', $targetdir.'/'.$filename);
|
||||
|
||||
return $filename;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns localised list of available plugin types
|
||||
*
|
||||
|
@ -41,7 +41,18 @@ if ($form->is_cancelled()) {
|
||||
redirect($PAGE->url);
|
||||
|
||||
} else if ($data = $form->get_data()) {
|
||||
// todo $installer->process_installfromzip_form($data);
|
||||
// Save the ZIP file into a temporary location.
|
||||
$jobid = md5(rand().uniqid('', true));
|
||||
$sourcedir = make_temp_directory('tool_installaddon/'.$jobid.'/source');
|
||||
$zipfilename = $installer->save_installfromzip_file($form, $sourcedir);
|
||||
// Redirect to the validation page.
|
||||
$nexturl = new moodle_url('/admin/tool/installaddon/validate.php', array(
|
||||
'sesskey' => sesskey(),
|
||||
'jobid' => $jobid,
|
||||
'zip' => $zipfilename,
|
||||
'type' => $data->plugintype,
|
||||
'rootdir' => $data->rootdir));
|
||||
redirect($nexturl);
|
||||
}
|
||||
|
||||
$output = $PAGE->get_renderer('tool_installaddon');
|
||||
|
Loading…
x
Reference in New Issue
Block a user