Browse Source

Fix #287 prevent restore from setting takenby when no userdata restored.

MOODLE_31_STABLE
Dan Marsden 7 years ago
parent
commit
5d8cb7cd06
  1. 12
      backup/moodle2/restore_attendance_stepslib.php

12
backup/moodle2/restore_attendance_stepslib.php

@ -108,17 +108,25 @@ class restore_attendance_activity_structure_step extends restore_activity_struct
protected function process_attendance_session($data) { protected function process_attendance_session($data) {
global $DB; global $DB;
$userinfo = $this->get_setting_value('userinfo'); // Are we including userinfo?
$data = (object)$data; $data = (object)$data;
$oldid = $data->id; $oldid = $data->id;
$data->attendanceid = $this->get_new_parentid('attendance'); $data->attendanceid = $this->get_new_parentid('attendance');
$data->groupid = $this->get_mappingid('group', $data->groupid); $data->groupid = $this->get_mappingid('group', $data->groupid);
$data->sessdate = $this->apply_date_offset($data->sessdate); $data->sessdate = $this->apply_date_offset($data->sessdate);
$data->lasttaken = $this->apply_date_offset($data->lasttaken);
$data->lasttakenby = $this->get_mappingid('user', $data->lasttakenby);
$data->timemodified = $this->apply_date_offset($data->timemodified); $data->timemodified = $this->apply_date_offset($data->timemodified);
$data->caleventid = $this->get_mappingid('event', $data->caleventid); $data->caleventid = $this->get_mappingid('event', $data->caleventid);
if ($userinfo) {
$data->lasttaken = $this->apply_date_offset($data->lasttaken);
$data->lasttakenby = $this->get_mappingid('user', $data->lasttakenby);
} else {
$data->lasttaken = 0;
$data->lasttakenby = 0;
}
$newitemid = $DB->insert_record('attendance_sessions', $data); $newitemid = $DB->insert_record('attendance_sessions', $data);
$this->set_mapping('attendance_session', $oldid, $newitemid, true); $this->set_mapping('attendance_session', $oldid, $newitemid, true);
} }

Loading…
Cancel
Save