Assign an interface language in UserImporter
authorTim Düsterhus <duesterhus@woltlab.com>
Tue, 19 Aug 2014 16:25:28 +0000 (18:25 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Tue, 19 Aug 2014 16:25:28 +0000 (18:25 +0200)
see https://www.woltlab.com/forum/index.php/Thread/229091-Import-aus-VB4-2-Sprachauswahl-im-Profil-leer/

wcfsetup/install/files/lib/system/importer/UserImporter.class.php

index 664b1828ced9638cf717f08f80e63d3a522fb39e..5beab5d764ed1b9d7aea2fd46ee8355d8a4c4e73 100644 (file)
@@ -134,6 +134,20 @@ class UserImporter extends AbstractImporter {
                        }
                }
                
+               $languageIDs = array();
+               if (isset($additionalData['languages'])) {
+                       foreach ($additionalData['languages'] as $languageCode) {
+                               $language = LanguageFactory::getInstance()->getLanguageByCode($languageCode);
+                               if ($language !== null) $languageIDs[] = $language->languageID;
+                       }
+               }
+               if (empty($languageIDs)) {
+                       $languageIDs[] = LanguageFactory::getInstance()->getDefaultLanguageID();
+               }
+               
+               // assign an interface language
+               $data['languageID'] = reset($languageIDs);
+               
                // create user
                $user = UserEditor::create($data);
                $userEditor = new UserEditor($user);
@@ -170,16 +184,6 @@ class UserImporter extends AbstractImporter {
                                                (userID, languageID)
                        VALUES                  (?, ?)";
                $statement = WCF::getDB()->prepareStatement($sql);
-               $languageIDs = array();
-               if (isset($additionalData['languages'])) {
-                       foreach ($additionalData['languages'] as $languageCode) {
-                               $language = LanguageFactory::getInstance()->getLanguageByCode($languageCode);
-                               if ($language !== null) $languageIDs[] = $language->languageID;
-                       }
-               }
-               if (empty($languageIDs)) {
-                       $languageIDs[] = LanguageFactory::getInstance()->getDefaultLanguageID();
-               }
                foreach ($languageIDs as $languageID) {
                        $statement->execute(array(
                                $user->userID,