diff --git a/backup/util/ui/renderer.php b/backup/util/ui/renderer.php index 1ee44e45587..f66a88d0aca 100644 --- a/backup/util/ui/renderer.php +++ b/backup/util/ui/renderer.php @@ -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; + } } /** diff --git a/backup/util/ui/restore_ui_stage.class.php b/backup/util/ui/restore_ui_stage.class.php index 6eab0985eb5..863a02f1c05 100644 --- a/backup/util/ui/restore_ui_stage.class.php +++ b/backup/util/ui/restore_ui_stage.class.php @@ -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)); diff --git a/lang/en/backup.php b/lang/en/backup.php index c20def29097..94266bb1d42 100644 --- a/lang/en/backup.php +++ b/lang/en/backup.php @@ -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';