Skip to content

Commit

Permalink
double check series course relation
Browse files Browse the repository at this point in the history
  • Loading branch information
ferishili committed Mar 13, 2024
1 parent c54935d commit 4715cba
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
17 changes: 17 additions & 0 deletions batchupload.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions lang/en/block_opencast.php
Original file line number Diff line number Diff line change
Expand Up @@ -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. <br> 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';

0 comments on commit 4715cba

Please sign in to comment.