From 56bd1ab0e1b93bd0d9ce2023462fe2e67a4733a0 Mon Sep 17 00:00:00 2001 From: Mark Nielsen Date: Mon, 14 Mar 2011 13:41:42 -0700 Subject: [PATCH] Added use of get_contextid and fixed some problems --- backup/converter/moodle1/converter.class.php | 16 ++++++++++++++-- backup/util/helper/convert_helper.class.php | 7 +++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/backup/converter/moodle1/converter.class.php b/backup/converter/moodle1/converter.class.php index b91e02b2386..b202031ae0c 100644 --- a/backup/converter/moodle1/converter.class.php +++ b/backup/converter/moodle1/converter.class.php @@ -33,8 +33,17 @@ class moodle1_converter extends plan_converter { $this->get_plan()->add_task(new moodle1_root_task('root_task')); $this->get_plan()->add_task(new moodle1_course_task('courseinfo')); - $this->get_plan()->add_task(new moodle1_final_task('final_task')); + // $this->get_plan()->add_task(new moodle1_final_task('final_task')); // @todo OK, cannot do this here because things get processed after we parse xml... } + + public function destroy() { + parent::destroy(); + + // @todo Doing this here for now instead of via a task/step + backup_controller_dbops::drop_backup_ids_temp_table($this->get_id()); // Drop ids temp table + } + + } // @todo Where to store these classes? @@ -134,7 +143,10 @@ class moodle1_course_structure_step extends convert_structure_step { new file_xml_output($directory.'/course.xml') ); $this->xmlwriter->start(); - $this->xmlwriter->begin_tag('course', array('id' => $this->id, 'contextid' => 'TODO')); // @todo make contextid + $this->xmlwriter->begin_tag('course', array( + 'id' => $this->id, + 'contextid' => convert_helper::get_contextid($this->id, 'course') + )); } } diff --git a/backup/util/helper/convert_helper.class.php b/backup/util/helper/convert_helper.class.php index ee9477dd42c..a91dbfe9c0f 100644 --- a/backup/util/helper/convert_helper.class.php +++ b/backup/util/helper/convert_helper.class.php @@ -73,7 +73,10 @@ abstract class convert_helper { global $DB; // Attempt to retrieve the contextid - $contextid = $DB->get_field('backup_ids_temp', 'id', array('itemid' => $instance, 'info' => $component)); + $contextid = $DB->get_field_select('backup_ids_temp', 'id', + $DB->sql_compare_text('info', 100).' = ? AND itemid = ? AND itemname = ?', + array($component, $instance, 'context') + ); if (!empty($contextid)) { return $contextid; @@ -87,7 +90,7 @@ abstract class convert_helper { if (!is_null($converterid)) { $context->backupid = $converterid; } - if ($id = $DB->insert('backup_ids_temp', $context)) { + if ($id = $DB->insert_record('backup_ids_temp', $context)) { return $id; } else { $msg = self::obj_to_readable($context);