From 408eb5e0d94c52dc425dbbfb219d5ef59834460d Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Tue, 5 Nov 2019 14:19:08 +0800 Subject: [PATCH] MDL-66399 editor: Only set h5p settings if user can deploy --- lib/form/editor.php | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/lib/form/editor.php b/lib/form/editor.php index f0631f99619..1b6d895c377 100644 --- a/lib/form/editor.php +++ b/lib/form/editor.php @@ -390,21 +390,24 @@ class MoodleQuickForm_editor extends HTML_QuickForm_element implements templatab $subtitle_options->env = 'editor'; $subtitle_options->itemid = $draftitemid; - // H5P plugin. - $args->accepted_types = array('.h5p'); - $h5poptions = initialise_filepicker($args); - $h5poptions->context = $ctx; - $h5poptions->client_id = uniqid(); - $h5poptions->maxbytes = $this->_options['maxbytes']; - $h5poptions->areamaxbytes = $this->_options['areamaxbytes']; - $h5poptions->env = 'editor'; - $h5poptions->itemid = $draftitemid; + if (has_capability('moodle/h5p:deploy', $ctx)) { + // Only set H5P Plugin settings if the user can deploy new H5P content. + // H5P plugin. + $args->accepted_types = array('.h5p'); + $h5poptions = initialise_filepicker($args); + $h5poptions->context = $ctx; + $h5poptions->client_id = uniqid(); + $h5poptions->maxbytes = $this->_options['maxbytes']; + $h5poptions->areamaxbytes = $this->_options['areamaxbytes']; + $h5poptions->env = 'editor'; + $h5poptions->itemid = $draftitemid; + $fpoptions['h5p'] = $h5poptions; + } $fpoptions['image'] = $image_options; $fpoptions['media'] = $media_options; $fpoptions['link'] = $link_options; $fpoptions['subtitle'] = $subtitle_options; - $fpoptions['h5p'] = $h5poptions; } //If editor is required and tinymce, then set required_tinymce option to initalize tinymce validation.