MDL-53566 tool_monitor: Fix context preload
authorAndrew Nicols <andrew@nicols.co.uk>
Tue, 13 Nov 2018 13:15:10 +0000 (21:15 +0800)
committerAndrew Nicols <andrew@nicols.co.uk>
Tue, 13 Nov 2018 13:17:40 +0000 (21:17 +0800)
admin/tool/monitor/lib.php

index c7493ad..58078ec 100644 (file)
@@ -125,7 +125,15 @@ function tool_monitor_get_user_courses() {
         $options[0] = get_string('site');
     }
 
-    $fields = 'fullname, visible, ctxid, ctxpath, ctxdepth, ctxlevel, ctxinstance';
+    $fieldlist = array_merge(
+            [
+                'fullname',
+                'visible',
+            ],
+            array_values(context_helper::get_preload_record_columns('c'))
+        );
+
+    $fields = implode(', ', $fieldlist);
     if ($courses = get_user_capability_course('tool/monitor:subscribe', null, true, $fields, $orderby)) {
         foreach ($courses as $course) {
             context_helper::preload_from_record($course);