Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 32... Línea 32...
32
 * @copyright  2021 Andrew Lyons <andrew@nicols.co.uk>
32
 * @copyright  2021 Andrew Lyons <andrew@nicols.co.uk>
33
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
33
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
34
 */
34
 */
35
abstract class plugin {
35
abstract class plugin {
36
    /**
36
    /**
37
     * Whether the plugin is enabled
37
     * Whether the plugin is enabled and accessible (e.g. capability checks).
38
     *
38
     *
39
     * @param context $context The context that the editor is used within
39
     * @param context $context The context that the editor is used within
40
     * @param array $options The options passed in when requesting the editor
40
     * @param array $options The options passed in when requesting the editor
41
     * @param array $fpoptions The filepicker options passed in when requesting the editor
41
     * @param array $fpoptions The filepicker options passed in when requesting the editor
42
     * @param editor $editor The editor instance in which the plugin is initialised
42
     * @param editor $editor The editor instance in which the plugin is initialised
Línea 46... Línea 46...
46
        context $context,
46
        context $context,
47
        array $options,
47
        array $options,
48
        array $fpoptions,
48
        array $fpoptions,
49
        ?editor $editor = null
49
        ?editor $editor = null
50
    ): bool {
50
    ): bool {
-
 
51
        $plugin = $options['pluginname'];
-
 
52
        $capability = "tiny/$plugin:use";
-
 
53
        if (!get_capability_info($capability)) {
-
 
54
            // Debug warning that the capability does not exist.
-
 
55
            debugging(
-
 
56
                'The tiny ' . $plugin . ' plugin does not define the standard capability ' . $capability ,
-
 
57
                DEBUG_DEVELOPER
-
 
58
            );
51
        return true;
59
            return true;
-
 
60
        }
-
 
61
 
-
 
62
        return has_capability($capability, $context);
-
 
63
    }
-
 
64
 
-
 
65
    /**
-
 
66
     * Whether the plugin is enabled and accessible for external functions.
-
 
67
     *
-
 
68
     * @param context $context The context that the editor is used within.
-
 
69
     * @param array $options Additional options:
-
 
70
     *    - pluginname: Name of the plugin, without the "tiny_" prefix.
-
 
71
     * @return bool
-
 
72
     */
-
 
73
    public static function is_enabled_for_external(context $context, array $options): bool {
-
 
74
        return static::is_enabled($context, $options, []);
52
    }
75
    }
Línea 53... Línea 76...
53
 
76
 
54
    /**
77
    /**
55
     * Get the plugin information for the plugin.
78
     * Get the plugin information for the plugin.