From 34526cff12be7963ae077973676ce891b442d2f6 Mon Sep 17 00:00:00 2001 From: Marcel Werk Date: Wed, 1 Jan 2014 18:06:35 +0100 Subject: [PATCH] Fixed import issue --- .../importer/UserOptionImporter.class.php | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/wcfsetup/install/files/lib/system/importer/UserOptionImporter.class.php b/wcfsetup/install/files/lib/system/importer/UserOptionImporter.class.php index 5b971912d4..71637b92d8 100644 --- a/wcfsetup/install/files/lib/system/importer/UserOptionImporter.class.php +++ b/wcfsetup/install/files/lib/system/importer/UserOptionImporter.class.php @@ -1,5 +1,7 @@ + */ + protected $categoryCache = null; + /** * Creates a new UserOptionImporter object. */ @@ -56,6 +64,9 @@ class UserOptionImporter extends AbstractImporter { } } + // create category + $this->createCategory($data['categoryName']); + // save option $action = new UserOptionAction(array(), 'create', array('data' => $data)); $returnValues = $action->executeAction(); @@ -85,4 +96,30 @@ class UserOptionImporter extends AbstractImporter { return $userOption->optionID; } + + /** + * Creates the given category if necessary. + * + * @param string $name + */ + protected function createCategory($name) { + if ($this->categoryCache === null) { + // get existing categories + $list = new UserOptionCategoryList(); + $list->getConditionBuilder()->add('categoryName = ? OR parentCategoryName = ?', array('profile', 'profile')); + $list->readObjects(); + foreach ($list->getObjects() as $category) $this->categoryCache[] = $category->categoryName; + } + + if (!in_array($name, $this->categoryCache)) { + // create category + UserOptionCategoryEditor::create(array( + 'packageID' => 1, + 'categoryName' => $name, + 'parentCategoryName' => 'profile' + )); + + $this->categoryCache[] = $name; + } + } } -- 2.20.1