MDL-30797 backup: Use correct API call for mapping groups to groupings on import...
authorAdam Olley <adam.olley@netspot.com.au>
Thu, 3 May 2012 07:08:37 +0000 (16:38 +0930)
committerAdrian Greeve <adrian@moodle.com>
Mon, 14 Jan 2013 07:15:05 +0000 (15:15 +0800)
backup/moodle2/restore_stepslib.php

index 740c202..8a2578a 100644 (file)
@@ -843,20 +843,9 @@ class restore_groups_structure_step extends restore_structure_step {
     }
 
     public function process_grouping_group($data) {
-        global $DB;
-
-        $data = (object)$data;
-
-        $data->groupingid = $this->get_new_parentid('grouping'); // Use new parentid
-        $data->groupid    = $this->get_mappingid('group', $data->groupid); // Get from mappings
-
-        $params = array();
-        $params['groupingid'] = $data->groupingid;
-        $params['groupid']    = $data->groupid;
-
-        if (!$DB->record_exists('groupings_groups', $params)) {
-            $DB->insert_record('groupings_groups', $data);  // No need to set this mapping (no child info nor files)
-        }
+        global $CFG;
+        require_once($CFG->dirroot.'/group/lib.php');
+        groups_assign_grouping($this->get_new_parentid('grouping'), $this->get_mappingid('group', $data->groupid));
     }
 
     protected function after_execute() {