Skip to content

Commit

Permalink
Merge branch 'MDL-25631' of git://github.com/merrill-oakland/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
Damyon Wiese committed Mar 28, 2013
2 parents 5020644 + c9deaa8 commit 86d66b5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 2 additions & 0 deletions backup/moodle2/restore_course_task.class.php
Expand Up @@ -71,6 +71,8 @@ public function build() {
$this->add_step(new restore_course_structure_step('course_info', 'course.xml'));
}

$this->add_step(new restore_course_legacy_files_step('legacy_files'));

// Restore course enrolments (plugins and membership). Conditionally prevented for any IMPORT/HUB operation
if ($this->plan->get_mode() != backup::MODE_IMPORT && $this->plan->get_mode() != backup::MODE_HUB) {
$this->add_step(new restore_enrolments_structure_step('course_enrolments', 'enrolments.xml'));
Expand Down
24 changes: 23 additions & 1 deletion backup/moodle2/restore_stepslib.php
Expand Up @@ -1459,7 +1459,6 @@ protected function after_execute() {

// Add course related files, without itemid to match
$this->add_related_files('course', 'summary', null);
$this->add_related_files('course', 'legacy', null);

// Deal with legacy allowed modules.
if ($this->legacyrestrictmodules) {
Expand All @@ -1486,6 +1485,29 @@ protected function after_execute() {
}
}

/**
* Execution step that will migrate legacy files if present.
*/
class restore_course_legacy_files_step extends restore_execution_step {
public function define_execution() {
global $DB;

// Do a check for legacy files and skip if there are none.
$sql = 'SELECT count(*)
FROM {backup_files_temp}
WHERE backupid = ?
AND contextid = ?
AND component = ?
AND filearea = ?';
$params = array($this->get_restoreid(), $this->task->get_old_contextid(), 'course', 'legacy');

if ($DB->count_records_sql($sql, $params)) {
$DB->set_field('course', 'legacyfiles', 2, array('id' => $this->get_courseid()));
restore_dbops::send_files_to_pool($this->get_basepath(), $this->get_restoreid(), 'course',
'legacy', $this->task->get_old_contextid(), $this->task->get_userid());
}
}
}

/*
* Structure step that will read the roles.xml file (at course/activity/block levels)
Expand Down

0 comments on commit 86d66b5

Please sign in to comment.