From: toyomoyo Date: Mon, 26 Feb 2007 02:35:00 +0000 (+0000) Subject: merged, taking care of context_rel cache when moving courses across categories X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=118c0f6d5c82934b3ae6b89197780430043451e3;p=moodle.git merged, taking care of context_rel cache when moving courses across categories --- diff --git a/course/lib.php b/course/lib.php index c05b7fd87f..be47798914 100644 --- a/course/lib.php +++ b/course/lib.php @@ -2521,6 +2521,8 @@ function move_courses ($courseids, $categoryid) { if (!update_record('course', $course)) { notify("An error occurred - course not moved!"); } + // parents changed (course category), do not delete child context relations + insert_context_rel(get_context_instance(CONTEXT_COURSE, $course->id), false); } } fix_course_sortorder(); diff --git a/lib/accesslib.php b/lib/accesslib.php index 68cbc404b4..a04ca0d68e 100755 --- a/lib/accesslib.php +++ b/lib/accesslib.php @@ -3704,9 +3704,14 @@ function user_has_role_assignment($userid, $roleid, $contextid=0) { } // inserts all parental context and self into context_rel table -function insert_context_rel($context) { - // removes old records - delete_records('context_rel', 'c2', $context->id); +/** @param object $context-context to be deleted + * @param bool deletechild - deltes child contexts dependencies + */ +function insert_context_rel($context, $deletechild=true) { + // removes all parents + if ($deletechild) { + delete_records('context_rel', 'c2', $context->id); + } delete_records('context_rel', 'c1', $context->id); // insert all parents if ($parents = get_parent_contexts($context)) {