Index: mod/forum/lib.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/forum/lib.php,v retrieving revision 1.514 diff -u -r1.514 lib.php --- mod/forum/lib.php 1 Dec 2006 05:21:22 -0000 1.514 +++ mod/forum/lib.php 11 Dec 2006 11:44:54 -0000 @@ -4436,6 +4436,14 @@ notify($strreset.': '.get_string('resetsubscriptions','forum'), 'notifysuccess'); } } + // Cleaning up: deleting forum discussions that have no posts in them + $sql = "DELETE FROM {$CFG->prefix}forum_discussions + WHERE firstpost NOT IN ( + SELECT id FROM {$CFG->prefix}forum_posts + ) AND course = {$data->courseid}"; + if (execute_sql($sql, false) and $showfeedback) { + notify($strreset.': '.get_string('resetdiscussions','forum'), 'notifysuccess'); + } }