From 2df9ae3275aa55916dd768e48047f53c942ca8e1 Mon Sep 17 00:00:00 2001 From: Marcel Werk Date: Thu, 21 Nov 2013 18:42:41 +0100 Subject: [PATCH] Added 'merge users by e-mail address' --- .../files/acp/templates/dataImport.tpl | 1 + .../lib/acp/form/DataImportForm.class.php | 2 +- .../cli/command/ImportCLICommand.class.php | 5 ++-- .../system/importer/UserImporter.class.php | 27 +++++++++++++------ wcfsetup/install/lang/de.xml | 7 ++--- wcfsetup/install/lang/en.xml | 7 ++--- 6 files changed, 32 insertions(+), 17 deletions(-) diff --git a/wcfsetup/install/files/acp/templates/dataImport.tpl b/wcfsetup/install/files/acp/templates/dataImport.tpl index efd8b774ed..768654919c 100644 --- a/wcfsetup/install/files/acp/templates/dataImport.tpl +++ b/wcfsetup/install/files/acp/templates/dataImport.tpl @@ -160,6 +160,7 @@ + diff --git a/wcfsetup/install/files/lib/acp/form/DataImportForm.class.php b/wcfsetup/install/files/lib/acp/form/DataImportForm.class.php index 5c74718558..7858dfd813 100644 --- a/wcfsetup/install/files/lib/acp/form/DataImportForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/DataImportForm.class.php @@ -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; } } diff --git a/wcfsetup/install/files/lib/system/cli/command/ImportCLICommand.class.php b/wcfsetup/install/files/lib/system/cli/command/ImportCLICommand.class.php index 108fb6d188..23ab20b926 100644 --- a/wcfsetup/install/files/lib/system/cli/command/ImportCLICommand.class.php +++ b/wcfsetup/install/files/lib/system/cli/command/ImportCLICommand.class.php @@ -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; } diff --git a/wcfsetup/install/files/lib/system/importer/UserImporter.class.php b/wcfsetup/install/files/lib/system/importer/UserImporter.class.php index 0ed9163d1b..9ca7be7f6c 100644 --- a/wcfsetup/install/files/lib/system/importer/UserImporter.class.php +++ b/wcfsetup/install/files/lib/system/importer/UserImporter.class.php @@ -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)) { diff --git a/wcfsetup/install/lang/de.xml b/wcfsetup/install/lang/de.xml index 0df8f4f056..1a9d30b1b3 100644 --- a/wcfsetup/install/lang/de.xml +++ b/wcfsetup/install/lang/de.xml @@ -187,10 +187,11 @@
{$exception->getMessage()}
{$exception->getErrorDesc()}
]]> - + - - + + + diff --git a/wcfsetup/install/lang/en.xml b/wcfsetup/install/lang/en.xml index dabdc0d9ed..96d232e30c 100644 --- a/wcfsetup/install/lang/en.xml +++ b/wcfsetup/install/lang/en.xml @@ -186,10 +186,11 @@ Examples for medium ID detection:
{$exception->getMessage()}
{$exception->getErrorDesc()}
]]> - + - - + + + -- 2.20.1