Skip to content

Commit

Permalink
fixes #937
Browse files Browse the repository at this point in the history
  • Loading branch information
tgloeggl committed May 13, 2024
1 parent 5560911 commit 9dd9dcd
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 6 deletions.
14 changes: 9 additions & 5 deletions app/controllers/redirect.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,9 @@ public function perform_action($action, $token)
}

if (empty($video)) {
throw new Error(_('Das Video kann nicht gefunden werden'), 404);
}
if ($video->trashed) {
throw new Error(_('Das Video wurde zur Löschung markiert und kann daher nicht abgerufen werden'), 404);
$this->error = _('Das Video wurde nicht gefunden, ist defekt oder momentan (noch) nicht verfügbar.');
} else if ($video->trashed) {
$this->error = _('Das Video wurde zur Löschung markiert und kann daher nicht abgerufen werden.');
}

/*
Expand All @@ -54,7 +53,7 @@ public function perform_action($action, $token)
$customtool = $this->getLtiCustomTool($video, $action);
$lti = LtiHelper::getLaunchData($video->config_id, $customtool, $video_share);
if (empty($lti) || empty($customtool)) {
throw new Error('Could not load video!', 422);
$this->error = _('Das Video wurde nicht gefunden, ist defekt oder momentan (noch) nicht verfügbar.');
}

// get correct endpoint for redirect type
Expand All @@ -66,6 +65,11 @@ public function perform_action($action, $token)

$this->launch_data = $ltilink['launch_data'];
$this->launch_url = $ltilink['launch_url'];

if (!empty($this->error)) {
$this->set_layout(null);
$this->assets_url = rtrim($this->plugin->getPluginUrl(), '/') . '/assets';
}
}

/**
Expand Down
33 changes: 32 additions & 1 deletion app/views/redirect/perform.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,33 @@
<? if (!empty($this->error)) : ?>
<DOCTYPE html>
<html>
<head>
<style>
h1 {
display: block;
position: absolute;
width: 70%;
left: 50%;
margin-left: -35%;
top: 20%;
text-align: center;
}

.oc-logo {
width: 20%;
text-align: center;
}
</style>
</head>
<body>
<h1>
<img class="oc-logo" src="<?= $assets_url ?>/images/opencast.svg">
<br>
<?= htmlReady($this->error) ?>
</h1>
</body>
</html>
<? else : ?>
<form class="default" action="<?= $launch_url ?>" name="ltiLaunchForm" id="ltiLaunchForm" method="post" encType="application/x-www-form-urlencoded">
<div class="oc--loading-spinner oc--loading-redirect">
<div class="oc--spinner"></div>
Expand All @@ -11,4 +41,5 @@
jQuery(function ($) {
$('#ltiLaunchForm').submit();
});
</script>
</script>
<? endif ?>

0 comments on commit 9dd9dcd

Please sign in to comment.