Skip to content

Commit

Permalink
Merge branch 'MDL-26841_20' of git://github.com/stronk7/moodle into M…
Browse files Browse the repository at this point in the history
…OODLE_20_STABLE
  • Loading branch information
Sam Hemelryk committed Sep 20, 2011
2 parents 0243159 + aed1ff8 commit 5e51b68
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 5 deletions.
6 changes: 4 additions & 2 deletions backup/moodle2/backup_course_task.class.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -72,8 +72,10 @@ public function build() {
// annotating some bits, tags and module restrictions // annotating some bits, tags and module restrictions
$this->add_step(new backup_course_structure_step('course_info', 'course.xml')); $this->add_step(new backup_course_structure_step('course_info', 'course.xml'));


// Generate the enrolment file // Generate the enrolment file (conditionally, prevent it in any IMPORT/HUB operation)
$this->add_step(new backup_enrolments_structure_step('course_enrolments', 'enrolments.xml')); if (!$this->plan->get_mode() == backup::MODE_IMPORT && !$this->plan->get_mode() == backup::MODE_HUB) {
$this->add_step(new backup_enrolments_structure_step('course_enrolments', 'enrolments.xml'));
}


// Annotate all the groups and groupings belonging to the course // Annotate all the groups and groupings belonging to the course
$this->add_step(new backup_annotate_course_groups_and_groupings('annotate_course_groups')); $this->add_step(new backup_annotate_course_groups_and_groupings('annotate_course_groups'));
Expand Down
6 changes: 4 additions & 2 deletions backup/moodle2/restore_course_task.class.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -69,8 +69,10 @@ public function build() {
// Restore course role assignments and overrides (internally will observe the role_assignments setting) // Restore course role assignments and overrides (internally will observe the role_assignments setting)
$this->add_step(new restore_ras_and_caps_structure_step('course_ras_and_caps', 'roles.xml')); $this->add_step(new restore_ras_and_caps_structure_step('course_ras_and_caps', 'roles.xml'));


// Restore course enrolments (plugins and membership) // Restore course enrolments (plugins and membership). Conditionally prevented for any IMPORT/HUB operation
$this->add_step(new restore_enrolments_structure_step('course_enrolments', 'enrolments.xml')); 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'));
}


// Restore course filters (conditionally) // Restore course filters (conditionally)
if ($this->get_setting_value('filters')) { if ($this->get_setting_value('filters')) {
Expand Down
24 changes: 23 additions & 1 deletion backup/moodle2/restore_stepslib.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -1281,6 +1281,28 @@ public function process_override($data) {
*/ */
class restore_enrolments_structure_step extends restore_structure_step { class restore_enrolments_structure_step extends restore_structure_step {


/**
* Conditionally decide if this step should be executed.
*
* This function checks the following parameter:
*
* 1. the course/enrolments.xml file exists
*
* @return bool true is safe to execute, false otherwise
*/
protected function execute_condition() {

// Check it is included in the backup
$fullpath = $this->task->get_taskbasepath();
$fullpath = rtrim($fullpath, '/') . '/' . $this->filename;
if (!file_exists($fullpath)) {
// Not found, can't restore enrolments info
return false;
}

return true;
}

protected function define_structure() { protected function define_structure() {


$paths = array(); $paths = array();
Expand Down Expand Up @@ -1739,7 +1761,7 @@ class restore_course_logs_structure_step extends restore_structure_step {
/** /**
* Conditionally decide if this step should be executed. * Conditionally decide if this step should be executed.
* *
* This function checks the following four parameters: * This function checks the following parameter:
* *
* 1. the course/logs.xml file exists * 1. the course/logs.xml file exists
* *
Expand Down

0 comments on commit 5e51b68

Please sign in to comment.