public function startImport() { $form = $this->initForm("startImport"); if (!$form->checkInput()) { $this->tpl->setContent($form->getHTML()); } else { $file = $form->getInput("import_file"); $importer = new ilOrgUnitSimpleImport(); try { $importer->simpleImport($file["tmp_name"]); } catch (Exception $e) { $this->ilLog->write($e->getMessage() . " - " . $e->getTraceAsString()); ilUtil::sendFailure($this->lng->txt("import_failed"), true); $this->ctrl->redirect($this, "render"); } $this->displayImportResults($importer); } }
public function startImport() { $form = $this->initForm("startImport"); if (!$form->checkInput()) { $this->tpl->setContent($form->getHTML()); } else { $file = $form->getInput("import_file"); $importer = new ilOrgUnitSimpleImport(); try { $file_path = $file["tmp_name"]; $file_type = pathinfo($file["name"], PATHINFO_EXTENSION); $file_name = pathinfo($file["name"], PATHINFO_FILENAME); if ($file_type == "zip") { $extract_path = $file_path . '_extracted/'; $extracted_file = $extract_path . $file_name . '/manifest.xml'; $zip = new ZipArchive(); $res = $zip->open($file_path); if ($res === true) { $zip->extractTo($extract_path); $zip->close(); if (file_exists($extracted_file)) { $file_path = $extracted_file; } } } $importer->simpleImport($file_path); } catch (Exception $e) { $this->ilLog->write($e->getMessage() . " - " . $e->getTraceAsString()); ilUtil::sendFailure($this->lng->txt("import_failed"), true); $this->ctrl->redirect($this, "render"); } $this->displayImportResults($importer); } }