2 namespace wcf\system\importer
;
3 use wcf\data\conversation\message\ConversationMessage
;
4 use wcf\data\conversation\message\ConversationMessageEditor
;
5 use wcf\data\
object\type\ObjectTypeCache
;
6 use wcf\util\StringUtil
;
9 * Imports conversation attachments.
12 * @copyright 2001-2013 WoltLab GmbH
13 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
14 * @package com.woltlab.wcf.conversation
15 * @subpackage system.importer
16 * @category Community Framework
18 class ConversationAttachmentImporter
extends AbstractAttachmentImporter
{
20 * Creates a new ConversationAttachmentImporter object.
22 public function __construct() {
23 $objectType = ObjectTypeCache
::getInstance()->getObjectTypeByName('com.woltlab.wcf.attachment.objectType', 'com.woltlab.wcf.conversation.message');
24 $this->objectTypeID
= $objectType->objectTypeID
;
28 * @see \wcf\system\importer\IImporter::import()
30 public function import($oldID, array $data, array $additionalData = array()) {
31 $data['objectID'] = ImportHandler
::getInstance()->getNewID('com.woltlab.wcf.conversation.message', $data['objectID']);
32 if (!$data['objectID']) return 0;
34 $attachmentID = parent
::import($oldID, $data, $additionalData);
35 if ($attachmentID && $attachmentID != $oldID) {
36 // fix embedded attachments
37 $messageObj = new ConversationMessage($data['objectID']);
39 if (($newMessage = $this->fixEmbeddedAttachments($messageObj->message
, $oldID, $attachmentID)) !== false) {
40 $editor = new ConversationMessageEditor($messageObj);
41 $editor->update(array(
42 'message' => $newMessage