Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

MDL-27442 forum: allow forum to be restored into 2.1 from a 1.9 backup

  • Loading branch information...
commit ab1da2675d9bcfefcc0be3e34b4309bc5f2cb039 1 parent 46ff8b0
@andyjdavis andyjdavis authored mudrd8mz committed
Showing with 43 additions and 1 deletion.
  1. +43 −1 mod/forum/backup/moodle1/lib.php
View
44 mod/forum/backup/moodle1/lib.php
@@ -46,7 +46,20 @@ class moodle1_mod_forum_handler extends moodle1_mod_handler {
*/
public function get_paths() {
return array(
- new convert_path('forum', '/MOODLE_BACKUP/COURSE/MODULES/MOD/FORUM'),
+ new convert_path('forum', '/MOODLE_BACKUP/COURSE/MODULES/MOD/FORUM',
+ array(
+ 'renamefields' => array(
+ 'format' => 'messageformat',
+ ),
+ 'newfields' => array(
+ 'completiondiscussions' => 0,
+ 'completionreplies' => 0,
+ 'completionpost' => 0,
+ 'maxattachments' => 1,
+ 'introformat' => 0,
+ ),
+ )
+ ),
);
}
@@ -54,5 +67,34 @@ public function get_paths() {
* Converts /MOODLE_BACKUP/COURSE/MODULES/MOD/FORUM data
*/
public function process_forum($data) {
+ // get the course module id and context id
+ $instanceid = $data['id'];
+ $moduleid = $this->get_moduleid($instanceid);
+ $contextid = $this->converter->get_contextid(CONTEXT_MODULE, $moduleid);
+
+ // we now have all information needed to start writing into the file
+ $this->open_xml_writer("activities/forum_{$moduleid}/forum.xml");
+ $this->xmlwriter->begin_tag('activity', array('id' => $instanceid, 'moduleid' => $moduleid,
+ 'modulename' => 'forum', 'contextid' => $contextid));
+ $this->xmlwriter->begin_tag('forum', array('id' => $instanceid));
+
+ unset($data['id']); // we already write it as attribute, do not repeat it as child element
+ foreach ($data as $field => $value) {
+ $this->xmlwriter->full_tag($field, $value);
+ }
+
+ $this->xmlwriter->begin_tag('discussions');
+ }
+
+ /**
+ * This is executed when we reach the closing </MOD> tag of our 'forum' path
+ */
+ public function on_forum_end() {
+ $this->xmlwriter->end_tag('discussions');
+ $this->xmlwriter->end_tag('forum');
+ $this->xmlwriter->end_tag('activity');
+ $this->close_xml_writer();
}
+
+ //conversion of discussion, posts etc will be implemented in a future version of Moodle
}
Please sign in to comment.
Something went wrong with that request. Please try again.