/** * Hook called before we delete a course. * * @param \stdClass $course The course record. */ function tool_recyclebin_pre_course_delete($course) { // Delete all the items in the course recycle bin, regardless if it enabled or not. // It may have been enabled, then disabled later on, so may still have content. $coursebin = new \tool_recyclebin\course_bin($course->id); $coursebin->delete_all_items(); if (\tool_recyclebin\category_bin::is_enabled()) { $categorybin = new \tool_recyclebin\category_bin($course->category); $categorybin->store_item($course); } }
/** * Hook called before we delete a course. * * @param \stdClass $course The course record. */ function tool_recyclebin_pre_course_delete($course) { // It is possible that the course deletion which triggered this hook // was from an in progress course restore. In that case we do not want // it in the recycle bin. if (isset($course->deletesource) && $course->deletesource == 'restore') { return; } // Delete all the items in the course recycle bin, regardless if it enabled or not. // It may have been enabled, then disabled later on, so may still have content. $coursebin = new \tool_recyclebin\course_bin($course->id); $coursebin->delete_all_items(); if (\tool_recyclebin\category_bin::is_enabled()) { $categorybin = new \tool_recyclebin\category_bin($course->category); $categorybin->store_item($course); } }