From b0f0200e4f3a73618b1080119f6f86b00c08dc41 Mon Sep 17 00:00:00 2001 From: Mark Nelson Date: Tue, 2 May 2017 13:26:39 +0800 Subject: [PATCH] MDL-56251 backup: trigger course_section_created/updated events --- backup/moodle2/restore_stepslib.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/backup/moodle2/restore_stepslib.php b/backup/moodle2/restore_stepslib.php index a0fc0592d0f..d4757be2766 100644 --- a/backup/moodle2/restore_stepslib.php +++ b/backup/moodle2/restore_stepslib.php @@ -1593,6 +1593,10 @@ class restore_section_structure_step extends restore_structure_step { } } $newitemid = $DB->insert_record('course_sections', $section); + $section->id = $newitemid; + + core\event\course_section_created::create_from_section($section)->trigger(); + $restorefiles = true; // Section exists, update non-empty information @@ -1612,6 +1616,17 @@ class restore_section_structure_step extends restore_structure_step { $DB->update_record('course_sections', $section); $newitemid = $secrec->id; + + // Trigger an event for course section update. + $event = \core\event\course_section_updated::create( + array( + 'objectid' => $section->id, + 'courseid' => $section->course, + 'context' => context_course::instance($section->course), + 'other' => array('sectionnum' => $section->section) + ) + ); + $event->trigger(); } // Annotate the section mapping, with restorefiles option if needed -- 2.11.4.GIT