/** * @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, 'dbHost' => $this->dbHost, 'dbUser' => $this->dbUser, 'dbPassword' => $this->dbPassword, 'dbName' => $this->dbName, 'dbPrefix' => $this->dbPrefix, 'fileSystemPath' => $this->fileSystemPath, 'userMergeMode' => $this->userMergeMode, 'additionalData' => $this->additionalData)); WCF::getTPL()->assign('queue', $queue); }
/** * @see \wcf\system\worker\IWorker::execute() */ public function execute() { if (!$this->count) { return; } // disable mysql strict mode $sql = "SET SESSION sql_mode = 'ANSI,ONLY_FULL_GROUP_BY'"; $statement = WCF::getDB()->prepareStatement($sql); $statement->execute(); $this->exporter->exportData($this->parameters['objectType'], $this->loopCount); }
/** * Reads the selected data which will be imported. */ protected function readSelectedData() { $printPrimaryTypes = true; $selectedData = array(); $supportedDataSelection = array('' => array()); $i = 1; $availablePrimaryDataTypes = array(); foreach ($this->supportedData as $objectType => $subData) { $availablePrimaryDataTypes[$i++] = $objectType; } while (true) { if ($printPrimaryTypes) { // print primary import data types CLIWCF::getReader()->println(WCF::getLanguage()->get('wcf.acp.dataImport.configure.data.description')); $supportedDataIndex = 1; $minSupportedDataIndex = 1; foreach ($this->supportedData as $objectType => $subData) { if (!isset($selectedData[$objectType])) { CLIWCF::getReader()->println($supportedDataIndex . ') ' . WCF::getLanguage()->get('wcf.acp.dataImport.data.' . $objectType)); $supportedDataSelection[''][$supportedDataIndex++] = $objectType; } else { if ($minSupportedDataIndex == $supportedDataIndex) { $minSupportedDataIndex++; } $supportedDataIndex++; } } CLIWCF::getReader()->println(WCF::getLanguage()->getDynamicVariable('wcf.acp.dataImport.cli.selection', array('minSelection' => $minSupportedDataIndex, 'maxSelection' => $supportedDataIndex - 1))); $printPrimaryTypes = false; } // read index of selected primary import data type $selectedObjectTypeIndex = CLIWCF::getReader()->readLine(WCF::getLanguage()->get('wcf.acp.dataImport.configure.data') . '> '); if ($selectedObjectTypeIndex === null) { exit; } // if no primary import data type is selected, finish data selection if ($selectedObjectTypeIndex == '') { // if no data is selected, quit import if (empty($selectedData)) { CLIWCF::getReader()->println(WCF::getLanguage()->get('wcf.acp.dataImport.cli.configure.data.error.noSelection')); $this->quitImport = true; return; } break; } // validate selected primary import data type if (isset($supportedDataSelection[''][$selectedObjectTypeIndex])) { $selectedObjectType = $supportedDataSelection[''][$selectedObjectTypeIndex]; $selectedData[$selectedObjectType] = array(); unset($supportedDataSelection[''][$selectedObjectTypeIndex]); } else { if (isset($availablePrimaryDataTypes[$selectedObjectTypeIndex])) { CLIWCF::getReader()->println(WCF::getLanguage()->get('wcf.acp.dataImport.cli.configure.data.alreadySelected')); continue; } else { CLIWCF::getReader()->println(WCF::getLanguage()->get('wcf.acp.dataImport.cli.configure.data.error.notValid')); continue; } } // handle secondary import data types if (!empty($this->supportedData[$selectedObjectType])) { // print secondary import data types CLIWCF::getReader()->println(' ' . WCF::getLanguage()->get('wcf.acp.dataImport.configure.data.description')); CLIWCF::getReader()->println(' 0) ' . WCF::getLanguage()->get('wcf.acp.dataImport.cli.configure.data.selectAll')); $supportedDataSelection[$selectedObjectType] = array(); $supportedDataIndex = 1; foreach ($this->supportedData[$selectedObjectType] as $objectType) { CLIWCF::getReader()->println(' ' . $supportedDataIndex . ') ' . WCF::getLanguage()->get('wcf.acp.dataImport.data.' . $objectType)); $supportedDataSelection[$selectedObjectType][$supportedDataIndex++] = $objectType; } CLIWCF::getReader()->println(' ' . WCF::getLanguage()->getDynamicVariable('wcf.acp.dataImport.cli.selection', array('minSelection' => 0, 'maxSelection' => $supportedDataIndex - 1))); while (true) { // read index of selected secondary import data type $selectedSecondaryObjectTypeIndex = CLIWCF::getReader()->readLine(' ' . WCF::getLanguage()->get('wcf.acp.dataImport.configure.data') . '> '); if ($selectedSecondaryObjectTypeIndex === null) { exit; } // continue with primary import data type selection if ($selectedSecondaryObjectTypeIndex == '') { break; } // validate selected secondary import data type if ($selectedSecondaryObjectTypeIndex == intval($selectedSecondaryObjectTypeIndex) && !$selectedSecondaryObjectTypeIndex) { // selected all secondary import data type $selectedData[$selectedObjectType] = array_merge($selectedData[$selectedObjectType], $supportedDataSelection[$selectedObjectType]); break; } else { if (isset($supportedDataSelection[$selectedObjectType][$selectedSecondaryObjectTypeIndex])) { $selectedSecondaryObjectType = $supportedDataSelection[$selectedObjectType][$selectedSecondaryObjectTypeIndex]; $selectedData[$selectedObjectType][$selectedSecondaryObjectTypeIndex] = $selectedSecondaryObjectType; unset($supportedDataSelection[$selectedObjectType][$selectedSecondaryObjectTypeIndex]); } else { if (isset($selectedData[$selectedObjectType][$selectedSecondaryObjectTypeIndex])) { CLIWCF::getReader()->println(' ' . WCF::getLanguage()->get('wcf.acp.dataImport.cli.configure.data.alreadySelected')); continue; } else { CLIWCF::getReader()->println(' ' . WCF::getLanguage()->get('wcf.acp.dataImport.cli.configure.data.error.notValid')); continue; } } } // check if all possible secondary import data types are selected if (count($selectedData[$selectedObjectType]) == count($this->supportedData[$selectedObjectType])) { $printPrimaryTypes = true; break; } } if (!empty($supportedDataSelection[$selectedObjectType])) { $printPrimaryTypes = true; } } // check if all possible primary import data types are selected if (count($selectedData) == count($this->supportedData)) { break; } } foreach ($selectedData as $objectType => $objectTypes) { $this->selectedData[] = $objectType; $this->selectedData = array_merge($this->selectedData, $objectTypes); } if (!$this->exporter->validateSelectedData($this->selectedData)) { CLIWCF::getReader()->println(WCF::getLanguage()->get('wcf.acp.dataImport.cli.configure.data.error.noSelection')); $this->quitImport = true; } }