MDL-33430 Notify user about file aliases failures at the final stage of the restore

This commit is contained in:
David Mudrák
2012-06-21 15:22:38 +02:00
parent ff8734f21d
commit 7b5f67f77f
4 changed files with 46 additions and 0 deletions
+24
View File
@@ -3353,6 +3353,7 @@ class restore_process_file_aliases_queue extends restore_execution_step {
$reason = ' ('.$reason.')';
}
$this->log('unable to restore alias'.$reason, backup::LOG_WARNING, $filedesc, 1);
$this->add_result_item('file_aliases_restore_failures', $filedesc);
}
/**
@@ -3391,6 +3392,29 @@ class restore_process_file_aliases_queue extends restore_execution_step {
return $filedesc;
}
/**
* Append a value to the given resultset
*
* @param string $name name of the result containing a list of values
* @param mixed $value value to add as another item in that result
*/
private function add_result_item($name, $value) {
$results = $this->task->get_results();
if (isset($results[$name])) {
if (!is_array($results[$name])) {
throw new coding_exception('Unable to append a result item into a non-array structure.');
}
$current = $results[$name];
$current[] = $value;
$this->task->add_result(array($name => $current));
} else {
$this->task->add_result(array($name => array($value)));
}
}
}
+14
View File
@@ -757,6 +757,20 @@ class restore_ui_stage_complete extends restore_ui_stage_process {
public function display(core_backup_renderer $renderer) {
$html = '';
if (!empty($this->results['file_aliases_restore_failures'])) {
$html .= $renderer->box_start('generalbox filealiasesfailures');
$html .= $renderer->heading_with_help(get_string('filealiasesrestorefailures', 'core_backup'),
'filealiasesrestorefailures', 'core_backup');
$html .= $renderer->container(get_string('filealiasesrestorefailuresinfo', 'core_backup'));
$html .= $renderer->container_start('aliaseslist');
$html .= html_writer::start_tag('ul');
foreach ($this->results['file_aliases_restore_failures'] as $alias) {
$html .= html_writer::tag('li', s($alias));
}
$html .= html_writer::end_tag('ul');
$html .= $renderer->container_end();
$html .= $renderer->box_end();
}
$html .= $renderer->box_start();
$html .= $renderer->notification(get_string('restoreexecutionsuccess', 'backup'), 'notifysuccess');
$html .= $renderer->continue_button(new moodle_url('/course/view.php', array(
+6
View File
@@ -117,6 +117,12 @@ $string['errorinvalidformat'] = 'Unknown backup format';
$string['errorinvalidformatinfo'] = 'The selected file is not a valid Moodle backup file and can\'t be restored.';
$string['executionsuccess'] = 'The backup file was successfully created.';
$string['filename'] = 'Filename';
$string['filealiasesrestorefailures'] = 'Aliases restore failures';
$string['filealiasesrestorefailuresinfo'] = 'Some aliases included in the backup file could not be restored. The following list contains their expected location and the source file they were referring to at the original site.';
$string['filealiasesrestorefailures_help'] = 'Aliases are symbolic links to other files, including those stored in external repositories. In some cases, Moodle cannot restore them - for example when restoring the backup at another site or when the referenced file does not exist.
More details and the actual reason of the failure can be found in the restore log file.';
$string['filealiasesrestorefailures_link'] = 'restore/filealiases';
$string['filereferencesincluded'] = 'File references to external contents included in backup package, they won\'t work on other sites.';
$string['filereferencessamesite'] = 'Backup is from the same site, file references can be restored';
$string['filereferencesnotsamesite'] = 'Backup is from other site, file references cannot be restored';
+2
View File
@@ -461,6 +461,8 @@ body.tag .managelink {padding: 5px;}
.path-backup .backup_progress .backup_stage.backup_stage_current {font-weight:bold;color:inherit;}
.path-backup .backup_progress .backup_stage.backup_stage_next {}
.path-backup .backup_progress span.backup_stage.backup_stage_complete {color:inherit;}
#page-backup-restore .filealiasesfailures {background-color:#ffd3d9}
#page-backup-restore .filealiasesfailures .aliaseslist {width:90%;margin:0.8em auto;background-color:white;border:1px dotted #666;}
/**
* Web Service