mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 00:12:56 +02:00
MDL-37291 implement full paypal restore support
This commit is contained in:
parent
0dc5a532ec
commit
471b96c41e
@ -207,6 +207,49 @@ class enrol_paypal_plugin extends enrol_plugin {
|
||||
return $OUTPUT->box(ob_get_clean());
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore instance and map settings.
|
||||
*
|
||||
* @param restore_enrolments_structure_step $step
|
||||
* @param stdClass $data
|
||||
* @param stdClass $course
|
||||
* @param int $oldid
|
||||
*/
|
||||
public function restore_instance(restore_enrolments_structure_step $step, stdClass $data, $course, $oldid) {
|
||||
global $DB;
|
||||
if ($step->get_task()->get_target() == backup::TARGET_NEW_COURSE) {
|
||||
$merge = false;
|
||||
} else {
|
||||
$merge = array(
|
||||
'courseid' => $data->courseid,
|
||||
'enrol' => $this->get_name(),
|
||||
'roleid' => $data->roleid,
|
||||
'cost' => $data->cost,
|
||||
'currency' => $data->currency,
|
||||
);
|
||||
}
|
||||
if ($merge and $instances = $DB->get_records('enrol', $merge, 'id')) {
|
||||
$instance = reset($instances);
|
||||
$instanceid = $instance->id;
|
||||
} else {
|
||||
$instanceid = $this->add_instance($course, (array)$data);
|
||||
}
|
||||
$step->set_mapping('enrol', $oldid, $instanceid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore user enrolment.
|
||||
*
|
||||
* @param restore_enrolments_structure_step $step
|
||||
* @param stdClass $data
|
||||
* @param stdClass $instance
|
||||
* @param int $oldinstancestatus
|
||||
* @param int $userid
|
||||
*/
|
||||
public function restore_user_enrolment(restore_enrolments_structure_step $step, $data, $instance, $userid, $oldinstancestatus) {
|
||||
$this->enrol_user($instance, $userid, null, $data->timestart, $data->timeend, $data->status);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an array of the user enrolment actions
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user