backup MDL-24067 Fixed up bug causing restore to reset course category to the first category.

This commit is contained in:
Sam Hemelryk 2010-09-13 03:12:44 +00:00
parent df6f9bbfc1
commit 7f32340be1
2 changed files with 11 additions and 5 deletions

View File

@ -140,8 +140,7 @@ class restore_course_task extends restore_task {
$overwrite = new restore_course_overwrite_conf_setting('overwrite_conf', base_setting::IS_BOOLEAN, false);
$overwrite->set_ui(new backup_setting_ui_select($overwrite, $overwrite->get_name(), array(1=>get_string('yes'), 0=>get_string('no'))));
$overwrite->get_ui()->set_label(get_string('setting_overwriteconf', 'backup'));
$fixedtargets = array(backup::TARGET_NEW_COURSE, backup::TARGET_EXISTING_DELETING, backup::TARGET_CURRENT_DELETING);
if (in_array($this->get_target(), $fixedtargets)) {
if ($this->get_target() == backup::TARGET_NEW_COURSE) {
$overwrite->set_value(true);
$overwrite->set_status(backup_setting::LOCKED_BY_CONFIG);
$overwrite->set_visibility(backup_setting::HIDDEN);

View File

@ -853,7 +853,12 @@ class restore_course_structure_step extends restore_structure_step {
return array($course, $category, $tag, $allowed);
}
// Processing functions go here
/**
* Processing functions go here
*
* @global moodledatabase $DB
* @param stdClass $data
*/
public function process_course($data) {
global $CFG, $DB;
@ -874,8 +879,10 @@ class restore_course_structure_step extends restore_structure_step {
$data->fullname = $fullname;
$data->shortname= $shortname;
$data->idnumber = '';
// TODO: Set category from the UI, its not a setting just a param
$data->category = get_course_category()->id;
// Category is set by UI when choosing the destination
unset($data->category);
$data->startdate= $this->apply_date_offset($data->startdate);
if ($data->defaultgroupingid) {
$data->defaultgroupingid = $this->get_mappingid('grouping', $data->defaultgroupingid);