mirror of
https://github.com/moodle/moodle.git
synced 2025-04-09 02:12:22 +02:00
Merge branch 'MDL-83704-main' of https://github.com/andrewnicols/moodle
This commit is contained in:
commit
6ef15493a2
@ -139,17 +139,7 @@ function uninstall_plugin($type, $name) {
|
||||
$subplugintypes = core_component::get_plugin_types_with_subplugins();
|
||||
if (isset($subplugintypes[$type])) {
|
||||
$base = core_component::get_plugin_directory($type, $name);
|
||||
|
||||
$subpluginsfile = "{$base}/db/subplugins.json";
|
||||
if (file_exists($subpluginsfile)) {
|
||||
$subplugins = (array) json_decode(file_get_contents($subpluginsfile))->plugintypes;
|
||||
} else if (file_exists("{$base}/db/subplugins.php")) {
|
||||
debugging('Use of subplugins.php has been deprecated. ' .
|
||||
'Please update your plugin to provide a subplugins.json file instead.',
|
||||
DEBUG_DEVELOPER);
|
||||
$subplugins = [];
|
||||
include("{$base}/db/subplugins.php");
|
||||
}
|
||||
$subplugins = \core\component::get_subplugins("{$type}_{$name}");
|
||||
|
||||
if (!empty($subplugins)) {
|
||||
foreach (array_keys($subplugins) as $subplugintype) {
|
||||
|
@ -170,15 +170,7 @@ class module extends context {
|
||||
$subcaps = array();
|
||||
|
||||
$modulepath = "{$CFG->dirroot}/mod/{$module->name}";
|
||||
if (file_exists("{$modulepath}/db/subplugins.json")) {
|
||||
$subplugins = (array) json_decode(file_get_contents("{$modulepath}/db/subplugins.json"))->plugintypes;
|
||||
} else if (file_exists("{$modulepath}/db/subplugins.php")) {
|
||||
debugging('Use of subplugins.php has been deprecated. ' .
|
||||
'Please update your plugin to provide a subplugins.json file instead.',
|
||||
DEBUG_DEVELOPER);
|
||||
$subplugins = array(); // Should be redefined in the file.
|
||||
include("{$modulepath}/db/subplugins.php");
|
||||
}
|
||||
$subplugins = \core\component::get_subplugins("mod_{$module->name}");
|
||||
|
||||
if (!empty($subplugins)) {
|
||||
foreach (array_keys($subplugins) as $subplugintype) {
|
||||
|
@ -189,13 +189,16 @@ class module_test extends \advanced_testcase {
|
||||
$this->resetAfterTest();
|
||||
|
||||
$course = $this->getDataGenerator()->create_course();
|
||||
$page = $this->getDataGenerator()->create_module('page', ['course' => $course->id, 'name' => 'Pokus']);
|
||||
$context = module::instance($page->cmid);
|
||||
$mod = $this->getDataGenerator()->create_module('book', ['course' => $course->id, 'name' => 'Pokus']);
|
||||
$context = module::instance($mod->cmid);
|
||||
|
||||
$capabilities = $context->get_capabilities();
|
||||
$capabilities = convert_to_array($capabilities);
|
||||
$capabilities = array_column($capabilities, 'name');
|
||||
$this->assertContains('mod/page:view', $capabilities);
|
||||
|
||||
$this->assertContains('mod/book:read', $capabilities);
|
||||
$this->assertContains('booktool/exportimscp:export', $capabilities);
|
||||
$this->assertContains('booktool/importhtml:import', $capabilities);
|
||||
$this->assertNotContains('mod/url:view', $capabilities);
|
||||
$this->assertNotContains('moodle/course:view', $capabilities);
|
||||
$this->assertNotContains('moodle/category:manage', $capabilities);
|
||||
|
Loading…
x
Reference in New Issue
Block a user