Added 'merge users by e-mail address'
authorMarcel Werk <burntime@woltlab.com>
Thu, 21 Nov 2013 17:42:41 +0000 (18:42 +0100)
committerMarcel Werk <burntime@woltlab.com>
Thu, 21 Nov 2013 17:42:41 +0000 (18:42 +0100)
wcfsetup/install/files/acp/templates/dataImport.tpl
wcfsetup/install/files/lib/acp/form/DataImportForm.class.php
wcfsetup/install/files/lib/system/cli/command/ImportCLICommand.class.php
wcfsetup/install/files/lib/system/importer/UserImporter.class.php
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml

index efd8b774ed3cc0752d2b541fa2846667826c1b00..768654919cd644191613b730a7b97d0ac6fb512a 100644 (file)
                                                <label><input type="radio" id="userMergeMode" name="userMergeMode" value="1" {if $userMergeMode == 1}checked="checked" {/if}/> {lang}wcf.acp.dataImport.configure.settings.userMergeMode.1{/lang}</label>
                                                <label><input type="radio" name="userMergeMode" value="2" {if $userMergeMode == 2}checked="checked" {/if}/> {lang}wcf.acp.dataImport.configure.settings.userMergeMode.2{/lang}</label>
                                                <label><input type="radio" name="userMergeMode" value="3" {if $userMergeMode == 3}checked="checked" {/if}/> {lang}wcf.acp.dataImport.configure.settings.userMergeMode.3{/lang}</label>
+                                               <label><input type="radio" name="userMergeMode" value="4" {if $userMergeMode == 4}checked="checked" {/if}/> {lang}wcf.acp.dataImport.configure.settings.userMergeMode.4{/lang}</label>
                                        </dd>
                                </dl>
                                
index 5c74718558384cb62c75762ede636709a685130d..7858dfd813bd1773f0ee6b79bcf639925a8081c2 100644 (file)
@@ -212,7 +212,7 @@ class DataImportForm extends AbstractForm {
                }
                
                // validate user merge mode
-               if ($this->userMergeMode < 1 || $this->userMergeMode > 3) {
+               if ($this->userMergeMode < 1 || $this->userMergeMode > 4) {
                        $this->userMergeMode = 2;
                }
        }
index 108fb6d18841e341eb8b7c57060beb9ae79108be..23ab20b926b4cc959ca5f4ac2b7c691db1c6d39e 100644 (file)
@@ -461,15 +461,16 @@ class ImportCLICommand implements ICLICommand {
                CLIWCF::getReader()->println('1) '.WCF::getLanguage()->get('wcf.acp.dataImport.configure.settings.userMergeMode.1'));
                CLIWCF::getReader()->println('2) '.WCF::getLanguage()->get('wcf.acp.dataImport.configure.settings.userMergeMode.2').' (*)');
                CLIWCF::getReader()->println('3) '.WCF::getLanguage()->get('wcf.acp.dataImport.configure.settings.userMergeMode.3'));
+               CLIWCF::getReader()->println('4) '.WCF::getLanguage()->get('wcf.acp.dataImport.configure.settings.userMergeMode.4'));
                CLIWCF::getReader()->println(WCF::getLanguage()->getDynamicVariable('wcf.acp.dataImport.cli.selection', array(
                        'minSelection' => 1,
-                       'maxSelection' => 3
+                       'maxSelection' => 4
                )));
                
                while (true) {
                        $this->userMergeMode = CLIWCF::getReader()->readLine('> ');
                        if ($this->userMergeMode === null) exit;
-                       if ($this->userMergeMode != intval($this->userMergeMode) || $this->userMergeMode < 1 || $this->userMergeMode > 3) {
+                       if ($this->userMergeMode != intval($this->userMergeMode) || $this->userMergeMode < 1 || $this->userMergeMode > 4) {
                                $this->userMergeMode = 2;
                        }
                        
index 0ed9163d1bd32297aaca15668cf24c2a3df90d02..9ca7be7f6ccde134237986b81d1381ee40210a9a 100644 (file)
@@ -59,19 +59,30 @@ class UserImporter extends AbstractImporter {
         */
        public function import($oldID, array $data, array $additionalData = array()) {
                // resolve duplicates
-               $existingUser = User::getUserByUsername($data['username']);
-               if ($existingUser->userID) {
-                       if (ImportHandler::getInstance()->getUserMergeMode() == 1 || (ImportHandler::getInstance()->getUserMergeMode() == 3 && mb_strtolower($existingUser->email) != mb_strtolower($data['email']))) {
-                               // rename user
-                               $data['username'] = self::resolveDuplicate($data['username']);
-                       }
-                       else {
+               if (ImportHandler::getInstance()->getUserMergeMode() == 4) {
+                       $existingUser = User::getUserByEmail($data['email']);
+                       if ($existingUser->userID) {
                                // merge user
                                ImportHandler::getInstance()->saveNewID('com.woltlab.wcf.user', $oldID, $existingUser->userID);
-                               
+                                       
                                return 0;
                        }
                }
+               else {
+                       $existingUser = User::getUserByUsername($data['username']);
+                       if ($existingUser->userID) {
+                               if (ImportHandler::getInstance()->getUserMergeMode() == 1 || (ImportHandler::getInstance()->getUserMergeMode() == 3 && mb_strtolower($existingUser->email) != mb_strtolower($data['email']))) {
+                                       // rename user
+                                       $data['username'] = self::resolveDuplicate($data['username']);
+                               }
+                               else {
+                                       // merge user
+                                       ImportHandler::getInstance()->saveNewID('com.woltlab.wcf.user', $oldID, $existingUser->userID);
+                                       
+                                       return 0;
+                               }
+                       }
+               }
                
                // check existing user id
                if (is_numeric($oldID)) {
index 0df8f4f0561a665008c5ec8183ba63d053276515..1a9d30b1b3322f78ba59b4ece7fc5a6ed8b0b1a5 100644 (file)
                <br /><strong>{$exception->getMessage()}<br />{$exception->getErrorDesc()}</strong>]]></item>
                <item name="wcf.acp.dataImport.configure.fileSystem.path.error"><![CDATA[Es wurde keine Installation unter dem angegeben Pfad gefunden.]]></item>
                <item name="wcf.acp.dataImport.configure.settings"><![CDATA[Einstellungen]]></item>
-               <item name="wcf.acp.dataImport.configure.settings.userMergeMode"><![CDATA[Verhalten bei sich überschneidenden Benutzernamen]]></item>
+               <item name="wcf.acp.dataImport.configure.settings.userMergeMode"><![CDATA[Verhalten bei sich überschneidenden Benutzeraccounts]]></item>
                <item name="wcf.acp.dataImport.configure.settings.userMergeMode.1"><![CDATA[Benutzeraccounts umbennen]]></item>
-               <item name="wcf.acp.dataImport.configure.settings.userMergeMode.2"><![CDATA[Benutzeraccounts zusammenlegen]]></item>
-               <item name="wcf.acp.dataImport.configure.settings.userMergeMode.3"><![CDATA[Benutzeraccounts zusammenlegen, wenn auch die E-Mail-Adresse identisch ist]]></item>
+               <item name="wcf.acp.dataImport.configure.settings.userMergeMode.2"><![CDATA[Benutzeraccounts mit identischen Namen zusammenlegen]]></item>
+               <item name="wcf.acp.dataImport.configure.settings.userMergeMode.3"><![CDATA[Benutzeraccounts mit identischen Namen und E-Mail-Adressen zusammenlegen]]></item>
+               <item name="wcf.acp.dataImport.configure.settings.userMergeMode.4"><![CDATA[Benutzeraccounts mit identischen E-Mail-Adressen zusammenlegen]]></item>
                <item name="wcf.acp.dataImport.data.com.woltlab.wcf.user"><![CDATA[Benutzer]]></item>
                <item name="wcf.acp.dataImport.data.com.woltlab.wcf.user.group"><![CDATA[Benutzergruppen]]></item>
                <item name="wcf.acp.dataImport.data.com.woltlab.wcf.user.option"><![CDATA[Benutzerprofilfelder]]></item>
index dabdc0d9ed1ad55bddc303ce6499b923b4fce498..96d232e30c464cfb4eea929ff057d0e454979c77 100644 (file)
@@ -186,10 +186,11 @@ Examples for medium ID detection:
                <br /><strong>{$exception->getMessage()}<br />{$exception->getErrorDesc()}</strong>]]></item>
                <item name="wcf.acp.dataImport.configure.fileSystem.path.error"><![CDATA[Unable to find a valid installation with the given path.]]></item>
                <item name="wcf.acp.dataImport.configure.settings"><![CDATA[Settings]]></item>
-               <item name="wcf.acp.dataImport.configure.settings.userMergeMode"><![CDATA[Conflicting Usernames]]></item>
+               <item name="wcf.acp.dataImport.configure.settings.userMergeMode"><![CDATA[TOOD: Verhalten bei sich überschneidenden Benutzeraccounts]]></item>
                <item name="wcf.acp.dataImport.configure.settings.userMergeMode.1"><![CDATA[Rename users]]></item>
-               <item name="wcf.acp.dataImport.configure.settings.userMergeMode.2"><![CDATA[Merge users]]></item>
-               <item name="wcf.acp.dataImport.configure.settings.userMergeMode.3"><![CDATA[Merge users if email address is equal]]></item>
+               <item name="wcf.acp.dataImport.configure.settings.userMergeMode.2"><![CDATA[TOOD: Benutzeraccounts mit identischen Namen zusammenlegen]]></item>
+               <item name="wcf.acp.dataImport.configure.settings.userMergeMode.3"><![CDATA[TOOD: Benutzeraccounts mit identischen Namen und E-Mail-Adressen zusammenlegen]]></item>
+               <item name="wcf.acp.dataImport.configure.settings.userMergeMode.4"><![CDATA[TOOD: Benutzeraccounts mit identischen E-Mail-Adressen zusammenlegen]]></item>
                <item name="wcf.acp.dataImport.data.com.woltlab.wcf.user"><![CDATA[User]]></item>
                <item name="wcf.acp.dataImport.data.com.woltlab.wcf.user.group"><![CDATA[User groups]]></item>
                <item name="wcf.acp.dataImport.data.com.woltlab.wcf.user.option"><![CDATA[User profile fields]]></item>