Added label import
authorMarcel Werk <burntime@woltlab.com>
Sun, 7 Jul 2013 19:34:59 +0000 (21:34 +0200)
committerMarcel Werk <burntime@woltlab.com>
Sun, 7 Jul 2013 19:34:59 +0000 (21:34 +0200)
com.woltlab.wcf/objectType.xml
wcfsetup/install/files/lib/system/importer/LabelGroupImporter.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/system/importer/LabelImporter.class.php [new file with mode: 0644]

index 88a8c830166e503618fe95a5889311ff774c2ccb..f7494a9032bd08c39d28b75a2836730d66d1ce3a 100644 (file)
                        <definitionname>com.woltlab.wcf.importer</definitionname>
                        <classname><![CDATA[wcf\system\importer\UserRankImporter]]></classname>
                </type>
+               <type>
+                       <name>com.woltlab.wcf.label.group</name>
+                       <definitionname>com.woltlab.wcf.importer</definitionname>
+                       <classname><![CDATA[wcf\system\importer\LabelGroupImporter]]></classname>
+               </type>
+               <type>
+                       <name>com.woltlab.wcf.label</name>
+                       <definitionname>com.woltlab.wcf.importer</definitionname>
+                       <classname><![CDATA[wcf\system\importer\LabelImporter]]></classname>
+               </type>
                <!-- /importers -->
        </import>
 </data>
\ No newline at end of file
diff --git a/wcfsetup/install/files/lib/system/importer/LabelGroupImporter.class.php b/wcfsetup/install/files/lib/system/importer/LabelGroupImporter.class.php
new file mode 100644 (file)
index 0000000..8c43f12
--- /dev/null
@@ -0,0 +1,42 @@
+<?php
+namespace wcf\system\importer;
+use wcf\data\label\group\LabelGroupEditor;
+use wcf\system\WCF;
+
+/**
+ * Imports label groups.
+ *
+ * @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 LabelGroupImporter implements IImporter {
+       /**
+        * @see wcf\system\importer\IImporter::import()
+        */
+       public function import($oldID, array $data, array $additionalData = array()) {
+               // save label group
+               $labelGroup = LabelGroupEditor::create($data);
+               
+               // save objects
+               if (!empty($additionalData['objects'])) {
+                       $sql = "INSERT INTO     wcf".WCF_N."_label_group_to_object
+                                               (groupID, objectTypeID, objectID)
+                               VALUES          (?, ?, ?)";
+                       $statement = WCF::getDB()->prepareStatement($sql);
+                       
+                       foreach ($additionalData['objects'] as $objectTypeID => $objectIDs) {
+                               foreach ($objectIDs as $objectID) {
+                                       $statement->execute(array($labelGroup->groupID, $objectTypeID, $objectID));
+                               }
+                       }
+               }
+               
+               ImportHandler::getInstance()->saveNewID('com.woltlab.wcf.label.group', $oldID, $labelGroup->groupID);
+               
+               return $labelGroup->groupID;
+       }
+}
diff --git a/wcfsetup/install/files/lib/system/importer/LabelImporter.class.php b/wcfsetup/install/files/lib/system/importer/LabelImporter.class.php
new file mode 100644 (file)
index 0000000..a37362f
--- /dev/null
@@ -0,0 +1,27 @@
+<?php
+namespace wcf\system\importer;
+use wcf\data\label\LabelEditor;
+use wcf\system\WCF;
+
+/**
+ * Imports labels.
+ *
+ * @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 LabelImporter implements IImporter {
+       /**
+        * @see wcf\system\importer\IImporter::import()
+        */
+       public function import($oldID, array $data, array $additionalData = array()) {
+               $label = LabelEditor::create($data);
+               
+               ImportHandler::getInstance()->saveNewID('com.woltlab.wcf.label', $oldID, $label->labelID);
+               
+               return $label->labelID;
+       }
+}