1 |
efrain |
1 |
<?php
|
|
|
2 |
// This file is part of Moodle - http://moodle.org/
|
|
|
3 |
//
|
|
|
4 |
// Moodle is free software: you can redistribute it and/or modify
|
|
|
5 |
// it under the terms of the GNU General Public License as published by
|
|
|
6 |
// the Free Software Foundation, either version 3 of the License, or
|
|
|
7 |
// (at your option) any later version.
|
|
|
8 |
//
|
|
|
9 |
// Moodle is distributed in the hope that it will be useful,
|
|
|
10 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
11 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
12 |
// GNU General Public License for more details.
|
|
|
13 |
//
|
|
|
14 |
// You should have received a copy of the GNU General Public License
|
|
|
15 |
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
|
|
16 |
|
|
|
17 |
namespace tiny_h5p;
|
|
|
18 |
|
|
|
19 |
use context;
|
|
|
20 |
use editor_tiny\plugin;
|
|
|
21 |
use editor_tiny\plugin_with_buttons;
|
|
|
22 |
use editor_tiny\plugin_with_menuitems;
|
|
|
23 |
use editor_tiny\plugin_with_configuration;
|
1441 |
ariadna |
24 |
use editor_tiny\plugin_with_configuration_for_external;
|
1 |
efrain |
25 |
|
|
|
26 |
/**
|
|
|
27 |
* Tiny H5P plugin for Moodle.
|
|
|
28 |
*
|
|
|
29 |
* @package tiny_h5p
|
|
|
30 |
* @copyright 2021 Andrew Lyons <andrew@nicols.co.uk>
|
|
|
31 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
32 |
*/
|
|
|
33 |
class plugininfo extends plugin implements
|
|
|
34 |
plugin_with_buttons,
|
|
|
35 |
plugin_with_menuitems,
|
1441 |
ariadna |
36 |
plugin_with_configuration,
|
|
|
37 |
plugin_with_configuration_for_external {
|
1 |
efrain |
38 |
|
|
|
39 |
public static function get_available_buttons(): array {
|
|
|
40 |
return [
|
|
|
41 |
'tiny_h5p/h5p',
|
|
|
42 |
];
|
|
|
43 |
}
|
|
|
44 |
|
|
|
45 |
public static function get_available_menuitems(): array {
|
|
|
46 |
return [
|
|
|
47 |
'tiny_h5p/h5p',
|
|
|
48 |
];
|
|
|
49 |
}
|
|
|
50 |
|
|
|
51 |
public static function get_plugin_configuration_for_context(
|
|
|
52 |
context $context,
|
|
|
53 |
array $options,
|
|
|
54 |
array $fpoptions,
|
|
|
55 |
?\editor_tiny\editor $editor = null
|
|
|
56 |
): array {
|
|
|
57 |
$permissions = [
|
|
|
58 |
'embed' => has_capability('tiny/h5p:addembed', $context),
|
|
|
59 |
'upload' => has_capability('moodle/h5p:deploy', $context),
|
|
|
60 |
];
|
|
|
61 |
$permissions['uploadandembed'] = $permissions['embed'] && $permissions['upload'];
|
|
|
62 |
|
|
|
63 |
return [
|
|
|
64 |
'permissions' => $permissions,
|
|
|
65 |
'storeinrepo' => true,
|
|
|
66 |
];
|
|
|
67 |
}
|
1441 |
ariadna |
68 |
|
|
|
69 |
#[\Override]
|
|
|
70 |
public static function get_plugin_configuration_for_external(context $context): array {
|
|
|
71 |
$settings = self::get_plugin_configuration_for_context($context, [], []);
|
|
|
72 |
return [
|
|
|
73 |
'embedallowed' => $settings['permissions']['embed'] ? '1' : '0',
|
|
|
74 |
'uploadallowed' => $settings['permissions']['upload'] ? '1' : '0',
|
|
|
75 |
];
|
|
|
76 |
}
|
1 |
efrain |
77 |
}
|