Browse Source

Fixes #265 create calendar events when restoring an attendance.

also add sanity check if restored session doesn't have a calendar event.
MOODLE_32_STABLE
Dan Marsden 8 years ago
parent
commit
5337794927
  1. 4
      backup/moodle2/restore_attendance_stepslib.php
  2. 6
      classes/structure.php

4
backup/moodle2/restore_attendance_stepslib.php

@ -120,7 +120,11 @@ class restore_attendance_activity_structure_step extends restore_activity_struct
$data->caleventid = $this->get_mappingid('event', $data->caleventid); $data->caleventid = $this->get_mappingid('event', $data->caleventid);
$newitemid = $DB->insert_record('attendance_sessions', $data); $newitemid = $DB->insert_record('attendance_sessions', $data);
$data->id = $newitemid;
$this->set_mapping('attendance_session', $oldid, $newitemid, true); $this->set_mapping('attendance_session', $oldid, $newitemid, true);
// Create Calendar event.
attendance_create_calendar_event($data);
} }
/** /**

6
classes/structure.php

@ -513,8 +513,12 @@ class mod_attendance_structure {
$sess->timemodified = time(); $sess->timemodified = time();
$DB->update_record('attendance_sessions', $sess); $DB->update_record('attendance_sessions', $sess);
if (empty($sess->caleventid)) {
// This shouldn't really happen, but just in case to prevent fatal error.
attendance_create_calendar_event($sess);
} else {
attendance_update_calendar_event($sess->caleventid, $sess->duration, $sess->sessdate); attendance_update_calendar_event($sess->caleventid, $sess->duration, $sess->sessdate);
}
$info = construct_session_full_date_time($sess->sessdate, $sess->duration); $info = construct_session_full_date_time($sess->sessdate, $sess->duration);
$event = \mod_attendance\event\session_updated::create(array( $event = \mod_attendance\event\session_updated::create(array(

Loading…
Cancel
Save