Added use of get_contextid and fixed some problems

This commit is contained in:
Mark Nielsen 2011-03-14 13:41:42 -07:00 committed by David Mudrak
parent a656fcb387
commit 56bd1ab0e1
2 changed files with 19 additions and 4 deletions

View File

@ -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')
));
}
}

View File

@ -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);