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); $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); parse_str(parse_url($href, PHP_URL_QUERY) ?? '', $query_params);
$token = $query_params['m'] ?? null; $token = $query_params['m'] ?? null;
if (!$token || !preg_match('/^[a-zA-Z0-9]+$/', $token)) { if (!$token || !preg_match('/^[a-zA-Z0-9]+$/', $token)) {
return $anchor_html; return $anchor_html;
} }
$start_time = isset($query_params['t']) ? (int)$query_params['t'] : null;
// Extract inner link text. // Extract inner link text.
if (!preg_match('/<a[^>]*>(.*?)<\/a>/is', $anchor_html, $text_matches)) { 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; $courseid = isset($COURSE->id) ? (int)$COURSE->id : 0;
$view_url = new moodle_url('/filter/mediacms/my_media.php', [ $view_params = ['token' => $token, 'courseid' => $courseid];
'token' => $token, if ($start_time !== null && $start_time > 0) {
'courseid' => $courseid, $view_params['t'] = $start_time;
]); }
$launch_url = new moodle_url('/filter/mediacms/launch.php', [ $view_url = new moodle_url('/filter/mediacms/my_media.php', $view_params);
'token' => $token,
'courseid' => $courseid, $launch_url = new moodle_url('/filter/mediacms/launch.php', $view_params);
]);
// Hidden iframe fires the LTI launch silently on every page load. // Hidden iframe fires the LTI launch silently on every page load.
// When the media owner (teacher) loads the page, EmbedMediaLTIView's // When the media owner (teacher) loads the page, EmbedMediaLTIView's
@@ -15,6 +15,7 @@ require_login();
$token = optional_param('token', '', PARAM_ALPHANUMEXT); $token = optional_param('token', '', PARAM_ALPHANUMEXT);
$courseid = optional_param('courseid', 0, PARAM_INT); $courseid = optional_param('courseid', 0, PARAM_INT);
$start_time = optional_param('t', 0, PARAM_INT);
$context = context_system::instance(); $context = context_system::instance();
$PAGE->set_context($context); $PAGE->set_context($context);
@@ -31,6 +32,9 @@ if ($token) {
'courseid' => $courseid ?: ($COURSE->id ?? 0), 'courseid' => $courseid ?: ($COURSE->id ?? 0),
'show_media_page' => 'true', '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); $src = (new moodle_url('/filter/mediacms/launch.php', $launch_params))->out(false);
} else { } else {
$PAGE->set_url(new moodle_url('/filter/mediacms/my_media.php')); $PAGE->set_url(new moodle_url('/filter/mediacms/my_media.php'));