From 7f8691201c6f335a7a1fe4e2f27f24fde67c4389 Mon Sep 17 00:00:00 2001 From: toyomoyo Date: Wed, 4 Oct 2006 02:43:11 +0000 Subject: [PATCH] fixed a bug where block instances aren't deleted properly --- lib/moodlelib.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/moodlelib.php b/lib/moodlelib.php index 73536f6a06..97faff1093 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -2696,7 +2696,11 @@ function remove_course_contents($courseid, $showfeedback=true) { notify_local_delete_course($courseid, $showfeedback); /// Delete course blocks - if ($blocks = get_records('block_instance', 'pagetype', PAGE_COURSE_VIEW, 'pageid', $course->id)) { + + if ($blocks = get_records_sql("SELECT * + FROM {$CFG->prefix}block_instance + WHERE pagetype = '".PAGE_COURSE_VIEW."' + AND pageid = $course->id")) { if (delete_records('block_instance', 'pagetype', PAGE_COURSE_VIEW, 'pageid', $course->id)) { if ($showfeedback) { notify($strdeleted .' block_instance'); @@ -2781,10 +2785,7 @@ function remove_course_contents($courseid, $showfeedback=true) { question_delete_course($course, $showfeedback); /// Delete all roles and overiddes in the course context (but keep the course context) - if ($context = get_context_instance(CONTEXT_COURSE, $course->id)) { - delete_records('role_assignments', 'contextid', $context->id); - delete_records('role_capabilities', 'contextid', $context->id); - } + delete_context(CONTEXT_COURSE, $course->id); return $result; } -- 2.39.5