/** * @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; } }
/** * Reads the database connection. */ protected function readDatabaseConnection() { while (true) { CLIWCF::getReader()->println(WCF::getLanguage()->get('wcf.acp.dataImport.configure.database')); $this->dbHost = CLIWCF::getReader()->readLine(WCF::getLanguage()->get('wcf.acp.dataImport.configure.database.host') . '> '); if ($this->dbHost === null) { exit; } $this->dbUser = CLIWCF::getReader()->readLine(WCF::getLanguage()->get('wcf.acp.dataImport.configure.database.user') . '> '); if ($this->dbUser === null) { exit; } $this->dbPassword = CLIWCF::getReader()->readLine(WCF::getLanguage()->get('wcf.acp.dataImport.configure.database.password') . '> ', '*'); if ($this->dbPassword === null) { exit; } $this->dbName = CLIWCF::getReader()->readLine(WCF::getLanguage()->get('wcf.acp.dataImport.configure.database.name') . '> '); if ($this->dbName === null) { exit; } $this->dbPrefix = CLIWCF::getReader()->readLine(WCF::getLanguage()->get('wcf.acp.dataImport.configure.database.prefix') . '> '); if ($this->dbPrefix === null) { exit; } $this->exporter->setData($this->dbHost, $this->dbUser, $this->dbPassword, $this->dbName, $this->dbPrefix, '', array()); try { $this->exporter->validateDatabaseAccess(); } catch (DatabaseException $e) { $errorMessage = WCF::getLanguage()->getDynamicVariable('wcf.acp.dataImport.configure.database.error', array('exception' => $e)); $errorMessageLines = explode('<br />', $errorMessage); foreach ($errorMessageLines as &$line) { $line = StringUtil::stripHTML($line); } unset($line); foreach ($errorMessageLines as $line) { CLIWCF::getReader()->println($line); } continue; } break; } }