Skip to content

Commit

Permalink
Backup and restore feature
Browse files Browse the repository at this point in the history
Backup and restore feature
  • Loading branch information
Flottertotte committed Dec 6, 2017
1 parent 7bf03c9 commit 76a8195
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -479,4 +479,30 @@ private function update_mail_content($content, $course, $user) {
}
return $content;
}

/**
* Backup execution step hook.
*
* @param backup_enrolments_execution_step $step
* @param stdClass $enrol
*/
public function backup_annotate_custom_fields(backup_enrolments_execution_step $step, stdClass $enrol) {
// annotate customint1 as a role
$step->annotate_id('role', $enrol->customint1);
}

public function restore_instance(restore_enrolments_structure_step $step, stdClass $data, $course, $oldid) {
global $DB, $CFG;

$data->customint1 = $step->get_mappingid('role', $data->customint1, null);

$instanceid = $this->add_instance($course, (array)$data);
$step->set_mapping('enrol', $oldid, $instanceid);

//$this->sync_enrols($DB->get_record('enrol', array('id'=>$instanceid)));
}

public function restore_user_enrolment(restore_enrolments_structure_step $step, $data, $instance, $userid, $oldinstancestatus) {
$this->enrol_user($instance, $userid, null, $data->timestart, $data->timeend, $oldinstancestatus);
}
}

0 comments on commit 76a8195

Please sign in to comment.