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_31_STABLE
Dan Marsden 8 years ago
parent
commit
5081c982e7
  1. 4
      backup/moodle2/restore_attendance_stepslib.php
  2. 8
      classes/structure.php

4
backup/moodle2/restore_attendance_stepslib.php

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

8
classes/structure.php

@ -403,8 +403,12 @@ class mod_attendance_structure {
$sess->timemodified = time();
$DB->update_record('attendance_sessions', $sess);
attendance_update_calendar_event($sess->caleventid, $sess->duration, $sess->sessdate);
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);
}
$info = construct_session_full_date_time($sess->sessdate, $sess->duration);
$event = \mod_attendance\event\session_updated::create(array(

Loading…
Cancel
Save