Skip to content

Commit

Permalink
MDL-32233 core_course_duplicate_course: Fixed integrator review detai…
Browse files Browse the repository at this point in the history
  • Loading branch information
jleyva committed May 16, 2012
1 parent 9aa84e9 commit 6c7d3e3
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions course/externallib.php
Expand Up @@ -805,15 +805,20 @@ public static function duplicate_course($courseid, $fullname, $shortname, $categ


$bc->execute_plan(); $bc->execute_plan();
$results = $bc->get_results(); $results = $bc->get_results();
$file = $results['backup_destination'];
if (!empty($results['backup_destination'])) {
$file = $results['backup_destination'];
} else {
$file = null;
}

$bc->destroy(); $bc->destroy();


// Restore the backup immediately. // Restore the backup immediately.


// In a backup mode different than import, we need to unzip the file because the backup temp directory is deleted. // Check if we need to unzip the file because the backup temp dir does not contains backup files.
if (!empty($backupsettings['users'])) { if ($file and !file_exists($backupbasepath . "/moodle_backup.xml")) {
check_dir_exists($CFG->tempdir . '/backup'); $file->extract_to_pathname(get_file_packer(), $backupbasepath);
$file->extract_to_pathname(get_file_packer(), $CFG->tempdir . '/backup/' . $backupid);
} }


// Create new course. // Create new course.
Expand Down Expand Up @@ -867,6 +872,10 @@ public static function duplicate_course($courseid, $fullname, $shortname, $categ
fulldelete($backupbasepath); fulldelete($backupbasepath);
} }


if ($file) {
$file->delete();
}

return array('id' => $course->id, 'shortname' => $course->shortname); return array('id' => $course->id, 'shortname' => $course->shortname);
} }


Expand Down

0 comments on commit 6c7d3e3

Please sign in to comment.