3 require_once(
"class.ilOrgUnitSimpleImport.php");
49 $ilTabs = $DIC[
'ilTabs'];
50 $ilToolbar = $DIC[
'ilToolbar'];
56 $this->parent_gui = $parent_gui;
57 $this->parent_object = $parent_gui->object;
58 $this->tabs_gui = $this->parent_gui->tabs_gui;
59 $this->toolbar = $ilToolbar;
62 $this->lng->loadLanguageModule(
'user');
64 if (! $this->ilAccess->checkaccess(
"write",
"", $this->parent_gui->object->getRefId())) {
74 $cmd = $this->ctrl->getCmd();
81 $this->tabs_gui->clearTargets();
82 $this->tabs_gui->setBackTarget($this->lng->txt(
"back"), $this->ctrl->getLinkTarget($this,
'chooseImport'));
86 $this->tabs_gui->clearTargets();
87 $this->tabs_gui->setBackTarget($this->lng->txt(
"back"), $this->ctrl->getLinkTarget($this,
'chooseImport'));
97 $this->ctrl->redirectByClass(
'ilinfoscreengui',
'');
100 $this->tabs_gui->setTabActive(
'view_content');
101 $this->tabs_gui->removeSubTab(
"page_editor");
102 $this->tabs_gui->removeSubTab(
"ordering");
105 $this->toolbar->addButton($this->lng->txt(
"simple_import"), $this->ctrl->getLinkTargetByClass(
"ilOrgUnitSimpleImportGUI",
"importScreen"));
106 $this->toolbar->addButton($this->lng->txt(
"simple_user_import"), $this->ctrl->getLinkTargetByClass(
"ilOrgUnitSimpleUserImportGUI",
"userImportScreen"));
111 $form = $this->
initForm(
"startImport");
112 $this->tpl->setContent($form->getHTML());
118 $input =
new ilFileInputGUI($this->lng->txt(
"import_xml_file"),
"import_file");
120 $input->setSuffixes(
array(
'zip',
'xml'));
121 $form->addItem($input);
122 $form->setFormAction($this->ctrl->getFormAction($this));
123 $form->addCommandButton($submit_action, $this->lng->txt(
"import"));
130 $form = $this->
initForm(
"startImport");
131 if (! $form->checkInput()) {
132 $this->tpl->setContent($form->getHTML());
134 $file = $form->getInput(
"import_file");
137 $file_path =
$file[
"tmp_name"];
138 $file_type = pathinfo(
$file[
"name"], PATHINFO_EXTENSION);
139 $file_name = pathinfo(
$file[
"name"], PATHINFO_FILENAME);
141 if($file_type ==
"zip") {
142 $extract_path = $file_path.
'_extracted/';
143 $extracted_file = $extract_path.$file_name.
'/manifest.xml';
145 $zip =
new ZipArchive();
146 $res = $zip->open($file_path);
148 $zip->extractTo($extract_path);
151 if(file_exists($extracted_file)) {
152 $file_path = $extracted_file;
157 $importer->simpleImport($file_path);
159 $this->
ilLog->
write($e->getMessage() .
" - " . $e->getTraceAsString());
161 $this->ctrl->redirect($this,
"render");
171 if (! $importer->hasErrors() && ! $importer->hasWarnings()) {
172 $stats = $importer->getStats();
173 ilUtil::sendSuccess(sprintf($this->lng->txt(
"import_successful"), $stats[
"created"], $stats[
"updated"], $stats[
"deleted"]),
true);
175 if ($importer->hasWarnings()) {
176 $msg = $this->lng->txt(
"import_terminated_with_warnings") .
" <br/>";
177 foreach ($importer->getWarnings() as $warning) {
178 $msg .=
"-" . $this->lng->txt($warning[
"lang_var"]) .
" (Import ID: " . $warning[
"import_id"] .
")<br />";
182 if ($importer->hasErrors()) {
183 $msg = $this->lng->txt(
"import_terminated_with_errors") .
"<br/>";
184 foreach ($importer->getErrors() as $warning) {
185 $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
Create styles array
The data for the language used.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
Class ilOrgUnitSimpleImport.
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
displayImportResults($importer)