MDL-53367 mod_forum: Subscribe current users when importing a forum
authorJuan Segarra Montesinos <juan.segarra@uji.es>
Wed, 2 Nov 2016 09:30:49 +0000 (10:30 +0100)
committerJuan Segarra Montesinos <juan.segarra@uji.es>
Fri, 16 Dec 2016 08:46:07 +0000 (09:46 +0100)
Subscribes currently enrolled users when importing a forum with
automatic subscription enabled.

mod/forum/backup/moodle2/restore_forum_stepslib.php

index 1ece799..de8b038 100644 (file)
@@ -67,6 +67,11 @@ class restore_forum_activity_structure_step extends restore_activity_structure_s
 
         $newitemid = $DB->insert_record('forum', $data);
         $this->apply_activity_instance($newitemid);
 
         $newitemid = $DB->insert_record('forum', $data);
         $this->apply_activity_instance($newitemid);
+
+        // Add current enrolled user subscriptions if necessary.
+        $data->id = $newitemid;
+        $ctx = context_module::instance($this->task->get_moduleid());
+        forum_instance_created($ctx, $data);
     }
 
     protected function process_forum_discussion($data) {
     }
 
     protected function process_forum_discussion($data) {