From 39aa0280e101f4dded1e461451d3fe75a3b88d9e Mon Sep 17 00:00:00 2001 From: Eloy Lafuente Date: Sat, 31 Jul 2010 22:22:51 +0000 Subject: [PATCH] MDL-21432 backup - fix for non-page comments (glossary...) --- backup/moodle2/restore_activity_task.class.php | 10 ++++++++++ backup/moodle2/restore_stepslib.php | 7 +++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/backup/moodle2/restore_activity_task.class.php b/backup/moodle2/restore_activity_task.class.php index 800252723fe..9c979f3a350 100644 --- a/backup/moodle2/restore_activity_task.class.php +++ b/backup/moodle2/restore_activity_task.class.php @@ -196,6 +196,16 @@ abstract class restore_activity_task extends restore_task { } } + /** + * Given a commment area, return the itemname that contains the itemid mappings + * + * By default both are the same (commentarea = itemname), so return it. If some + * module uses a different approach, this method can be overriden in its taks + */ + public function get_comment_mapping_itemname($commentarea) { + return $commentarea; + } + /** * Define (add) particular steps that each activity can have */ diff --git a/backup/moodle2/restore_stepslib.php b/backup/moodle2/restore_stepslib.php index 3792e5186fc..9a787b9061c 100644 --- a/backup/moodle2/restore_stepslib.php +++ b/backup/moodle2/restore_stepslib.php @@ -872,13 +872,12 @@ class restore_comments_structure_step extends restore_structure_step { // First of all, if the comment has some itemid, ask to the task what to map $mapping = false; - $newitemid = 0; if ($data->itemid) { - $mapping = $this->task->get_comment_mapping_itemname(); - $newitemid = $this->get_mappingid($mapping, $data->itemid); + $mapping = $this->task->get_comment_mapping_itemname($data->commentarea); + $data->itemid = $this->get_mappingid($mapping, $data->itemid); } // Only restore the comment if has no mapping OR we have found the matching mapping - if (!$mapping || $newitemid) { + if (!$mapping || $data->itemid) { // Only if user mapping and context $data->userid = $this->get_mappingid('user', $data->userid); if ($data->userid && $this->task->get_contextid()) {