</dd>
</dl>
{/foreach}
+
+ {event name='dataFields'}
</fieldset>
- {*<fieldset>
+ <fieldset>
<legend>{lang}wcf.acp.dataImport.configure.settings{/lang}</legend>
+ <dl>
+ <dt><label for="userMergeMode">{lang}wcf.acp.dataImport.configure.settings.userMergeMode{/lang}</label></dt>
+ <dd>
+ <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>
+ </dd>
+ </dl>
- </fieldset>*}
+ {event name='settingFields'}
+ </fieldset>
<fieldset{if $errorField == 'database'} class="formError"{/if}>
<legend>{lang}wcf.acp.dataImport.configure.database{/lang}</legend>
{/if}
</dd>
</dl>
+
+ {event name='databaseFields'}
</fieldset>
<fieldset>
<small>{lang}wcf.acp.dataImport.configure.fileSystem.path.description{/lang}</small>
</dd>
</dl>
+
+ {event name='fileSystemFields'}
</fieldset>
+
+ {event name='fieldsets'}
</div>
<div class="formSubmit">
*/
public $fileSystemPath = '';
+ /**
+ * user merge mode
+ * @var integer
+ */
+ public $userMergeMode = 2;
+
/**
* @see wcf\page\IPage::readParameters()
*/
if (isset($_POST['dbName'])) $this->dbName = StringUtil::trim($_POST['dbName']);
if (isset($_POST['dbPrefix'])) $this->dbPrefix = StringUtil::trim($_POST['dbPrefix']);
if (isset($_POST['fileSystemPath'])) $this->fileSystemPath = StringUtil::trim($_POST['fileSystemPath']);
+ if (isset($_POST['userMergeMode'])) $this->userMergeMode = intval($_POST['userMergeMode']);
}
/**
if (!$this->exporter->validateFileAccess()) {
throw new UserInputException('fileSystemPath');
}
+
+ // validate user merge mode
+ if ($this->userMergeMode < 1 || $this->userMergeMode > 3) {
+ $this->userMergeMode = 2;
+ }
}
/**
'dbName' => $this->dbName,
'dbPrefix' => $this->dbPrefix,
'fileSystemPath' => $this->fileSystemPath,
+ 'userMergeMode' => $this->userMergeMode
));
WCF::getTPL()->assign('queue', $queue);
'dbPassword' => $this->dbPassword,
'dbName' => $this->dbName,
'dbPrefix' => $this->dbPrefix,
- 'fileSystemPath' => $this->fileSystemPath
+ 'fileSystemPath' => $this->fileSystemPath,
+ 'userMergeMode' => $this->userMergeMode
));
}
}
*/
protected $importers = array();
+ /**
+ * user merge mode
+ * @var integer
+ */
+ protected $userMergeMode = 2;
+
/**
* @see wcf\system\SingletonFactory::init()
*/
unset($this->idMappingCache[$objectTypeID][$oldID]);
}
+
+ /**
+ * Sets the user merge mode.
+ *
+ * @param integer $mode
+ */
+ public function setUserMergeMode($mode) {
+ $this->userMergeMode = $mode;
+ }
+
+ /**
+ * Gets the user merge mode.
+ *
+ * @return integer
+ */
+ public function getUserMergeMode() {
+ return $this->userMergeMode;
+ }
}
use wcf\data\user\UserAction;
use wcf\system\database\DatabaseException;
use wcf\system\WCF;
+use wcf\util\StringUtil;
/**
* Imports users.
* @see wcf\system\importer\IImporter::import()
*/
public function import($oldID, array $data, array $additionalData = array()) {
+ // resolve duplicates
+ $existingUser = User::getUserByUsername($data['username']);
+ if ($existingUser->userID) {
+ if ($this->userMergeMode == 1 || ($this->userMergeMode == 3 && StringUtil::toLowerCase($existingUser->email) != StringUtil::toLowerCase($data['email']))) {
+ // rename user
+ $data['username'] = self::resolveDuplicate($data['username']);
+ }
+ else {
+ // merge user
+ ImportHandler::getInstance()->saveNewID('com.woltlab.wcf.user', $oldID, $existingUser->userID);
+
+ return $existingUser->userID;
+ }
+ }
+
// check existing user id
$sql = "SELECT COUNT(*) AS count
FROM wcf".WCF_N."_user
return $newUserID;
}
+
+ /**
+ * Revolves duplicate user names.
+ *
+ * @param string $username
+ * @return string new username
+ */
+ private static function resolveDuplicate($username) {
+ $i = 0;
+ $newUsername = '';
+ do {
+ $i++;
+ $newUsername = 'Duplicate'.($i > 1 ? $i : '').' '.$username;
+ // try username
+ $sql = "SELECT userID
+ FROM wcf".WCF_N."_user
+ WHERE username = ?";
+ $statement = WCF::getDB()->prepareStatement($sql);
+ $statement->execute(array($newUsername));
+ $row = $statement->fetchArray();
+ if (empty($row['userID'])) break;
+ }
+ while (true);
+
+ return $newUsername;
+ }
}
namespace wcf\system\worker;
use wcf\data\object\type\ObjectTypeCache;
use wcf\system\exception\SystemException;
+use wcf\system\importer\ImportHandler;
use wcf\system\WCF;
/**
// set data
$this->exporter->setData($this->importData['dbHost'], $this->importData['dbUser'], $this->importData['dbPassword'], $this->importData['dbName'], $this->importData['dbPrefix'], $this->importData['fileSystemPath']);
$this->exporter->init();
+
+ // set user merge mode
+ ImportHandler::getInstance()->setUserMergeMode($this->importData['userMergeMode']);
}
/**
<item name="wcf.acp.dataImport.configure.database.error"><![CDATA[Beim Verbindungsversuch mit der Datenbank ist folgender Fehler aufgetreten:
<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.userMergeMode"><![CDATA[Verhalten bei sich überschneidenden Benutzernamen]]></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>
</category>
<category name="wcf.acp.exceptionLog">
<item name="wcf.acp.dataImport.configure.database.error"><![CDATA[TODO: Beim Verbindungsversuch mit der Datenbank ist folgender Fehler aufgetreten:
<br /><strong>{$exception->getMessage()}<br />{$exception->getErrorDesc()}</strong>]]></item>
<item name="wcf.acp.dataImport.configure.fileSystem.path.error"><![CDATA[TODO: Es wurde keine Installation unter dem angegeben Pfad gefunden.]]></item>
+ <item name="wcf.acp.dataImport.configure.settings.userMergeMode"><![CDATA[TODO: Verhalten bei sich überschneidenden Benutzernamen]]></item>
+ <item name="wcf.acp.dataImport.configure.settings.userMergeMode.1"><![CDATA[TODO: Benutzeraccounts umbennen]]></item>
+ <item name="wcf.acp.dataImport.configure.settings.userMergeMode.2"><![CDATA[TODO: Benutzeraccounts zusammenlegen]]></item>
+ <item name="wcf.acp.dataImport.configure.settings.userMergeMode.3"><![CDATA[TODO: Benutzeraccounts zusammenlegen, wenn auch die E-Mail-Adresse identisch ist]]></item>
</category>
<category name="wcf.acp.exceptionLog">