Improved handling of previously created import mappings
authorAlexander Ebert <ebert@woltlab.com>
Tue, 13 Aug 2013 17:12:41 +0000 (19:12 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Tue, 13 Aug 2013 17:12:41 +0000 (19:12 +0200)
wcfsetup/install/files/acp/js/WCF.ACP.js
wcfsetup/install/files/acp/templates/dataImport.tpl
wcfsetup/install/files/lib/acp/form/DataImportForm.class.php
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml

index c16efca7a1b9387d8c9f669b43255ffee9d4bb2a..1d3a1ae6d299b411983c940f32e9361ea7704994 100644 (file)
@@ -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 = $('<div class="formSubmit" />').appendTo(this._dialog.find('#workerContainer'));
-                                       $('<button>' + WCF.Language.get('wcf.global.button.next') + '</button>').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 = $('<div class="formSubmit" />').appendTo(this._dialog.find('#workerContainer'));
+                       $('<button>' + WCF.Language.get('wcf.global.button.next') + '</button>').click($.proxy(function() {
+                               window.location = this._redirectURL;
+                       }, this)).appendTo($form);
+                       
+                       this._dialog.wcfDialog('render');
                }
                else {
                        this._run(
index a1a737ca7e84649ad10fabc2e003750f470d4870..f5685778e877f80aa206d3670bbadbc0423bb33f 100644 (file)
        {if !$availableExporters|count}
                <p class="info">{lang}wcf.acp.dataImport.selectExporter.noExporters{/lang}</p>
        {else}
+               {if $showMappingNotice}
+                       <p class="warning">{lang}wcf.acp.dataImport.existingMapping.notice{/lang}</p>
+                       <script data-relocate="true">
+                               //<![CDATA[
+                               $(function() {
+                                       $('#deleteMapping').click(function() {
+                                               WCF.System.Confirmation.show('{lang}wcf.acp.dataImport.existingMapping.confirmMessage{/lang}', function(action) {
+                                                       if (action === 'confirm') {
+                                                               new WCF.Action.Proxy({
+                                                                       autoSend: true,
+                                                                       data: {
+                                                                               actionName: 'resetMapping',
+                                                                               className: 'wcf\\system\\importer\\ImportHandler'
+                                                                       },
+                                                                       success: function() { window.location.reload(); },
+                                                                       url: 'index.php/AJAXInvoke/?t=' + SECURITY_TOKEN + SID_ARG_2ND
+                                                               });
+                                                       }
+                                               });
+                                               
+                                               return false;
+                                       });
+                               });
+                               //]]>
+                       </script>
+               {/if}
+               
                <form method="get" action="{link controller='DataImport'}{/link}">
                        <div class="container containerPadding marginTop">
                                <fieldset>
index 6305c40eae87ac6b393a4f0da67f4fa308a8fbe1..6243872937f0f4b2d8da259c28c6e7b83788190f 100644 (file)
@@ -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 <http://opensource.org/licenses/lgpl-license.php>
@@ -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<string>
         */
        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
                ));
        }
index a6b35455348b5676b6e8b7f67def0ff8cea00f82..8aa2405d10f254f40b4398ac3d3077ee9b82f285 100644 (file)
                <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.existingMapping.confirmMessage"><![CDATA[Wollen Sie die bestehenden Zuordnungen wirklich löschen?]]></item>
+               <item name="wcf.acp.dataImport.existingMapping.notice"><![CDATA[Es existieren Zuordnungen eines früheren Import-Vorganges, diese werden verwendet um Inhalte aus dem importierten Forum einwandfrei zu zuordnen. Wenn Sie den Import-Vorgang vollständig abgeschlossen haben, können Sie diese Zuordnungen <a id="deleteMapping">löschen</a>. Sie sollten die Zuordnungen nicht löschen, wenn Sie jetzt oder zukünftig noch weitere Inhalte aus dem selben Forum übernommen wollen.]]></item>
                <item name="wcf.acp.dataImport.selectExporter.noExporters"><![CDATA[Es wurde keine Datenquelle für einen Datenimport gefunden.]]></item>
        </category>
        
index 2f29174e189d9328249b699eb223da15d857d280..407d5a53961361ae6401d7b6981e908771d7b6a6 100644 (file)
@@ -195,6 +195,8 @@ Examples for medium ID detection:
                <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.existingMapping.confirmMessage"><![CDATA[Do you really want to delete the existing import mappings?]]></item>
+               <item name="wcf.acp.dataImport.existingMapping.notice"><![CDATA[There are import mappings created by a previous import process, these mappings are used to properly handle connections between data from the imported forum and this one. In case you’ve imported all desired data, you can <a id="deleteMapping">delete</a> 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.]]></item>
                <item name="wcf.acp.dataImport.selectExporter.noExporters"><![CDATA[There are no data importers installed.]]></item>
        </category>