Added like importer
authorMarcel Werk <burntime@woltlab.com>
Sun, 7 Jul 2013 15:21:42 +0000 (17:21 +0200)
committerMarcel Werk <burntime@woltlab.com>
Sun, 7 Jul 2013 15:21:42 +0000 (17:21 +0200)
wcfsetup/install/files/lib/system/importer/AbstractLikeImporter.class.php [new file with mode: 0644]

diff --git a/wcfsetup/install/files/lib/system/importer/AbstractLikeImporter.class.php b/wcfsetup/install/files/lib/system/importer/AbstractLikeImporter.class.php
new file mode 100644 (file)
index 0000000..14d24c5
--- /dev/null
@@ -0,0 +1,34 @@
+<?php
+namespace wcf\system\importer;
+use wcf\data\like\LikeEditor;
+
+/**
+ * Imports likes.
+ *
+ * @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 AbstractLikeImporter implements IImporter {
+       /**
+        * object type id for likes
+        * @var integer
+        */
+       protected $objectTypeID = 0;
+       
+       /**
+        * @see wcf\system\importer\IImporter::import()
+        */
+       public function import($oldID, array $data) {
+               if ($data['objectUserID']) $data['objectUserID'] = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.user', $data['objectUserID']);
+               $data['userID'] = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.user', $data['userID']);
+               if (!$data['userID']) return 0;
+               
+               $like = LikeEditor::create(array_merge($data, array('objectTypeID' => $this->objectTypeID)));
+               
+               return $like->likeID;
+       }
+}