backup MDL-24067 Fixed up bug causing restore to reset course category to the first...
authorSam Hemelryk <sam@moodle.com>
Mon, 13 Sep 2010 03:12:44 +0000 (03:12 +0000)
committerSam Hemelryk <sam@moodle.com>
Mon, 13 Sep 2010 03:12:44 +0000 (03:12 +0000)
backup/moodle2/restore_course_task.class.php
backup/moodle2/restore_stepslib.php

index 7570b38..9994d1b 100644 (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);
index b049f03..f7061bb 100644 (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);