@@ -2757,6 +2757,19 @@ public function exportCalendarEvents($offset, $limit)
27572757 '>= '
27582758 );
27592759
2760+ $ coverPhotoFiles = [];
2761+ if (\version_compare ($ this ->getPackageVersion ('com.woltlab.calendar ' ), '6.2.0 Alpha 1 ' , '>= ' )) {
2762+ $ conditionBuilder = new PreparedStatementConditionBuilder ();
2763+ $ conditionBuilder ->add ('eventID IN (?) ' , [$ eventIDs ]);
2764+
2765+ $ sql = "SELECT coverPhotoFileID
2766+ FROM calendar " . $ this ->dbNo . "_event
2767+ " . $ conditionBuilder ;
2768+ $ statement = $ this ->database ->prepareUnmanaged ($ sql );
2769+ $ statement ->execute ($ conditionBuilder ->getParameters ());
2770+ $ coverPhotoFiles = $ this ->getFileLocations ($ statement ->fetchAll (\PDO ::FETCH_COLUMN ));
2771+ }
2772+
27602773 $ sql = "SELECT packageDir
27612774 FROM wcf " . $ this ->dbNo . "_package
27622775 WHERE package = ? " ;
@@ -2823,7 +2836,6 @@ public function exportCalendarEvents($offset, $limit)
28232836 'subject ' => $ row ['subject ' ],
28242837 'message ' => $ row ['message ' ],
28252838 'time ' => $ row ['time ' ],
2826- 'eventDate ' => $ row ['eventDate ' ],
28272839 'views ' => $ row ['views ' ],
28282840 'enableHtml ' => $ row ['enableHtml ' ],
28292841 'enableComments ' => $ row ['enableComments ' ],
@@ -2840,6 +2852,7 @@ public function exportCalendarEvents($offset, $limit)
28402852 'maxCompanions ' => $ row ['maxCompanions ' ],
28412853 'participationIsChangeable ' => $ row ['participationIsChangeable ' ],
28422854 'participationIsPublic ' => $ row ['participationIsPublic ' ],
2855+ ...$ this ->getEventDateData ($ row ),
28432856 ];
28442857
28452858 if (\version_compare ($ this ->getPackageVersion ('com.woltlab.calendar ' ), '3.0.0 Alpha 1 ' , '< ' )) {
@@ -2851,8 +2864,16 @@ public function exportCalendarEvents($offset, $limit)
28512864 // 3.0+
28522865 $ data ['categoryID ' ] = $ row ['categoryID ' ];
28532866 }
2854- if ($ sourceVersion52 && $ row ['coverPhotoID ' ]) {
2855- $ additionalData ['coverPhoto ' ] = $ this ->getCoverPhotoPath ($ calendarFilePath , $ row );
2867+ if ($ sourceVersion52 ) {
2868+ if (!empty ($ row ['coverPhotoFileID ' ]) && isset ($ coverPhotoFiles [$ row ['coverPhotoFileID ' ]])) {
2869+ // since 6.2.0
2870+ ['location ' => $ location , 'filename ' => $ filename ] = $ coverPhotoFiles [$ row ['coverPhotoFileID ' ]];
2871+ $ additionalData ['coverPhotoLocation ' ] = $ location ;
2872+ $ additionalData ['coverPhotoFilename ' ] = $ filename ;
2873+ } elseif (!empty ($ row ['coverPhotoID ' ])) {
2874+ // before 6.2.0
2875+ $ additionalData ['coverPhotoLocation ' ] = $ this ->getCoverPhotoPath ($ calendarFilePath , $ row );
2876+ }
28562877 }
28572878
28582879 ImportHandler::getInstance ()
@@ -2865,6 +2886,41 @@ public function exportCalendarEvents($offset, $limit)
28652886 }
28662887 }
28672888
2889+ private function getEventDateData (array $ row ): array
2890+ {
2891+ if (!empty ($ row ['eventDate ' ])) {
2892+ $ row = \unserialize ($ row ['eventDate ' ]);
2893+ }
2894+
2895+ $ repeatWeeklyByDay = $ row ['repeatWeeklyByDay ' ] ?? [];
2896+ if (\is_array ($ repeatWeeklyByDay )) {
2897+ $ repeatWeeklyByDay = \implode (', ' , $ repeatWeeklyByDay );
2898+ }
2899+
2900+ return [
2901+ 'isFullDay ' => $ row ['isFullDay ' ] ?? 0 ,
2902+ 'enableRepeat ' => $ row ['enableRepeat ' ] ?? 0 ,
2903+ 'firstDayOfWeek ' => $ row ['firstDayOfWeek ' ] ?? null ,
2904+ 'startTime ' => $ row ['startTime ' ] ?? null ,
2905+ 'endTime ' => $ row ['endTime ' ] ?? null ,
2906+ 'timezone ' => $ row ['timezone ' ] ?? 'UTC ' ,
2907+ 'repeatType ' => $ row ['repeatType ' ] ?? null ,
2908+ 'repeatWeeklyByDay ' => $ repeatWeeklyByDay ,
2909+ 'repeatMonthlyByMonthDay ' => $ row ['repeatMonthlyByMonthDay ' ] ?? null ,
2910+ 'repeatMonthlyDayOffset ' => $ row ['repeatMonthlyDayOffset ' ] ?? null ,
2911+ 'repeatMonthlyByWeekDay ' => $ row ['repeatMonthlyByWeekDay ' ] ?? null ,
2912+ 'repeatYearlyByMonthDay ' => $ row ['repeatYearlyByMonthDay ' ] ?? null ,
2913+ 'repeatYearlyByMonthDom ' => $ row ['repeatYearlyByMonthDom ' ] ?? null ,
2914+ 'repeatYearlyDayOffset ' => $ row ['repeatYearlyDayOffset ' ] ?? null ,
2915+ 'repeatYearlyByWeekDay ' => $ row ['repeatYearlyByWeekDay ' ] ?? null ,
2916+ 'repeatYearlyByMonth ' => $ row ['repeatYearlyByMonth ' ] ?? null ,
2917+ 'repeatEndType ' => $ row ['repeatEndType ' ] ?? null ,
2918+ 'repeatInterval ' => $ row ['repeatInterval ' ] ?? null ,
2919+ 'repeatEndCount ' => $ row ['repeatEndCount ' ] ?? null ,
2920+ 'repeatEndDate ' => $ row ['repeatEndDate ' ] ?? null ,
2921+ ];
2922+ }
2923+
28682924 /**
28692925 * Counts calendar event dates.
28702926 */
@@ -4618,7 +4674,7 @@ private function getFilebaseDir()
46184674 *
46194675 * @param int[] $fileIDs
46204676 *
4621- * @return array{int, array{location: string, filename: string}}[]
4677+ * @return array{int, array{location: string, filename: string}}
46224678 */
46234679 private function getFileLocations (array $ fileIDs ): array
46244680 {
0 commit comments