Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/Models/Tags.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ public static function getCourseVideosTags($course_id)
' INNER JOIN oc_playlist_seminar AS ops ON (ops.playlist_id = opv.playlist_id AND ops.seminar_id = :cid)';
$params = [':cid' => $course_id];

if (!$perm->have_studip_perm('dozent', $course_id)) {
$required_course_perm = \Config::get()->OPENCAST_TUTOR_EPISODE_PERM ? 'tutor' : 'dozent';
if (!$perm->have_studip_perm($required_course_perm, $course_id)) {
$query .= ' LEFT JOIN oc_playlist_seminar_video AS opsv ON (opsv.playlist_seminar_id = ops.id AND opsv.video_id = opv.video_id)'.
' WHERE (opsv.visibility IS NULL AND opsv.visible_timestamp IS NULL AND ops.visibility = "visible"'.
' OR opsv.visibility = "visible" AND opsv.visible_timestamp IS NULL'.
Expand Down
2 changes: 1 addition & 1 deletion lib/Providers/Perm.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public static function hasRole($check_role, $user_id = null)
* @param string $check_role
* @param string $user_id
*
* @return boolean
* @return array|boolean list of institutes or false if the checks are not met!
*/
public static function getRoleInstitutes($check_role, $user_id)
{
Expand Down
3 changes: 2 additions & 1 deletion lib/Routes/Course/CourseConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ public function __invoke(Request $request, Response $response, $args)

if (empty($series)) {
// only tutor or above should be able to trigger this series creation!
if ($perm->have_studip_perm('tutor', $course_id)) {
$required_course_perm = \Config::get()->OPENCAST_TUTOR_EPISODE_PERM ? 'tutor' : 'dozent';
if ($perm->have_studip_perm($required_course_perm, $course_id)) {
// No series for this course yet! Create one!
$config_id = \Config::get()->OPENCAST_DEFAULT_SERVER;
$series_client = new SeriesClient($config_id);
Expand Down
13 changes: 7 additions & 6 deletions lib/Routes/Course/CourseListForPlaylistVideos.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public function __invoke(Request $request, Response $response, $args)
global $perm;

$params = $request->getQueryParams();
$course_id = isset($params['cid']) ? $params['cid'] : null;

// first, check if user has access to this playlist
$playlist = Playlists::findOneByToken($args['token']);
Expand All @@ -32,23 +33,23 @@ public function __invoke(Request $request, Response $response, $args)

// check if playlist is connected to the passed course and user is part of that course as well
$permission = false;
if ($params['cid']) {
if ($perm->have_studip_perm('user', $params['cid'])) {
if ($course_id && !empty($playlist->courses)) {
$playlist_connected_courses_ids = array_column($playlist->courses->toArray(), 'id');
if ($perm->have_studip_perm('user', $course_id) && in_array($course_id, $playlist_connected_courses_ids)) {
$permission = true;
}
}

if (!$params['cid'] || !$permission) {
if (!$course_id || !$permission) {
// check what permissions the current user has on the playlist
$uperm = $playlist->getUserPerm();

if (empty($uperm) || !$uperm)
{
if (empty($uperm) || !$uperm) {
throw new \AccessDeniedException();
}
}

$courses_ids = PlaylistSeminars::getPlaylistVideosCourses($playlist->id, $params['cid']);
$courses_ids = PlaylistSeminars::getPlaylistVideosCourses($playlist->id, $course_id);

return $this->createResponse(PlaylistSeminars::getCoursesArray($courses_ids), $response->withStatus(200));
}
Expand Down
5 changes: 3 additions & 2 deletions lib/Routes/Course/CourseSetUpload.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ public function __invoke(Request $request, Response $response, $args)
$course_id = $args['course_id'];
$upload = $args['upload'] ? 1 : 0;

if (!$perm->have_studip_perm('tutor', $course_id)) {
$required_course_perm = \Config::get()->OPENCAST_TUTOR_EPISODE_PERM ? 'tutor' : 'dozent';
if (!$perm->have_studip_perm($required_course_perm, $course_id)) {
throw new \AccessDeniedException();
}

Expand All @@ -35,4 +36,4 @@ public function __invoke(Request $request, Response $response, $args)

return $response->withStatus(204);
}
}
}
3 changes: 2 additions & 1 deletion lib/Routes/Playlist/Authority.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ public static function canAddAndRemoveVideoInPlaylist(\Seminar_User $user, Playl
return true;
}

if ($playlist->haveCoursePerm('tutor') && $video->haveCoursePerm('tutor')) {
$required_course_perm = \Config::get()->OPENCAST_TUTOR_EPISODE_PERM ? 'tutor' : 'dozent';
if ($playlist->haveCoursePerm($required_course_perm) && $video->haveCoursePerm($required_course_perm)) {
return true;
}

Expand Down
3 changes: 2 additions & 1 deletion lib/Routes/Playlist/PlaylistAddToCourse.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ public function __invoke(Request $request, Response $response, $args)

// Add record to the PlaylistSeminars based on courses
if (!empty($courses)) {
$required_course_perm = \Config::get()->OPENCAST_TUTOR_EPISODE_PERM ? 'tutor' : 'dozent';
foreach ($courses as $course) {
if ($perm->have_studip_perm('tutor', $course['id'])) {
if ($perm->have_studip_perm($required_course_perm, $course['id'])) {
$playlist_seminar = new PlaylistSeminars;
$playlist_seminar->playlist_id = $playlist->id;
$playlist_seminar->seminar_id = $course['id'];
Expand Down
3 changes: 2 additions & 1 deletion lib/Routes/Playlist/PlaylistCopy.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ public function __invoke(Request $request, Response $response, $args)

// Check permission on course destination
if (!empty($destination_course)) {
if (!$perm->have_studip_perm('tutor', $destination_course)) {
$required_course_perm = \Config::get()->OPENCAST_TUTOR_EPISODE_PERM ? 'tutor' : 'dozent';
if (!$perm->have_studip_perm($required_course_perm, $destination_course)) {
throw new \AccessDeniedException();
}
}
Expand Down
13 changes: 7 additions & 6 deletions lib/Routes/Playlist/PlaylistVideoList.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public function __invoke(Request $request, Response $response, $args)
global $perm;

$params = $request->getQueryParams();
$course_id = isset($params['cid']) ? $params['cid'] : null;

// first, check if user has access to this playlist
$playlist = Playlists::findOneByToken($args['token']);
Expand All @@ -32,18 +33,18 @@ public function __invoke(Request $request, Response $response, $args)

// check if playlist is connected to the passed course and user is part of that course as well
$permission = false;
if ($params['cid']) {
if ($perm->have_studip_perm('user', $params['cid'])) {
if ($course_id && !empty($playlist->courses)) {
$playlist_connected_courses_ids = array_column($playlist->courses->toArray(), 'id');
if ($perm->have_studip_perm('user', $course_id) && in_array($course_id, $playlist_connected_courses_ids)) {
$permission = true;
}
}

if (!$params['cid'] || !$permission) {
if (!$course_id || !$permission) {
// check what permissions the current user has on the playlist
$uperm = $playlist->getUserPerm();

if (empty($uperm) || !$uperm)
{
if (empty($uperm) || !$uperm) {
throw new \AccessDeniedException();
}
}
Expand All @@ -53,7 +54,7 @@ public function __invoke(Request $request, Response $response, $args)

$ret = [];
foreach ($videos['videos'] as $video) {
$video_array = $video->toSanitizedArray($params['cid'], $playlist->id);
$video_array = $video->toSanitizedArray($course_id, $playlist->id);
if (!empty($video_array['perm']) && ($video_array['perm'] == 'owner' || $video_array['perm'] == 'write'))
{
$video_array['perms'] = $video->perms->toSanitizedArray();
Expand Down
10 changes: 6 additions & 4 deletions lib/Routes/Tags/TagListForPlaylistVideos.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public function __invoke(Request $request, Response $response, $args)
global $perm;

$params = $request->getQueryParams();
$course_id = isset($params['cid']) ? $params['cid'] : null;

// first, check if user has access to this playlist
$playlist = Playlists::findOneByToken($args['token']);
Expand All @@ -29,13 +30,14 @@ public function __invoke(Request $request, Response $response, $args)

// check if playlist is connected to the passed course and user is part of that course as well
$permission = false;
if ($params['cid']) {
if ($perm->have_studip_perm('user', $params['cid'])) {
if ($course_id && !empty($playlist->courses)) {
$playlist_connected_courses_ids = array_column($playlist->courses->toArray(), 'id');
if ($perm->have_studip_perm('user', $course_id) && in_array($course_id, $playlist_connected_courses_ids)) {
$permission = true;
}
}

if (!$params['cid'] || !$permission) {
if (!$course_id || !$permission) {
// check what permissions the current user has on the playlist
$uperm = $playlist->getUserPerm();

Expand All @@ -45,7 +47,7 @@ public function __invoke(Request $request, Response $response, $args)
}
}

$ret = Tags::getPlaylistVideosTags($playlist->id, $params['cid']);
$ret = Tags::getPlaylistVideosTags($playlist->id, $course_id);

return $this->createResponse($ret, $response->withStatus(200));
}
Expand Down
3 changes: 2 additions & 1 deletion lib/Routes/Video/VideoCopyToCourse.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ public function __invoke(Request $request, Response $response, $args)
global $perm, $user;

$course_id = $args['course_id'];
if (!$perm->have_studip_perm('tutor', $course_id)) {
$required_course_perm = \Config::get()->OPENCAST_TUTOR_EPISODE_PERM ? 'tutor' : 'dozent';
if (!$perm->have_studip_perm($required_course_perm, $course_id)) {
throw new \AccessDeniedException();
}

Expand Down
4 changes: 0 additions & 4 deletions vueapp/components/Playlists/PlaylistAddVideos.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,6 @@ export default {
},

props: {
canEdit: {
type: Boolean,
default: true,
},
canUpload: {
type: Boolean,
default: true,
Expand Down
14 changes: 5 additions & 9 deletions vueapp/components/Videos/VideoRow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<td v-if="showCheckbox">
<input type="checkbox" :checked="isChecked" @click.stop="toggleVideo">
</td>
<td v-else-if="canUpload">
<td v-else-if="userHasSelectableVideos && canUpload">
</td>

<td class="oc--playercontainer">
Expand Down Expand Up @@ -199,14 +199,6 @@ export default {
type: Number,
required: true
},
canMoveUp: {
type: Boolean,
default: false
},
canMoveDown: {
type: Boolean,
default: false
},
selectable: {
type: Boolean,
default: false
Expand All @@ -225,6 +217,10 @@ export default {
showActions: {
type: Boolean,
default: true
},
userHasSelectableVideos: {
type: Boolean,
default: false
}
},

Expand Down
15 changes: 12 additions & 3 deletions vueapp/components/Videos/VideosTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
:showActions="showActions"
@doAction="doAction"
@redirectAction="redirectAction"
:userHasSelectableVideos="userHasSelectableVideos"
></VideoRow>
</template>
</draggable>
Expand All @@ -101,7 +102,7 @@
<tr>
<td :colspan="numberOfColumns">
<span class="oc--bulk-actions">
<StudipButton v-if="canUpload" icon="remove" @click.prevent="removeVideosFromPlaylist" :disabled="!hasCheckedVideos">
<StudipButton v-if="canUpload && userHasSelectableVideos" icon="remove" @click.prevent="removeVideosFromPlaylist" :disabled="!hasCheckedVideos">
{{ $gettext('Aus Wiedergabeliste entfernen') }}
</StudipButton>
</span>
Expand Down Expand Up @@ -305,11 +306,11 @@ export default {
]),

numberOfColumns() {
return 7 - (this.showCheckbox ? 0 : 1) - (this.showActions ? 0 : 1);
return 7 - (this.showCheckbox ? 0 : 1) - (this.showActions ? 0 : 1);
},

showCheckbox() {
return this.selectable || this.canEdit || this.canUpload;
return (this.selectable || this.canEdit || this.canUpload) && this.userHasSelectableVideos;
},

isCourse() {
Expand Down Expand Up @@ -348,6 +349,14 @@ export default {
}
},

userHasSelectableVideos() {
let has_videos_with_write_perm = false;
if (this.loadedVideos.length > 0) {
has_videos_with_write_perm = this.loadedVideos.filter(v => v.perm == 'write' || v.perm == 'owner').length > 0;
}
return has_videos_with_write_perm;
},

serversCheckSuccessful() {
return Object.values(this.isLTIAuthenticated).every(server => server);
}
Expand Down
1 change: 0 additions & 1 deletion vueapp/views/Course.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
/>

<PlaylistAddVideos v-if="showPlaylistAddVideosDialog"
:canEdit="canEdit"
:canUpload="canUpload"
@done="closePlaylistAddVideosDialog"
@cancel="closePlaylistAddVideosDialog"
Expand Down
Loading