This commit is contained in:
Markos Gogoulos
2026-05-06 12:23:24 +03:00
parent 1248ec9809
commit 7573255255
2 changed files with 15 additions and 11 deletions
@@ -247,12 +247,13 @@ class text_filter extends \core_filters\text_filter {
}
$href = html_entity_decode($href_matches[1], ENT_QUOTES | ENT_HTML5);
// Extract ?m=TOKEN.
// Extract ?m=TOKEN and optional ?t=seconds.
parse_str(parse_url($href, PHP_URL_QUERY) ?? '', $query_params);
$token = $query_params['m'] ?? null;
if (!$token || !preg_match('/^[a-zA-Z0-9]+$/', $token)) {
return $anchor_html;
}
$start_time = isset($query_params['t']) ? (int)$query_params['t'] : null;
// Extract inner link text.
if (!preg_match('/<a[^>]*>(.*?)<\/a>/is', $anchor_html, $text_matches)) {
@@ -261,15 +262,14 @@ class text_filter extends \core_filters\text_filter {
$courseid = isset($COURSE->id) ? (int)$COURSE->id : 0;
$view_url = new moodle_url('/filter/mediacms/my_media.php', [
'token' => $token,
'courseid' => $courseid,
]);
$view_params = ['token' => $token, 'courseid' => $courseid];
if ($start_time !== null && $start_time > 0) {
$view_params['t'] = $start_time;
}
$launch_url = new moodle_url('/filter/mediacms/launch.php', [
'token' => $token,
'courseid' => $courseid,
]);
$view_url = new moodle_url('/filter/mediacms/my_media.php', $view_params);
$launch_url = new moodle_url('/filter/mediacms/launch.php', $view_params);
// Hidden iframe fires the LTI launch silently on every page load.
// When the media owner (teacher) loads the page, EmbedMediaLTIView's
@@ -13,8 +13,9 @@ global $SITE, $PAGE, $OUTPUT, $USER, $COURSE;
require_login();
$token = optional_param('token', '', PARAM_ALPHANUMEXT);
$courseid = optional_param('courseid', 0, PARAM_INT);
$token = optional_param('token', '', PARAM_ALPHANUMEXT);
$courseid = optional_param('courseid', 0, PARAM_INT);
$start_time = optional_param('t', 0, PARAM_INT);
$context = context_system::instance();
$PAGE->set_context($context);
@@ -31,6 +32,9 @@ if ($token) {
'courseid' => $courseid ?: ($COURSE->id ?? 0),
'show_media_page' => 'true',
];
if ($start_time > 0) {
$launch_params['t'] = $start_time;
}
$src = (new moodle_url('/filter/mediacms/launch.php', $launch_params))->out(false);
} else {
$PAGE->set_url(new moodle_url('/filter/mediacms/my_media.php'));