From: martinlanghoff Date: Wed, 19 Sep 2007 07:13:57 +0000 (+0000) Subject: course: Changing a course cat from course/edit calls context_moved() X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=a372aab50744c0563a12ff081346cc57a6e49db3;p=moodle.git course: Changing a course cat from course/edit calls context_moved() Changes to course cat from the main course settings form now calls context_moved(), and accesslib data is properly maintained. --- diff --git a/course/lib.php b/course/lib.php index f21afeca6a..40d46f4984 100644 --- a/course/lib.php +++ b/course/lib.php @@ -2757,11 +2757,14 @@ function update_course($data) { unset($data->restrictmodules); } + $movecat = false; $oldcourse = get_record('course', 'id', $data->id); // should not fail, already tested above if (!has_capability('moodle/course:create', get_context_instance(CONTEXT_COURSECAT, $oldcourse->category)) or !has_capability('moodle/course:create', get_context_instance(CONTEXT_COURSECAT, $data->category))) { // can not move to new category, keep the old one unset($data->category); + } elseif ($oldcourse->category != $data->category) { + $movecat = true; } // Update with the new data @@ -2775,6 +2778,12 @@ function update_course($data) { update_restricted_mods($course, $allowedmods); } + if ($movecat) { + $context = get_context_instance(CONTEXT_COURSE, $course->id); + $newparent = get_context_instance(CONTEXT_COURSECAT, $course->category); + context_moved($context, $newparent); + } + fix_course_sortorder(); // Test for and remove blocks which aren't appropriate anymore