Merge branch 'MDL-37078-m23' of git://github.com/sammarshallou/moodle into MOODLE_23_...
authorDan Poltawski <dan@moodle.com>
Mon, 17 Dec 2012 03:37:10 +0000 (11:37 +0800)
committerDan Poltawski <dan@moodle.com>
Mon, 17 Dec 2012 03:37:10 +0000 (11:37 +0800)
1  2 
backup/moodle2/restore_stepslib.php

@@@ -190,15 -190,6 +190,15 @@@ class restore_gradebook_structure_step 
                  $data->id = $newitemid = $existinggradeitem->id;
                  $DB->update_record('grade_items', $data);
              }
 +        } else if ($data->itemtype == 'manual') {
 +            // Manual items aren't assigned to a cm, so don't go duplicating them in the target if one exists.
 +            $gi = array(
 +                'itemtype' => $data->itemtype,
 +                'courseid' => $data->courseid,
 +                'itemname' => $data->itemname,
 +                'categoryid' => $data->categoryid,
 +            );
 +            $newitemid = $DB->get_field('grade_items', 'id', $gi);
          }
  
          if (empty($newitemid)) {
@@@ -1160,11 -1151,11 +1160,11 @@@ class restore_section_structure_step ex
          $sectionid = $this->get_task()->get_sectionid();
  
          // Get data object for current section availability (if any).
-         $data = $DB->get_record('course_sections_availability',
-                 array('coursesectionid' => $sectionid), 'id, sourcecmid, gradeitemid', IGNORE_MISSING);
+         $records = $DB->get_records('course_sections_availability',
+                 array('coursesectionid' => $sectionid), 'id, sourcecmid, gradeitemid');
  
          // If it exists, update mappings.
-         if ($data) {
+         foreach ($records as $data) {
              // Only update mappings for entries which are created by this restore.
              // Otherwise, when you restore to an existing course, it will mess up
              // existing section availability entries.
@@@ -2913,6 -2904,9 +2913,6 @@@ class restore_create_categories_and_que
              $data->penalty = 1;
          }
  
 -        $data->timecreated  = $this->apply_date_offset($data->timecreated);
 -        $data->timemodified = $this->apply_date_offset($data->timemodified);
 -
          $userid = $this->get_mappingid('user', $data->createdby);
          $data->createdby = $userid ? $userid : $this->task->get_userid();