From 75db5bb8b0cb555865d293541bff6c28bfd4be75 Mon Sep 17 00:00:00 2001 From: Cyperghost Date: Tue, 19 Dec 2023 13:06:32 +0100 Subject: [PATCH] Export calendar event cover photo --- .../system/exporter/WBB4xExporter.class.php | 35 ++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/files/lib/system/exporter/WBB4xExporter.class.php b/files/lib/system/exporter/WBB4xExporter.class.php index 1750db5..ee9456b 100644 --- a/files/lib/system/exporter/WBB4xExporter.class.php +++ b/files/lib/system/exporter/WBB4xExporter.class.php @@ -3,6 +3,7 @@ namespace wcf\system\exporter; use blog\system\BLOGCore; +use calendar\system\CALENDARCore; use gallery\system\GALLERYCore; use wcf\data\object\type\ObjectTypeCache; use wcf\data\package\Package; @@ -2713,6 +2714,25 @@ final class WBB4xExporter extends AbstractExporter return; } + $sourceVersion52 = \version_compare( + $this->getPackageVersion('com.woltlab.calendar'), + '5.2.0 Alpha 1', + '>=' + ); + $destVersion52 = \version_compare( + CALENDARCore::getInstance()->getPackage()->packageVersion, + '5.2.0 Alpha 1', + '>=' + ); + + $sql = "SELECT packageDir + FROM wcf" . $this->dbNo . "_package + WHERE package = ?"; + $statement = $this->database->prepareStatement($sql, 1); + $statement->execute(['com.woltlab.calendar']); + $packageDir = $statement->fetchColumn(); + $calendarFilePath = FileUtil::getRealPath($this->fileSystemPath . '/' . $packageDir); + // get tags $tags = $this->getTags('com.woltlab.calendar.event', $eventIDs); @@ -2739,11 +2759,21 @@ final class WBB4xExporter extends AbstractExporter // get event $conditionBuilder = new PreparedStatementConditionBuilder(); $conditionBuilder->add('event.eventID IN (?)', [$eventIDs]); - $sql = "SELECT event.*, language.languageCode + if ($sourceVersion52 && $destVersion52) { + $sql = "SELECT event.*, language.languageCode + FROM calendar" . $this->dbNo . "_event event + LEFT JOIN wcf" . $this->dbNo . "_language language + ON language.languageID = event.languageID + LEFT JOIN calendar" . $this->dbNo . "_cover_photo coverPhoto + ON coverPhoto.coverPhotoID = event.coverPhotoID + " . $conditionBuilder; + } else { + $sql = "SELECT event.*, language.languageCode FROM calendar" . $this->dbNo . "_event event LEFT JOIN wcf" . $this->dbNo . "_language language ON language.languageID = event.languageID " . $conditionBuilder; + } $statement = $this->database->prepareStatement($sql); $statement->execute($conditionBuilder->getParameters()); while ($row = $statement->fetchArray()) { @@ -2789,6 +2819,9 @@ final class WBB4xExporter extends AbstractExporter // 3.0+ $data['categoryID'] = $row['categoryID']; } + if ($sourceVersion52 && $destVersion52 && $row['coverPhotoID']) { + $additionalData['coverPhoto'] = $this->getCoverPhotoPath($calendarFilePath, $row); + } ImportHandler::getInstance() ->getImporter('com.woltlab.calendar.event') -- 2.20.1