Index: backup/backupfilesedit.php ========================================================= --- backup/backupfilesedit.php (revision 1.3) +++ backup/backupfilesedit.php Mon Nov 01 14:19:18 WST 2010 @@ -45,6 +45,9 @@ $PAGE->set_url($url); $PAGE->set_context($context); +if ($context->contextlevel == CONTEXT_MODULE) { + $PAGE->set_cm($cm); +} $PAGE->set_title(get_string('managefiles', 'backup')); $PAGE->set_heading(get_string('managefiles', 'backup')); $PAGE->set_pagelayout('admin'); Index: backup/restorefile.php ========================================================= --- backup/restorefile.php (revision 1.4) +++ backup/restorefile.php Mon Nov 01 14:18:00 WST 2010 @@ -50,6 +50,7 @@ switch ($context->contextlevel) { case CONTEXT_MODULE: + $PAGE->set_cm($cm); $heading = get_string('restoreactivity', 'backup'); break; case CONTEXT_COURSE: @@ -112,6 +113,21 @@ 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 +140,6 @@ 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(); Index: backup/util/ui/backup_ui_stage.class.php ========================================================= --- backup/util/ui/backup_ui_stage.class.php (revision 1.13) +++ backup/util/ui/backup_ui_stage.class.php Mon Nov 01 18:03:45 WST 2010 @@ -453,8 +453,20 @@ 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'); Index: lang/en/backup.php ========================================================= --- lang/en/backup.php (revision 1.24) +++ lang/en/backup.php Fri Oct 29 14:11:39 WST 2010 @@ -48,10 +48,12 @@ $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.'; Index: lib/navigationlib.php ========================================================= --- lib/navigationlib.php (revision 1.199) +++ lib/navigationlib.php Fri Oct 29 14:07:43 WST 2010 @@ -3146,6 +3146,13 @@ $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;