MDL-84780 course: Disabled modules are not allowed

This commit is contained in:
Stefan Hanauska
2026-03-19 20:48:52 +01:00
parent 6ebf41a6c2
commit 9a4d2c5083
2 changed files with 10 additions and 0 deletions
+4
View File
@@ -1483,6 +1483,10 @@ function course_allowed_module($course, $modname, ?\stdClass $user = null) {
supports numeric module ids. Please update your code to pass the module name.');
}
if (!\core\plugininfo\mod::get_enabled_plugin($modname)) {
return false;
}
$capability = 'mod/' . $modname . ':addinstance';
if (!get_capability_info($capability)) {
// Debug warning that the capability does not exist, but no more than once per page.
+6
View File
@@ -7035,6 +7035,12 @@ final class courselib_test extends advanced_testcase {
// Manager has permissions.
$this->assertTrue(course_allowed_module($course, 'assign', $manager));
// Disable the assign module.
$DB->set_field('modules', 'visible', 0, ['name' => 'assign']);
// Verify that disabled modules are not allowed.
$this->assertFalse(course_allowed_module($course, 'assign', $manager));
}
/**