Merge branch 'MDL-31000-master-3' of git://git.luns.net.uk/moodle
[moodle.git] / repository / lib.php
index 6ef38e3..8652aa9 100644 (file)
@@ -870,7 +870,11 @@ abstract class repository {
                     }
                     if ($record->repositorytype == 'coursefiles') {
                         // coursefiles plugin needs managefiles permission
-                        $capability = $capability && has_capability('moodle/course:managefiles', $current_context);
+                        if (!empty($current_context)) {
+                            $capability = $capability && has_capability('moodle/course:managefiles', $current_context);
+                        } else {
+                            $capability = $capability && has_capability('moodle/course:managefiles', get_system_context());
+                        }
                     }
                     if ($is_supported && $capability) {
                         $repositories[$repository->id] = $repository;