Skip to content

Commit

Permalink
MDL-27442 forum: allow forum to be restored into 2.1 from a 1.9 backup
Browse files Browse the repository at this point in the history
  • Loading branch information
andyjdavis authored and mudrd8mz committed May 19, 2011
1 parent 46ff8b0 commit ab1da26
Showing 1 changed file with 43 additions and 1 deletion.
44 changes: 43 additions & 1 deletion mod/forum/backup/moodle1/lib.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -46,13 +46,55 @@ class moodle1_mod_forum_handler extends moodle1_mod_handler {
*/ */
public function get_paths() { public function get_paths() {
return array( 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,
),
)
),
); );
} }


/** /**
* Converts /MOODLE_BACKUP/COURSE/MODULES/MOD/FORUM data * Converts /MOODLE_BACKUP/COURSE/MODULES/MOD/FORUM data
*/ */
public function process_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
} }

0 comments on commit ab1da26

Please sign in to comment.