MDL-84780 course: Disabled modules are not allowed
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user