Permalink
Browse files

Added use of get_contextid and fixed some problems

  • Loading branch information...
1 parent a656fcb commit 56bd1ab0e1b93bd0d9ce2023462fe2e67a4733a0 @mrmark mrmark committed with mudrd8mz Mar 14, 2011
Showing with 19 additions and 4 deletions.
  1. +14 −2 backup/converter/moodle1/converter.class.php
  2. +5 −2 backup/util/helper/convert_helper.class.php
@@ -33,8 +33,17 @@ public function build_plan() {
$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 @@ public function open_writer() {
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')
+ ));
}
}
@@ -73,7 +73,10 @@ public static function get_contextid($instance, $component = 'moodle', $converte
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 @@ public static function get_contextid($instance, $component = 'moodle', $converte
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);

0 comments on commit 56bd1ab

Please sign in to comment.