]> git.mjollnir.org Git - moodle.git/commitdiff
"MDL-12077, add course delete hook for course format"
authordongsheng <dongsheng>
Mon, 12 Jan 2009 06:24:00 +0000 (06:24 +0000)
committerdongsheng <dongsheng>
Mon, 12 Jan 2009 06:24:00 +0000 (06:24 +0000)
lib/moodlelib.php

index c37176c7953cb6589b7199d6ed4844a58769a683..4e6451366d7860aadb9d9b908d1f4712d181cfde 100644 (file)
@@ -3537,7 +3537,23 @@ function remove_course_contents($courseid, $showfeedback=true) {
 
     $strdeleted = get_string('deleted');
 
-/// First delete every instance of every module
+/// Clean up course formats (iterate through all formats in the even the course format was ever changed)
+    $formats = get_list_of_plugins('course/format');
+    foreach ($formats as $format) {
+        $formatdelete = $format.'_course_format_delete_course';
+        $formatlib    = "$CFG->dirroot/course/format/$format/lib.php";
+        if (file_exists($formatlib)) {
+            include_once($formatlib);
+            if (function_exists($formatdelete)) {
+                if ($showfeedback) {
+                    notify($strdeleted.' '.$format);
+                }
+                $formatdelete($course->id);
+            }
+        }
+    }
+
+/// Delete every instance of every module
 
     if ($allmods = $DB->get_records('modules') ) {
         foreach ($allmods as $mod) {