From 51ac9962e619e2f07bc48af86a452a861b407942 Mon Sep 17 00:00:00 2001 From: Marcel Werk Date: Sun, 7 Jul 2013 21:34:59 +0200 Subject: [PATCH] Added label import --- com.woltlab.wcf/objectType.xml | 10 +++++ .../importer/LabelGroupImporter.class.php | 42 +++++++++++++++++++ .../system/importer/LabelImporter.class.php | 27 ++++++++++++ 3 files changed, 79 insertions(+) create mode 100644 wcfsetup/install/files/lib/system/importer/LabelGroupImporter.class.php create mode 100644 wcfsetup/install/files/lib/system/importer/LabelImporter.class.php diff --git a/com.woltlab.wcf/objectType.xml b/com.woltlab.wcf/objectType.xml index 88a8c83016..f7494a9032 100644 --- a/com.woltlab.wcf/objectType.xml +++ b/com.woltlab.wcf/objectType.xml @@ -252,6 +252,16 @@ com.woltlab.wcf.importer + + com.woltlab.wcf.label.group + com.woltlab.wcf.importer + + + + com.woltlab.wcf.label + com.woltlab.wcf.importer + + \ 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 index 0000000000..8c43f1208e --- /dev/null +++ b/wcfsetup/install/files/lib/system/importer/LabelGroupImporter.class.php @@ -0,0 +1,42 @@ + + * @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 index 0000000000..a37362f183 --- /dev/null +++ b/wcfsetup/install/files/lib/system/importer/LabelImporter.class.php @@ -0,0 +1,27 @@ + + * @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; + } +} -- 2.20.1