From: Alexander Ebert Date: Tue, 13 Aug 2013 17:12:41 +0000 (+0200) Subject: Improved handling of previously created import mappings X-Git-Tag: 2.0.0_Beta_7~25^2~1 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=3bbdfdb008eb77f913d88f904c5e4b069a27c872;p=GitHub%2FWoltLab%2FWCF.git Improved handling of previously created import mappings --- diff --git a/wcfsetup/install/files/acp/js/WCF.ACP.js b/wcfsetup/install/files/acp/js/WCF.ACP.js index c16efca7a1..1d3a1ae6d2 100644 --- a/wcfsetup/install/files/acp/js/WCF.ACP.js +++ b/wcfsetup/install/files/acp/js/WCF.ACP.js @@ -2275,26 +2275,15 @@ WCF.ACP.Import.Manager = Class.extend({ _invoke: function() { this._index++; if (this._index >= this._objectTypes.length) { - // cleanup - new WCF.Action.Proxy({ - autoSend: true, - data: { - actionName: 'resetMapping', - className: 'wcf\\system\\importer\\ImportHandler' - }, - success: $.proxy(function() { - this._dialog.find('.icon-spinner').removeClass('icon-spinner').addClass('icon-ok'); - this._dialog.find('h1').text(WCF.Language.get('wcf.acp.dataImport.completed')); - - var $form = $('
').appendTo(this._dialog.find('#workerContainer')); - $('').click($.proxy(function() { - window.location = this._redirectURL; - }, this)).appendTo($form); - - this._dialog.wcfDialog('render'); - }, this), - url: 'index.php/AJAXInvoke/?t=' + SECURITY_TOKEN + SID_ARG_2ND - }); + this._dialog.find('.icon-spinner').removeClass('icon-spinner').addClass('icon-ok'); + this._dialog.find('h1').text(WCF.Language.get('wcf.acp.dataImport.completed')); + + var $form = $('
').appendTo(this._dialog.find('#workerContainer')); + $('').click($.proxy(function() { + window.location = this._redirectURL; + }, this)).appendTo($form); + + this._dialog.wcfDialog('render'); } else { this._run( diff --git a/wcfsetup/install/files/acp/templates/dataImport.tpl b/wcfsetup/install/files/acp/templates/dataImport.tpl index a1a737ca7e..f5685778e8 100644 --- a/wcfsetup/install/files/acp/templates/dataImport.tpl +++ b/wcfsetup/install/files/acp/templates/dataImport.tpl @@ -69,6 +69,33 @@ {if !$availableExporters|count}

{lang}wcf.acp.dataImport.selectExporter.noExporters{/lang}

{else} + {if $showMappingNotice} +

{lang}wcf.acp.dataImport.existingMapping.notice{/lang}

+ + {/if} +
diff --git a/wcfsetup/install/files/lib/acp/form/DataImportForm.class.php b/wcfsetup/install/files/lib/acp/form/DataImportForm.class.php index 6305c40eae..6243872937 100644 --- a/wcfsetup/install/files/lib/acp/form/DataImportForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/DataImportForm.class.php @@ -11,7 +11,7 @@ use wcf\util\StringUtil; /** * Provides the data import form. - * + * * @author Marcel Werk * @copyright 2001-2013 WoltLab GmbH * @license GNU Lesser General Public License @@ -25,143 +25,149 @@ class DataImportForm extends AbstractForm { * @var array */ public $additionalData = array(); - + /** * @see wcf\page\AbstractPage::$activeMenuItem */ public $activeMenuItem = 'wcf.acp.menu.link.maintenance.import'; - + /** * @see wcf\page\AbstractPage::$neededPermissions */ public $neededPermissions = array('admin.system.canImportData'); - + /** * list of available exporters * @var array */ public $exporters = array(); - + /** * exporter name * @var string */ public $exporterName = ''; - + /** * exporter object * @var wcf\system\exporter\IExporter */ public $exporter = null; - + /** * list of available importers * @var array */ public $importers = array(); - + /** * list of supported data types * @var array */ public $supportedData = array(); - + /** * selected data types * @var array */ public $selectedData = array(); - + /** * database host name * @var string */ public $dbHost = ''; - + /** * database user name * @var string */ public $dbUser = ''; - + /** * database password * @var string */ public $dbPassword = ''; - + /** * database name * @var string */ public $dbName = ''; - + /** * database table prefix * @var string */ public $dbPrefix = ''; - + /** * file system path * @var string */ public $fileSystemPath = ''; - + + /** + * display notice for existing import mappings + * @var boolean + */ + public $showMappingNotice = false; + /** * user merge mode * @var integer */ public $userMergeMode = 2; - + /** * @see wcf\page\IPage::readParameters() */ public function readParameters() { parent::readParameters(); - + // get available exporters/importers $this->exporters = ObjectTypeCache::getInstance()->getObjectTypes('com.woltlab.wcf.exporter'); $this->importers = array_keys(ObjectTypeCache::getInstance()->getObjectTypes('com.woltlab.wcf.importer')); - + if (isset($_REQUEST['exporterName'])) { $this->exporterName = $_REQUEST['exporterName']; if (!isset($this->exporters[$this->exporterName])) { throw new IllegalLinkException(); } - + $this->exporter = $this->exporters[$this->exporterName]->getProcessor(); $this->supportedData = $this->exporter->getSupportedData(); - + // remove unsupported data foreach ($this->supportedData as $key => $subData) { if (!in_array($key, $this->importers)) { unset($this->supportedData[$key]); continue; } - + foreach ($subData as $key2 => $value) { if (!in_array($value, $this->importers)) { unset($this->supportedData[$key][$key2]); } } } - + // get default database prefix if (!count($_POST)) { $this->dbPrefix = $this->exporter->getDefaultDatabasePrefix(); } } } - + /** * @see wcf\form\IForm::readFormParameters() */ public function readFormParameters() { parent::readFormParameters(); - + if (isset($_POST['selectedData']) && is_array($_POST['selectedData'])) $this->selectedData = $_POST['selectedData']; - + if (isset($_POST['dbHost'])) $this->dbHost = StringUtil::trim($_POST['dbHost']); if (isset($_POST['dbUser'])) $this->dbUser = StringUtil::trim($_POST['dbUser']); if (isset($_POST['dbPassword'])) $this->dbPassword = $_POST['dbPassword']; @@ -171,15 +177,15 @@ class DataImportForm extends AbstractForm { if (isset($_POST['userMergeMode'])) $this->userMergeMode = intval($_POST['userMergeMode']); if (isset($_POST['additionalData'])) $this->additionalData = ArrayUtil::trim($_POST['additionalData']); } - + /** * @see wcf\form\IForm::validate() */ public function validate() { parent::validate(); - + $this->exporter->setData($this->dbHost, $this->dbUser, $this->dbPassword, $this->dbName, $this->dbPrefix, $this->fileSystemPath, $this->additionalData); - + // validate database Access try { $this->exporter->validateDatabaseAccess(); @@ -188,32 +194,32 @@ class DataImportForm extends AbstractForm { WCF::getTPL()->assign('exception', $e); throw new UserInputException('database'); } - + // validate selected data if (!$this->exporter->validateSelectedData($this->selectedData)) { throw new UserInputException('selectedData'); } - + // validate file access if (!$this->exporter->validateFileAccess()) { throw new UserInputException('fileSystemPath'); } - + // validate user merge mode if ($this->userMergeMode < 1 || $this->userMergeMode > 3) { $this->userMergeMode = 2; } } - + /** * @see wcf\form\IForm::save() */ public function save() { parent::save(); - + // get queue $queue = $this->exporter->getQueue(); - + // save import data WCF::getSession()->register('importData', array( 'exporterName' => $this->exporterName, @@ -226,18 +232,30 @@ class DataImportForm extends AbstractForm { 'userMergeMode' => $this->userMergeMode, 'additionalData' => $this->additionalData )); - + WCF::getTPL()->assign('queue', $queue); } - + /** * @see wcf\page\IPage::readData() */ public function readData() { parent::readData(); - if (!count($_POST)) { + if (empty($_POST)) { $this->fileSystemPath = (!empty($_SERVER['DOCUMENT_ROOT']) ? $_SERVER['DOCUMENT_ROOT'] : WCF_DIR); + + if (!$this->exporterName) { + $sql = "SELECT COUNT(*) AS count + FROM wcf".WCF_N."_import_mapping"; + $statement = WCF::getDB()->prepareStatement($sql); + $statement->execute(); + $row = $statement->fetchArray(); + + if ($row['count']) { + $this->showMappingNotice = true; + } + } } } @@ -246,7 +264,7 @@ class DataImportForm extends AbstractForm { */ public function assignVariables() { parent::assignVariables(); - + WCF::getTPL()->assign(array( 'exporter' => $this->exporter, 'importers' => $this->importers, @@ -261,6 +279,7 @@ class DataImportForm extends AbstractForm { 'dbPrefix' => $this->dbPrefix, 'fileSystemPath' => $this->fileSystemPath, 'userMergeMode' => $this->userMergeMode, + 'showMappingNotice' => $this->showMappingNotice, 'additionalData' => $this->additionalData )); } diff --git a/wcfsetup/install/lang/de.xml b/wcfsetup/install/lang/de.xml index a6b3545534..8aa2405d10 100644 --- a/wcfsetup/install/lang/de.xml +++ b/wcfsetup/install/lang/de.xml @@ -196,6 +196,8 @@ + + löschen. Sie sollten die Zuordnungen nicht löschen, wenn Sie jetzt oder zukünftig noch weitere Inhalte aus dem selben Forum übernommen wollen.]]> diff --git a/wcfsetup/install/lang/en.xml b/wcfsetup/install/lang/en.xml index 2f29174e18..407d5a5396 100644 --- a/wcfsetup/install/lang/en.xml +++ b/wcfsetup/install/lang/en.xml @@ -195,6 +195,8 @@ Examples for medium ID detection: + + delete the mappings. It is strongly recommended to keep these mappings as long as there is still data to be imported now or in the future.]]>