backup MDL-24103 Better error messages when a user attempts to restore invalid backup file formats such as moodle 1.9 backups
This commit is contained in:
@@ -603,6 +603,20 @@ class core_backup_renderer extends plugin_renderer_base {
|
||||
$output .= html_writer::end_tag('div');
|
||||
return $output;
|
||||
}
|
||||
|
||||
public function invalid_format($format) {
|
||||
$html = html_writer::start_tag('div', array('class'=>'invalidformat'));
|
||||
$html .= html_writer::tag('h2', get_string('errorinvalidformat', 'backup'), array('class'=>'notifyproblem'));
|
||||
if ($format == 'moodle1') {
|
||||
// Moodle 1.x backups
|
||||
$html .= html_writer::tag('div', get_string('errormoodle1formatdesc', 'backup'), array('class'=>'notifyproblem'));
|
||||
} else {
|
||||
// Totally unknown format
|
||||
$html .= html_writer::tag('div', get_string('errorinvalidformatdesc', 'backup'), array('class'=>'notifyproblem'));
|
||||
}
|
||||
$html .= html_writer::end_tag('div');
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -169,6 +169,13 @@ class restore_ui_stage_confirm extends restore_ui_independent_stage {
|
||||
return ($fb->extract_to_pathname("$CFG->dataroot/temp/backup/".$this->filename, "$CFG->dataroot/temp/backup/$this->filepath/"));
|
||||
}
|
||||
public function display($renderer) {
|
||||
|
||||
// TODO: Remove this when backup formats are better supported
|
||||
$format = backup_general_helper::detect_backup_format($this->filepath);
|
||||
if ($format !== 'moodle2') {
|
||||
return $renderer->invalid_format($format);
|
||||
}
|
||||
|
||||
$this->details = backup_general_helper::get_backup_information($this->filepath);
|
||||
return $renderer->backup_details($this->details, new moodle_url('/backup/restore.php', array('contextid'=>$this->contextid, 'filepath'=>$this->filepath, 'stage'=>restore_ui::STAGE_DESTINATION)));
|
||||
}
|
||||
@@ -233,6 +240,12 @@ class restore_ui_stage_destination extends restore_ui_independent_stage {
|
||||
*/
|
||||
public function display($renderer) {
|
||||
global $DB, $USER, $PAGE;
|
||||
|
||||
$format = backup_general_helper::detect_backup_format($this->filepath);
|
||||
if ($format !== 'moodle2') {
|
||||
return $renderer->invalid_format($format);
|
||||
}
|
||||
|
||||
$this->details = backup_general_helper::get_backup_information($this->filepath);
|
||||
$url = new moodle_url('/backup/restore.php', array('contextid'=>$this->contextid, 'filepath'=>$this->filepath, 'stage'=>restore_ui::STAGE_SETTINGS));
|
||||
|
||||
|
||||
@@ -80,6 +80,9 @@ $string['errorfilenamerequired'] = 'You must enter a valid filename for this bac
|
||||
$string['errorfilenamemustbezip'] = 'The filename you enter must be a ZIP file and have the .mbz extension';
|
||||
$string['errorminbackup20version'] = 'This backup file has been created with one development version of Moodle backup ({$a->backup}). Minimum required is {$a->min}. Cannot be restored.';
|
||||
$string['errorrestorefrontpage'] = 'Restoring over front page is not allowed.';
|
||||
$string['errorinvalidformat'] = 'Invalid backup format.';
|
||||
$string['errorinvalidformatdesc'] = 'The uploaded file is invalid or not a recognised restorable backup.';
|
||||
$string['errormoodle1formatdesc'] = 'Moodle 1.x backups are not presently restorable. This functionality is under development and will be complete shortly.';
|
||||
$string['executionsuccess'] = 'The backup file was successfully created.';
|
||||
$string['filename'] = 'Filename';
|
||||
$string['generalactivities'] = 'Include activities';
|
||||
|
||||
Reference in New Issue
Block a user