3 require_once(
"class.ilOrgUnitSimpleImport.php");
49 $this->parent_gui = $parent_gui;
50 $this->parent_object = $parent_gui->object;
51 $this->tabs_gui = $this->parent_gui->tabs_gui;
52 $this->toolbar = $ilToolbar;
55 $this->lng->loadLanguageModule(
'user');
57 if (! $this->ilAccess->checkaccess(
"write",
"", $this->parent_gui->object->getRefId())) {
67 $cmd = $this->ctrl->getCmd();
74 $this->tabs_gui->clearTargets();
75 $this->tabs_gui->setBackTarget($this->lng->txt(
"back"), $this->ctrl->getLinkTarget($this,
'chooseImport'));
79 $this->tabs_gui->clearTargets();
80 $this->tabs_gui->setBackTarget($this->lng->txt(
"back"), $this->ctrl->getLinkTarget($this,
'chooseImport'));
90 $this->ctrl->redirectByClass(
'ilinfoscreengui',
'');
93 $this->tabs_gui->setTabActive(
"import");
94 $this->tabs_gui->removeSubTab(
"page_editor");
95 $this->tabs_gui->removeSubTab(
"ordering");
98 $this->toolbar->addButton($this->lng->txt(
"simple_import"), $this->ctrl->getLinkTargetByClass(
"ilOrgUnitSimpleImportGUI",
"importScreen"));
99 $this->toolbar->addButton($this->lng->txt(
"simple_user_import"), $this->ctrl->getLinkTargetByClass(
"ilOrgUnitSimpleUserImportGUI",
"userImportScreen"));
104 $form = $this->
initForm(
"startImport");
105 $this->tpl->setContent($form->getHTML());
111 $input =
new ilFileInputGUI($this->lng->txt(
"import_xml_file"),
"import_file");
113 $input->setSuffixes(array(
'zip',
'xml'));
114 $form->addItem($input);
115 $form->setFormAction($this->ctrl->getFormAction($this));
116 $form->addCommandButton($submit_action, $this->lng->txt(
"import"));
123 $form = $this->
initForm(
"startImport");
124 if (! $form->checkInput()) {
125 $this->tpl->setContent($form->getHTML());
127 $file = $form->getInput(
"import_file");
130 $file_path =
$file[
"tmp_name"];
131 $file_type = pathinfo(
$file[
"name"], PATHINFO_EXTENSION);
132 $file_name = pathinfo(
$file[
"name"], PATHINFO_FILENAME);
134 if($file_type ==
"zip") {
135 $extract_path = $file_path.
'_extracted/';
136 $extracted_file = $extract_path.$file_name.
'/manifest.xml';
138 $zip =
new ZipArchive();
139 $res = $zip->open($file_path);
141 $zip->extractTo($extract_path);
144 if(file_exists($extracted_file)) {
145 $file_path = $extracted_file;
150 $importer->simpleImport($file_path);
152 $this->
ilLog->
write($e->getMessage() .
" - " . $e->getTraceAsString());
154 $this->ctrl->redirect($this,
"render");
164 if (! $importer->hasErrors() && ! $importer->hasWarnings()) {
165 $stats = $importer->getStats();
166 ilUtil::sendSuccess(sprintf($this->lng->txt(
"import_successful"), $stats[
"created"], $stats[
"updated"], $stats[
"deleted"]),
true);
168 if ($importer->hasWarnings()) {
169 $msg = $this->lng->txt(
"import_terminated_with_warnings") .
" <br/>";
170 foreach ($importer->getWarnings() as $warning) {
171 $msg .=
"-" . $this->lng->txt($warning[
"lang_var"]) .
" (Import ID: " . $warning[
"import_id"] .
")<br />";
175 if ($importer->hasErrors()) {
176 $msg = $this->lng->txt(
"import_terminated_with_errors") .
"<br/>";
177 foreach ($importer->getErrors() as $warning) {
178 $msg .=
"- " . $this->lng->txt($warning[
"lang_var"]) .
" (Import ID: " . $warning[
"import_id"] .
")<br />";
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
Class ilOrgUnitSimpleImportGUI.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
write($a_msg, $a_log_level=NULL)
logging
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
Class ilOrgUnitSimpleImport.
displayImportResults($importer)