Index: lib/moodlelib.php =================================================================== --- lib/moodlelib.php (revision 1025) +++ lib/moodlelib.php (working copy) @@ -3127,21 +3127,21 @@ } } -/// Clean up course format stuff (iterate through all formats in the even the course format was ever changed - $dir = opendir($CFG->dirroot.'/course/format'); - while (false !== ($file = readdir($dir))) { - if (is_dir($CFG->dirroot.'/course/format/'.$file)) { - if (file_exists($CFG->dirroot.'/course/format/'.$file.'/lib.php')) { - include_once($CFG->dirroot.'/course/format/'.$file.'/lib.php'); - $fname = $file.'_delete_course'; - if (function_exists($fname)) { - notify($strdeleted. ' '. $file); - $fname($course->id); +/// 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.'_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); } } } - closedir($dir); /// Clean up metacourse stuff