use wcf\data\attachment\AttachmentAction;
use wcf\data\attachment\AttachmentEditor;
use wcf\system\exception\SystemException;
+use wcf\util\StringUtil;
/**
* Imports attachments.
*/
class AbstractAttachmentImporter implements IImporter {
/**
- * object type id for attachment
+ * object type id for attachments
* @var integer
*/
protected $objectTypeID = 0;
return 0;
}
+
+ protected function fixEmbeddedAttachments($message, $oldID, $newID) {
+ if (StringUtil::indexOfIgnoreCase($message, '[attach]'.$oldID.'[/attach]') !== false || StringUtil::indexOfIgnoreCase($message, '[attach='.$oldID.']') !== false) {
+ $message = StringUtil::replaceIgnoreCase('[attach]'.$oldID.'[/attach]', '[attach]'.$newID.'[/attach]', $message);
+ $message = StringUtil::replaceIgnoreCase('[attach='.$oldID.']', '[attach='.$newID.']', $message);
+
+ return $message;
+ }
+
+ return false;
+ }
}
class AbstractCommentResponseImporter implements IImporter {
/**
* object type name
- * @var integer
+ * @var string
*/
protected $objectTypeName = '';
--- /dev/null
+<?php
+namespace wcf\system\importer;
+use wcf\data\poll\PollEditor;
+
+/**
+ * Imports polls.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2013 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package com.woltlab.wcf
+ * @subpackage system.importer
+ * @category Community Framework
+ */
+class AbstractPollImporter implements IImporter {
+ /**
+ * object type id for poll
+ * @var integer
+ */
+ protected $objectTypeID = 0;
+
+ /**
+ * object type name
+ * @var string
+ */
+ protected $objectTypeName = '';
+
+ /**
+ * @see wcf\system\importer\IImporter::import()
+ */
+ public function import($oldID, array $data) {
+ $poll = PollEditor::create(array_merge($data, array('objectTypeID' => $this->objectTypeID)));
+
+ ImportHandler::getInstance()->saveNewID($this->objectTypeName, $oldID, $poll->pollID);
+
+ return $poll->pollID;
+ }
+}
--- /dev/null
+<?php
+namespace wcf\system\importer;
+use wcf\data\poll\option\PollOptionEditor;
+
+/**
+ * Imports poll votes.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2013 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package com.woltlab.wcf
+ * @subpackage system.importer
+ * @category Community Framework
+ */
+class AbstractPollOptionImporter implements IImporter {
+ /**
+ * option object type name
+ * @var string
+ */
+ protected $objectTypeName = '';
+
+ /**
+ * poll object type name
+ * @var string
+ */
+ protected $pollObjectTypeName = '';
+
+ /**
+ * @see wcf\system\importer\IImporter::import()
+ */
+ public function import($oldID, array $data) {
+ $data['pollID'] = ImportHandler::getInstance()->getNewID($this->pollObjectTypeName, $data['pollID']);
+ if (!$data['pollID']) return 0;
+
+ $option = PollOptionEditor::create($data);
+
+ ImportHandler::getInstance()->saveNewID($this->objectTypeName, $oldID, $option->optionID);
+
+ return $option->optionID;
+ }
+}
--- /dev/null
+<?php
+namespace wcf\system\importer;
+use wcf\system\WCF;
+
+/**
+ * Imports poll votes.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2013 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package com.woltlab.wcf
+ * @subpackage system.importer
+ * @category Community Framework
+ */
+class AbstractPollOptionVoteImporter implements IImporter {
+ /**
+ * option object type name
+ * @var string
+ */
+ protected $objectTypeName = '';
+
+ /**
+ * poll object type name
+ * @var string
+ */
+ protected $pollObjectTypeName = '';
+
+ /**
+ * @see wcf\system\importer\IImporter::import()
+ */
+ public function import($oldID, array $data) {
+ $data['userID'] = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.user', $data['userID']);
+ if (!$data['userID']) return 0;
+
+ $data['pollID'] = ImportHandler::getInstance()->getNewID($this->pollObjectTypeName, $data['pollID']);
+ if (!$data['pollID']) return 0;
+
+ $data['optionID'] = ImportHandler::getInstance()->getNewID($this->pollObjectTypeName, $data['optionID']);
+ if (!$data['optionID']) return 0;
+
+ $sql = "INSERT INTO wcf".WCF_N."_poll_option_vote
+ (pollID, optionID, userID)
+ VALUES (?, ?, ?)";
+ $statement = WCF::getDB()->prepareStatement($sql);
+ $statement->execute(array($data['pollID'], $data['optionID'], $data['userID']));
+
+ return 1;
+ }
+}
--- /dev/null
+<?php
+namespace wcf\system\importer;
+use wcf\data\user\object\watch\UserObjectWatchAction;
+
+/**
+ * Imports watched objects.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2013 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package com.woltlab.wcf
+ * @subpackage system.importer
+ * @category Community Framework
+ */
+class AbstractWatchedObjectImporter implements IImporter {
+ /**
+ * object type id for watched objects
+ * @var integer
+ */
+ protected $objectTypeID = 0;
+
+ /**
+ * @see wcf\system\importer\IImporter::import()
+ */
+ public function import($oldID, array $data) {
+ $data['userID'] = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.user', $data['userID']);
+ if (!$data['userID']) return 0;
+
+ $action = new UserObjectWatchAction(array(), 'create', array(
+ 'data' => array_merge($data, array('objectTypeID' => $this->objectTypeID))
+ ));
+ $returnValues = $action->executeAction();
+ return $returnValues['returnValues']->watchID;
+ }
+}