Skip to content
Browse files

MDL-32233 core_course_duplicate_course: Fixed integrator review detai…

  • Loading branch information...
1 parent 9aa84e9 commit 6c7d3e3100f515317d6fbe410e5498e411d5780f @jleyva jleyva committed May 16, 2012
Showing with 14 additions and 5 deletions.
  1. +14 −5 course/externallib.php
View
19 course/externallib.php
@@ -805,15 +805,20 @@ public static function duplicate_course($courseid, $fullname, $shortname, $categ
$bc->execute_plan();
$results = $bc->get_results();
- $file = $results['backup_destination'];
+
+ if (!empty($results['backup_destination'])) {
+ $file = $results['backup_destination'];
+ } else {
+ $file = null;
+ }
+
$bc->destroy();
// Restore the backup immediately.
- // In a backup mode different than import, we need to unzip the file because the backup temp directory is deleted.
- if (!empty($backupsettings['users'])) {
- check_dir_exists($CFG->tempdir . '/backup');
- $file->extract_to_pathname(get_file_packer(), $CFG->tempdir . '/backup/' . $backupid);
+ // Check if we need to unzip the file because the backup temp dir does not contains backup files.
+ if ($file and !file_exists($backupbasepath . "/moodle_backup.xml")) {
+ $file->extract_to_pathname(get_file_packer(), $backupbasepath);
}
// Create new course.
@@ -867,6 +872,10 @@ public static function duplicate_course($courseid, $fullname, $shortname, $categ
fulldelete($backupbasepath);
}
+ if ($file) {
+ $file->delete();
+ }
+
return array('id' => $course->id, 'shortname' => $course->shortname);
}

0 comments on commit 6c7d3e3

Please sign in to comment.
Something went wrong with that request. Please try again.