diff --git a/.github/workflows/moodle-ci.yml b/.github/workflows/moodle-ci.yml index 3142f7c1..0fedfb15 100644 --- a/.github/workflows/moodle-ci.yml +++ b/.github/workflows/moodle-ci.yml @@ -28,18 +28,21 @@ jobs: fail-fast: false matrix: include: - - php: '8.1' + - php: '8.3' moodle-branch: 'master' database: 'pgsql' - - php: '8.1' + - php: '8.2' moodle-branch: 'master' database: 'mariadb' + - php: '8.3' + moodle-branch: 'MOODLE_404_STABLE' + database: 'pgsql' + - php: '8.2' + moodle-branch: 'MOODLE_404_STABLE' + database: 'mariadb' - php: '8.1' moodle-branch: 'MOODLE_403_STABLE' database: 'pgsql' - - php: '8.0' - moodle-branch: 'MOODLE_403_STABLE' - database: 'mariadb' - php: '8.0' moodle-branch: 'MOODLE_402_STABLE' database: 'pgsql' diff --git a/classes/vimeo_embed.php b/classes/vimeo_embed.php index 9a482c32..8e082c8f 100644 --- a/classes/vimeo_embed.php +++ b/classes/vimeo_embed.php @@ -51,6 +51,11 @@ class vimeo_embed implements \renderable, \templatable { */ protected $record = null; + /** + * @var $uniqueid Unique id for element + */ + protected $uniqueid = null; + /** * Constructor * diff --git a/mod_form.php b/mod_form.php index 0ab88960..44de5f9b 100644 --- a/mod_form.php +++ b/mod_form.php @@ -295,6 +295,10 @@ public function validation($data, $files) { } } + foreach (array_keys(core_component::get_plugin_list('videotimeplugin')) as $name) { + $errors += component_callback("videotimeplugin_$name", 'validation', [$data, $files], []); + } + return $errors; } diff --git a/plugin/videojs/lib.php b/plugin/videojs/lib.php index ff50d904..68999b24 100644 --- a/plugin/videojs/lib.php +++ b/plugin/videojs/lib.php @@ -362,3 +362,45 @@ function videotimeplugin_videojs_config_file_areas() { 'poster', ]; } + +/** + * Validates the form input + * + * @param array $data submitted data + * @param array $files submitted files + * @return array eventual errors indexed by the field name + */ +function videotimeplugin_videojs_validation($data, $files) { + $acceptedtypes = [ + 'audio/flac', + 'audio/mp3', + 'audio/ogg', + 'audio/wav', + 'video/mp4', + 'video/mpeg', + 'video/ogg', + 'video/quicktime', + 'video/wav', + 'video/webm', + ]; + if ( + in_array(resourcelib_guess_url_mimetype($data['vimeo_url']), $acceptedtypes) + || mod_videotime_get_vimeo_id_from_link($data['mediafile']) + || resourcelib_get_extension($data['vimeo_url'] == 'm3u8') + ) { + return []; + } + foreach ($files as $file) { + if ( + !$file->is_directory() + && ($file->get_itemid() == $data['mediafile']) + ) { + if (in_array($file->get_mimetype(), $acceptedtypes)) { + return []; + } + return ['mediafile' => get_string('invalidmediafile', 'videotimeplugin_videojs')]; + } + + } + return ['vimeo_url' => get_string('required')]; +}