Skip to content

Commit 75f8ecf

Browse files
committed
migrate the video visibility as well,
This PR fixes elan-ev#1286. It only focuses on the migration process coming from V2 to V3 and tries to read the visibility of the course videos and populate them into the oc_playlist_seminar_video table only after the course default playlist is created!
1 parent 75dff87 commit 75f8ecf

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

migrations/065_convert_virtual_playlists.php

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@
55
use Opencast\Models\Playlists;
66
use Opencast\Models\PlaylistVideos;
77
use Opencast\Models\PlaylistSeminars;
8+
use Opencast\Models\PlaylistSeminarVideos;
89

910
class ConvertVirtualPlaylists extends Migration
1011
{
1112
public function description()
1213
{
13-
return 'Convert virtual course playlists to real playlists';
14+
return 'Convert virtual course playlists to real playlists and populate the visibility of the videos in oc_playlist_seminar_video';
1415
}
1516

1617
public function up()
@@ -35,11 +36,11 @@ public function up()
3536
// collect videos for playlists
3637
$playlists = [];
3738
while ($data = $result->fetch(PDO::FETCH_ASSOC)) {
38-
$playlists[$data['seminar_id']][] = $data['video_id'];
39+
$playlists[$data['seminar_id']][] = [$data['video_id'], $data['visibility']];
3940
}
4041

4142
// create playlists for courses, add videos to them and connect these new playlists to the course
42-
foreach ($playlists as $seminar_id => $videos) {
43+
foreach ($playlists as $seminar_id => $videos_records) {
4344
$course = Course::find($seminar_id);
4445

4546
if (!empty($course)) {
@@ -51,7 +52,8 @@ public function up()
5152
$playlist->store();
5253

5354
// add videos to playlist
54-
foreach ($videos as $video_id) {
55+
foreach ($videos_records as $video_record) {
56+
[$video_id, $video_visibility] = $video_record;
5557
$video = new PlaylistVideos();
5658
$video->video_id = $video_id;
5759
$video->playlist_id = $playlist->id;
@@ -65,6 +67,16 @@ public function up()
6567
$psem->is_default = 1;
6668
$psem->visibility = 'visible';
6769
$psem->store();
70+
71+
// Populate videos visibilities in oc_playlist_seminar_video table.
72+
foreach ($videos_records as $video_record) {
73+
[$video_id, $video_visibility] = $video_record;
74+
$psemv = new PlaylistSeminarVideos();
75+
$psemv->playlist_seminar_id = $psem->id;
76+
$psemv->video_id = $video_id;
77+
$psemv->visibility = $video_visibility;
78+
$psemv->store();
79+
}
6880
}
6981
}
7082

@@ -80,4 +92,4 @@ public function down()
8092

8193
SimpleOrMap::expireTableScheme();
8294
}
83-
}
95+
}

0 commit comments

Comments
 (0)