MDL-35305 wiki: backup and restore files
authorMarina Glancy <marina@moodle.com>
Fri, 28 Mar 2014 02:26:01 +0000 (10:26 +0800)
committerMarina Glancy <marina@moodle.com>
Fri, 28 Mar 2014 02:30:45 +0000 (10:30 +0800)
Thanks to Tatsuya Shirai for the patch

mod/wiki/backup/moodle2/backup_wiki_stepslib.php
mod/wiki/backup/moodle2/restore_wiki_stepslib.php

index f0288b2..9119290 100644 (file)
@@ -120,7 +120,7 @@ class backup_wiki_activity_structure_step extends backup_activity_structure_step
 
         // Define file annotations
         $wiki->annotate_files('mod_wiki', 'intro', null); // This file area hasn't itemid
-        $page->annotate_files('mod_wiki', 'attachments', 'id'); // This file area hasn't itemid
+        $subwiki->annotate_files('mod_wiki', 'attachments', 'id'); // This file area hasn't itemid
 
         // Return the root element (wiki), wrapped into standard activity structure
         return $this->prepare_activity_structure($wiki);
index d57f32c..bae98dd 100644 (file)
@@ -91,7 +91,7 @@ class restore_wiki_activity_structure_step extends restore_activity_structure_st
             $newitemid = false;
         }
 
-        $this->set_mapping('wiki_subwiki', $oldid, $newitemid);
+        $this->set_mapping('wiki_subwiki', $oldid, $newitemid, true);
     }
 
     protected function process_wiki_page($data) {
@@ -174,6 +174,6 @@ class restore_wiki_activity_structure_step extends restore_activity_structure_st
     protected function after_execute() {
         // Add wiki related files, no need to match by itemname (just internally handled context)
         $this->add_related_files('mod_wiki', 'intro', null);
-        $this->add_related_files('mod_wiki', 'attachments', 'wiki_page');
+        $this->add_related_files('mod_wiki', 'attachments', 'wiki_subwiki');
     }
 }