]> git.mjollnir.org Git - moodle.git/commitdiff
merged, taking care of context_rel cache when moving courses across categories
authortoyomoyo <toyomoyo>
Mon, 26 Feb 2007 02:35:00 +0000 (02:35 +0000)
committertoyomoyo <toyomoyo>
Mon, 26 Feb 2007 02:35:00 +0000 (02:35 +0000)
course/lib.php
lib/accesslib.php

index c05b7fd87fdc64657aa429b8b910245b649320ab..be4779891487319d45fb284c136d96f6661cb78f 100644 (file)
@@ -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();
index 68cbc404b4b636c0e6f89ba96abd407cb675901f..a04ca0d68e231ce9c5ce31324e67b00cc58b39be 100755 (executable)
@@ -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)) {