Skip to content

Commit

Permalink
"MDL-12077, add course delete hook for course format"
Browse files Browse the repository at this point in the history
  • Loading branch information
dongsheng committed Jan 12, 2009
1 parent 3b3370f commit 034f441
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion lib/moodlelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 034f441

Please sign in to comment.