MDL-24917, display activity backup area in restore-pre ui

This commit is contained in:
Dongsheng Cai 2010-11-02 02:29:21 +00:00
parent 384437085a
commit d0da42d1b7
5 changed files with 42 additions and 7 deletions

View File

@ -40,7 +40,7 @@ $filecontext = get_context_instance_by_id($contextid);
$url = new moodle_url('/backup/backupfilesedit.php', array('currentcontext'=>$currentcontext, 'contextid'=>$contextid, 'component'=>$component, 'filearea'=>$filearea));
require_login($course);
require_login($course, false, $cm);
require_capability('moodle/restore:uploadfile', $context);
$PAGE->set_url($url);

View File

@ -58,7 +58,7 @@ switch ($context->contextlevel) {
}
require_login($course);
require_login($course, false, $cm);
require_capability('moodle/restore:restorecourse', $context);
$browser = get_file_browser();
@ -112,6 +112,21 @@ if (has_capability('moodle/restore:uploadfile', $context)) {
echo $OUTPUT->container_end();
}
if ($context->contextlevel == CONTEXT_MODULE) {
echo $OUTPUT->heading_with_help(get_string('choosefilefromactivitybackup', 'backup'), 'choosefilefromuserbackup', 'backup');
echo $OUTPUT->container_start();
$treeview_options = array();
$user_context = get_context_instance(CONTEXT_USER, $USER->id);
$treeview_options['filecontext'] = $context;
$treeview_options['currentcontext'] = $context;
$treeview_options['component'] = 'backup';
$treeview_options['context'] = $context;
$treeview_options['filearea'] = 'activity';
$renderer = $PAGE->get_renderer('core', 'backup');
echo $renderer->backup_files_viewer($treeview_options);
echo $OUTPUT->container_end();
}
echo $OUTPUT->heading_with_help(get_string('choosefilefromcoursebackup', 'backup'), 'choosefilefromcoursebackup', 'backup');
echo $OUTPUT->container_start();
$treeview_options = array();
@ -124,7 +139,6 @@ $renderer = $PAGE->get_renderer('core', 'backup');
echo $renderer->backup_files_viewer($treeview_options);
echo $OUTPUT->container_end();
echo $OUTPUT->heading_with_help(get_string('choosefilefromuserbackup', 'backup'), 'choosefilefromuserbackup', 'backup');
echo $OUTPUT->container_start();
$treeview_options = array();

View File

@ -453,8 +453,20 @@ class backup_ui_stage_complete extends backup_ui_stage_final {
global $OUTPUT;
// Get the resulting stored_file record
$coursecontext = get_context_instance(CONTEXT_COURSE, $this->get_ui()->get_controller()->get_courseid());
$restorerul = new moodle_url('/backup/restorefile.php', array('contextid'=>$coursecontext->id));
$type = $this->get_ui()->get_controller()->get_type();
$courseid = $this->get_ui()->get_controller()->get_courseid();
switch ($type) {
case 'activity':
$cmid = $this->get_ui()->get_controller()->get_id();
$cm = get_coursemodule_from_id(null, $cmid, $courseid);
$modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
$restorerul = new moodle_url('/backup/restorefile.php', array('contextid'=>$modcontext->id));
break;
case 'course':
default:
$coursecontext = get_context_instance(CONTEXT_COURSE, $courseid);
$restorerul = new moodle_url('/backup/restorefile.php', array('contextid'=>$coursecontext->id));
}
echo $OUTPUT->box_start();
echo $OUTPUT->notification(get_string('executionsuccess', 'backup'), 'notifysuccess');

View File

@ -48,10 +48,12 @@ $string['backuptypeactivity'] = 'Activity';
$string['backuptypecourse'] = 'Course';
$string['backupversion'] = 'Backup version';
$string['cannotfindassignablerole'] = 'The {$a} role in the backup file cannot be mapped to any of the roles that you are allowed to assign.';
$string['choosefilefromcoursebackup'] = 'Choose an existing backup file from course backup area';
$string['choosefilefromcoursebackup'] = 'Course backup area';
$string['choosefilefromcoursebackup_help'] = 'When backup courses using default settings, backup files will be stored here';
$string['choosefilefromuserbackup'] = 'Choose an existing backup file from private backup area';
$string['choosefilefromuserbackup'] = 'User private backup area';
$string['choosefilefromuserbackup_help'] = 'When backup courses with "Anonymize user information" option ticked, backup files will be stored here';
$string['choosefilefromactivitybackup'] = 'Activity backup area';
$string['choosefilefromactivitybackup_help'] = 'When backup activities using default settings, backup files will be stored here';
$string['configgeneralactivities'] = 'Sets the default for including activities in a backup.';
$string['configgeneralanonymize'] = 'If enabled all information pertaining to users will be anonymised by default.';
$string['configgeneralblocks'] = 'Sets the default for including blocks in a backup.';

View File

@ -3146,6 +3146,13 @@ class settings_navigation extends navigation_node {
$modulenode->add(get_string('backup'), $url, self::TYPE_SETTING);
}
// Restore this activity
$featuresfunc = $this->page->activityname.'_supports';
if (function_exists($featuresfunc) && $featuresfunc(FEATURE_BACKUP_MOODLE2) && has_capability('moodle/restore:restoreactivity', $this->page->cm->context)) {
$url = new moodle_url('/backup/restorefile.php', array('contextid'=>$this->page->cm->context->id));
$modulenode->add(get_string('restore'), $url, self::TYPE_SETTING);
}
$function = $this->page->activityname.'_extend_settings_navigation';
if (!function_exists($function)) {
return $modulenode;