From 4715cba41ffab49e2dd9d8aa1c313721ede9b415 Mon Sep 17 00:00:00 2001 From: ferishili Date: Wed, 13 Mar 2024 10:21:04 +0100 Subject: [PATCH] double check series course relation --- batchupload.php | 17 +++++++++++++++++ lang/en/block_opencast.php | 2 ++ 2 files changed, 19 insertions(+) diff --git a/batchupload.php b/batchupload.php index 97fa0d9c..ef44472d 100644 --- a/batchupload.php +++ b/batchupload.php @@ -114,6 +114,23 @@ } else { $coursecontext = context_course::instance($courseid); require_capability('block/opencast:addvideo', $coursecontext); + + // Make sure apibridge is available to use. + if (!isset($apibridge)) { + $apibridge = apibridge::get_instance($ocinstanceid); + } + + // Double check if the series is related to the course, which never happens, but we check anyway. + // In case $courseid == $SITE->id, the course series relation will be verified already. + if (!empty($series)) { + $courseseries = $apibridge->get_course_series($courseid); + $seriesfound = array_filter($courseseries, function ($cs) use($series) { + return $cs->series == $series; + }); + if (empty($seriesfound)) { + throw new moodle_exception('batchupload_errorseriesmismatched', 'block_opencast', $redirecturl); + } + } } $batchmetadatacatalog = upload_helper::get_opencast_metadata_catalog_batch($ocinstanceid); diff --git a/lang/en/block_opencast.php b/lang/en/block_opencast.php index e5150415..39e31039 100644 --- a/lang/en/block_opencast.php +++ b/lang/en/block_opencast.php @@ -915,5 +915,7 @@ $string['batchupload_emptyvideosuploaderror'] = 'You must upload at least one presenter video file.'; $string['batchupload_jobssaved'] = 'Batch of {$a} Video(s) successfully uploaded.
The videos are queued for transferring to Opencast. Therefore, you do not need to wait on this page for them to finish.'; $string['batchupload_errorsaveuploadjobs'] = 'There were errors uploading {$a->count} out of {$a->total} video(s).'; +$string['batchupload_errorseriesmismatched'] = 'Unfortunately the series is not defined in this course.'; + // Deprecated since version 2021062300. $string['video_already_uploaded'] = 'Video already uploaded';