/** * @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(); } catch (DatabaseException $e) { 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 switch ($this->userMergeMode) { case UserImporter::MERGE_MODE_EMAIL: case UserImporter::MERGE_MODE_USERNAME_OR_EMAIL: break; default: $this->userMergeMode = UserImporter::MERGE_MODE_EMAIL; } }
/** * @see \wcf\system\worker\IWorker::validate() */ public function validate() { WCF::getSession()->checkPermissions(array('admin.system.canImportData')); if (!isset($this->parameters['objectType'])) { throw new SystemException("parameter 'objectType' missing"); } // get import data $this->importData = WCF::getSession()->getVar('importData'); if ($this->importData === null) { throw new SystemException("import data missing"); } // get exporter $this->exporter = ObjectTypeCache::getInstance()->getObjectTypeByName('com.woltlab.wcf.exporter', $this->importData['exporterName'])->getProcessor(); // set data $this->exporter->setData($this->importData['dbHost'], $this->importData['dbUser'], $this->importData['dbPassword'], $this->importData['dbName'], $this->importData['dbPrefix'], $this->importData['fileSystemPath'], $this->importData['additionalData']); $this->exporter->init(); // set user merge mode ImportHandler::getInstance()->setUserMergeMode($this->importData['userMergeMode']); // set import hash ImportHandler::getInstance()->setImportHash(substr(StringUtil::getHash($this->importData['dbHost'] . $this->importData['dbName'] . $this->importData['dbPrefix']), 0, 8)); }
/** * Reads the path to the file system. */ protected function readFileSystemPath() { CLIWCF::getReader()->println(WCF::getLanguage()->get('wcf.acp.dataImport.configure.fileSystem.path')); while (true) { $this->fileSystemPath = CLIWCF::getReader()->readLine('> '); if ($this->fileSystemPath === null) { exit; } $this->exporter->setData($this->dbHost, $this->dbUser, $this->dbPassword, $this->dbName, $this->dbPrefix, $this->fileSystemPath, array()); if (!$this->exporter->validateFileAccess()) { CLIWCF::getReader()->println(WCF::getLanguage()->get('wcf.acp.dataImport.configure.fileSystem.path.error')); continue; } break; } }