Skip to content

Commit

Permalink
MDL-24917, display activity backup area in restore-pre ui
Browse files Browse the repository at this point in the history
  • Loading branch information
Dongsheng Cai committed Nov 2, 2010
1 parent 3844370 commit d0da42d
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 7 deletions.
2 changes: 1 addition & 1 deletion backup/backupfilesedit.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

$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);
Expand Down
18 changes: 16 additions & 2 deletions backup/restorefile.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
}


require_login($course);
require_login($course, false, $cm);
require_capability('moodle/restore:restorecourse', $context);

$browser = get_file_browser();
Expand Down Expand Up @@ -112,6 +112,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();
Expand All @@ -124,7 +139,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();
Expand Down
16 changes: 14 additions & 2 deletions backup/util/ui/backup_ui_stage.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -453,8 +453,20 @@ public function display() {
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');
Expand Down
6 changes: 4 additions & 2 deletions lang/en/backup.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.';
Expand Down
7 changes: 7 additions & 0 deletions lib/navigationlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -3146,6 +3146,13 @@ protected function load_module_settings() {
$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;
Expand Down

0 comments on commit d0da42d

Please sign in to comment.