MDL-84126 editor_tiny: Add capability check for plugins

This commit is contained in:
David Woloszyn
2025-03-04 15:01:05 +11:00
parent 688478cfa4
commit 97373483e6
2 changed files with 15 additions and 2 deletions
+13 -2
View File
@@ -34,7 +34,7 @@ use context;
*/
abstract class plugin {
/**
* Whether the plugin is enabled
* Whether the plugin is enabled and accessible (e.g. capability checks).
*
* @param context $context The context that the editor is used within
* @param array $options The options passed in when requesting the editor
@@ -48,7 +48,18 @@ abstract class plugin {
array $fpoptions,
?editor $editor = null
): bool {
return true;
$plugin = $options['pluginname'];
$capability = "tiny/$plugin:use";
if (!get_capability_info($capability)) {
// Debug warning that the capability does not exist.
debugging(
'The tiny ' . $plugin . ' plugin does not define the standard capability ' . $capability ,
DEBUG_DEVELOPER
);
return true;
}
return has_capability($capability, $context);
}
/**