diff --git a/app/controllers/redirect.php b/app/controllers/redirect.php index 09786ca2..08af36bc 100644 --- a/app/controllers/redirect.php +++ b/app/controllers/redirect.php @@ -185,13 +185,11 @@ private function getLtiLinkFor($lti, $endpoint) */ public function preview_action($token) { - global $user, $perm; - $this->set_layout(null); $video = Videos::findByToken($token); - if (!$video->getUserPerm($user->id)) { + if (!$video->getUserPerm()) { throw new \Exception('Access denied!'); } diff --git a/lib/Models/Videos.php b/lib/Models/Videos.php index a582be5a..1422f7fe 100644 --- a/lib/Models/Videos.php +++ b/lib/Models/Videos.php @@ -547,7 +547,7 @@ private function getSeminarVisibility($cid, $playlist_id) * * @return string $perm the perm value */ - public function getUserPerm($user_id = null, $course_id = null) + public function getUserPerm($user_id = null) { global $user, $perm; @@ -572,6 +572,13 @@ public function getUserPerm($user_id = null, $course_id = null) } } + if (!$ret_perm) { + // check if at least read perms are present due to course participation + if ($this->haveCoursePerm('user')) { + return 'read'; + } + } + return $ret_perm; }