MDL-54771 restore: Add deletesource to course object

Since deleting a course now triggers the pre_course_delete hook
it may be useful for hook implementations to know whether it was
a "true" course deletion, or one originating from a temporary
course created during a restore.
This commit is contained in:
Cameron Ball 2016-07-06 23:11:31 +08:00
parent ac8d6cff54
commit 1706352d01

View File

@ -231,9 +231,11 @@ class restore_ui extends base_ui {
* Delete course which is created by restore process * Delete course which is created by restore process
*/ */
public function cleanup() { public function cleanup() {
global $DB;
$courseid = $this->controller->get_courseid(); $courseid = $this->controller->get_courseid();
if ($this->is_temporary_course_created($courseid)) { if ($this->is_temporary_course_created($courseid) && $course = $DB->get_record('course', array('id' => $courseid))) {
delete_course($courseid, false); $course->deletesource = 'restore';
delete_course($course, false);
} }
} }