MDL-26513 restore - observe target site restrictmodulesfor setting
authorEloy Lafuente (stronk7) <stronk7@moodle.org>
Sat, 19 Feb 2011 21:27:37 +0000 (22:27 +0100)
committerEloy Lafuente (stronk7) <stronk7@moodle.org>
Mon, 21 Feb 2011 14:58:20 +0000 (15:58 +0100)
backup/moodle2/restore_stepslib.php

index 2939675..eace014 100644 (file)
@@ -1021,8 +1021,6 @@ class restore_course_structure_step extends restore_structure_step {
         global $CFG, $DB;
 
         $data = (object)$data;
-        $coursetags = isset($data->tags['tag']) ? $data->tags['tag'] : array();
-        $coursemodules = isset($data->allowed_modules['module']) ? $data->allowed_modules['module'] : array();
         $oldid = $data->id; // We'll need this later
 
         $fullname  = $this->get_setting_value('course_fullname');
@@ -1038,6 +1036,9 @@ class restore_course_structure_step extends restore_structure_step {
         $data->shortname= $shortname;
         $data->idnumber = '';
 
+        // Only restrict modules if original course was and target site too for new courses
+        $data->restrictmodules = $data->restrictmodules && !empty($CFG->restrictmodulesfor) && $CFG->restrictmodulesfor == 'all';
+
         $data->startdate= $this->apply_date_offset($data->startdate);
         if ($data->defaultgroupingid) {
             $data->defaultgroupingid = $this->get_mappingid('grouping', $data->defaultgroupingid);