Skip to content

Commit 89ba456

Browse files
authored
Correctly consider global default visibility of videos (#1302)
* Correctly consider global default visibility of videos * use correct sql
1 parent 6b68696 commit 89ba456

File tree

3 files changed

+52
-11
lines changed

3 files changed

+52
-11
lines changed

assets/css/opencast.scss

+8
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,14 @@ $action-menu-icon-size: 20px;
362362
opacity: 0.7;
363363
}
364364

365+
.oc--episode--invisible {
366+
background-color: #FFFFCC;
367+
}
368+
369+
.oc--title--invisible-info {
370+
font-size: 0.8em;
371+
}
372+
365373
.oc--loadingbar {
366374
border-radius: 15px;
367375
background-color: darken($episode-background, 20%);

lib/Models/Videos.php

+20-9
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,7 @@ public static function getPlaylistVideos($playlist_id, $filters)
109109
$sql .= ' INNER JOIN oc_playlist_seminar AS ops ON (ops.seminar_id = :cid AND ops.playlist_id = opv.playlist_id)'.
110110
' LEFT JOIN oc_playlist_seminar_video AS opsv ON (opsv.playlist_seminar_id = ops.id AND opsv.video_id = opv.video_id)';
111111

112-
$where = ' WHERE (opsv.visibility IS NULL AND opsv.visible_timestamp IS NULL AND ops.visibility = "visible"
113-
OR opsv.visibility = "visible" AND opsv.visible_timestamp IS NULL
114-
OR opsv.visible_timestamp < NOW()) ';
112+
$where = ' WHERE '. self::getVisibilitySql();
115113

116114
$params[':cid'] = $cid;
117115
}
@@ -152,9 +150,7 @@ public static function getCourseVideos($course_id, $filters)
152150
if (!$perm->have_studip_perm($required_course_perm, $course_id)) {
153151
$sql .= ' LEFT JOIN oc_playlist_seminar_video AS opsv ON (opsv.playlist_seminar_id = ops.id AND opsv.video_id = opv.video_id)';
154152

155-
$where = ' WHERE (opsv.visibility IS NULL AND opsv.visible_timestamp IS NULL AND ops.visibility = "visible"
156-
OR opsv.visibility = "visible" AND opsv.visible_timestamp IS NULL
157-
OR opsv.visible_timestamp < NOW()) ';
153+
$where = ' WHERE '. self::getVisibilitySql();
158154
}
159155

160156
$query = [
@@ -166,6 +162,23 @@ public static function getCourseVideos($course_id, $filters)
166162
return self::getFilteredVideos($query, $filters);
167163
}
168164

165+
private static function getVisibilitySql()
166+
{
167+
// if each video has to explicitly set to visible, filter out everything else
168+
if (\Config::get()->OPENCAST_HIDE_EPISODES) {
169+
return '(
170+
(opsv.visibility = "visible" AND opsv.visible_timestamp IS NULL)
171+
OR (opsv.visible_timestamp < NOW())
172+
)';
173+
} else {
174+
return '(
175+
(opsv.visibility IS NULL AND opsv.visible_timestamp IS NULL AND ops.visibility = "visible")
176+
OR (opsv.visibility = "visible" AND opsv.visible_timestamp IS NULL)
177+
OR (opsv.visible_timestamp < NOW())
178+
)';
179+
}
180+
}
181+
169182
/**
170183
* Get the list of videos where the user has owner perm, faceted by the passed filters
171184
*
@@ -484,9 +497,7 @@ public static function getNumberOfNewCourseVideos($course_id, $last_visit, $user
484497
if (!$perm->have_perm('dozent', $user_id)) {
485498
$sql .= ' LEFT JOIN oc_playlist_seminar_video AS opsv ON (opsv.playlist_seminar_id = ops.id AND opsv.video_id = opv.video_id)';
486499

487-
$where .= ' AND (opsv.visibility IS NULL AND opsv.visible_timestamp IS NULL AND ops.visibility = "visible"
488-
OR opsv.visibility = "visible" AND opsv.visible_timestamp IS NULL
489-
OR opsv.visible_timestamp < NOW()) ';
500+
$where .= ' AND '. self::getVisibilitySql();
490501
}
491502

492503
$sql .= $where;

vueapp/components/Videos/VideoRow.vue

+24-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<template>
2-
<tr class="oc--episode" v-if="event.refresh === undefined" :key="event.id" ref="videoRow">
2+
<tr class="oc--episode" v-if="event.refresh === undefined" :key="event.id" ref="videoRow"
3+
:class="{
4+
'oc--episode--invisible': !isVisible(event)
5+
}">
36
<td v-if="canEdit && videoSortMode">
47
<a class="dragarea" title="$gettextInterpolate($gettext('Video per Drag & Drop verschieben'))">
58
<img class="oc--drag-handle"
@@ -54,7 +57,7 @@
5457
<span class="tooltip-content">
5558
{{ $gettext('Aufrufe') }}
5659
</span>
57-
<studip-icon shape="visibility-visible" role="info_alt"></studip-icon>
60+
<studip-icon :shape="isVisible(event) ? 'visibility-visible' : 'visibility-invisible'" role="info_alt"></studip-icon>
5861
{{ event.views }}
5962
</span>
6063
<span class="oc--duration">
@@ -95,6 +98,9 @@
9598
</td>
9699

97100
<td class="oc--metadata-title">
101+
<div v-if="!isVisible(event)" class="oc--title--invisible-info">
102+
{{ $gettext('(Video ist unsichtbar für Studierende)') }}
103+
</div>
98104
<div class="oc--title-container">
99105
<a v-if="isLivestream && livestreamInfo.isLive"
100106
href="#" @click.prevent="redirectAction(`/livestream/` + event.token)" target="_blank">
@@ -343,6 +349,22 @@ export default {
343349
video_row.lastElementChild.setAttribute('colspan', colspan);
344350
}
345351
}
352+
},
353+
354+
isVisible(event) {
355+
if (event.seminar_visibility === null || event.seminar_visibility === undefined) {
356+
if (this.simple_config_list.settings.OPENCAST_HIDE_EPISODES) {
357+
return false;
358+
} else {
359+
return true;
360+
}
361+
}
362+
363+
if (event.seminar_visibility?.visibility == 'visible') {
364+
return true;
365+
}
366+
367+
return false;
346368
}
347369
},
348370

0 commit comments

Comments
 (0)