Skip to content

Commit

Permalink
We need the newly created course_module id to be passed to the restore
Browse files Browse the repository at this point in the history
functions of the modules. We need this now for the forum module to convert
forums backed up in 1.6 to use roles upon restore in 1.7. However, this might
be needed for other modules as well if they need conversion to the roles
system.
  • Loading branch information
vyshane committed Aug 25, 2006
1 parent c779eb1 commit 7f6301c
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions backup/restorelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,7 @@ function restore_create_block_instances($restore,$xml_file) {
//This function creates all the course_sections and course_modules from xml
//when restoring in a new course or simply checks sections and create records
//in backup_ids when restoring in a existing course
function restore_create_sections($restore,$xml_file) {
function restore_create_sections(&$restore, $xml_file) {

global $CFG,$db;

Expand Down Expand Up @@ -842,7 +842,7 @@ function restore_create_sections($restore,$xml_file) {
//Now calculate the section's newid
$newid = 0;
if ($restore->restoreto == 2) {
//Save it to db (only if restoring to new course)
//Save it to db (only if restoring to new course)
$newid = insert_record("course_sections",$section);
} else {
//Get section id when restoring in existing course
Expand All @@ -856,7 +856,7 @@ function restore_create_sections($restore,$xml_file) {
}
//New check. If section 0 doesn't exist, insert it here !!
//Teorically this never should happen but, in practice, some users
//have reported this issue.
//have reported this issue.
if(!$rec) {
$zero_sec->course = $restore->course_id;
$zero_sec->section = 0;
Expand Down Expand Up @@ -886,6 +886,7 @@ function restore_create_sections($restore,$xml_file) {
if (!is_array($restore->mods[$mod->type]->instances) // we don't care about per instance
|| (array_key_exists($mod->instance,$restore->mods[$mod->type]->instances)
&& !empty($restore->mods[$mod->type]->instances[$mod->instance]->restore))) {

//Get the module id from modules
$module = get_record("modules","name",$mod->type);
if ($module) {
Expand All @@ -911,6 +912,8 @@ function restore_create_sections($restore,$xml_file) {
//to use it later
backup_putid ($restore->backup_unique_code,"course_modules",
$keym,$newidmod,$mod->instance);

$restore->mods[$mod->type]->instances[$mod->instance]->restored_as_course_module = $newidmod;
} else {
$status = false;
}
Expand Down Expand Up @@ -2463,7 +2466,6 @@ function restore_course_files($restore) {
function restore_create_modules($restore,$xml_file) {

global $CFG;

$status = true;
//Check it exists
if (!file_exists($xml_file)) {
Expand Down

0 comments on commit 7f6301c

Please sign in to comment.