Skip to content

Commit

Permalink
authors should have perms on videos as well
Browse files Browse the repository at this point in the history
  • Loading branch information
tgloeggl committed Nov 28, 2024
1 parent a897494 commit c05d4d0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 1 addition & 3 deletions app/controllers/redirect.php
Original file line number Diff line number Diff line change
Expand Up @@ -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!');
}

Expand Down
9 changes: 8 additions & 1 deletion lib/Models/Videos.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
}

Expand Down

0 comments on commit c05d4d0

Please sign in to comment.