19 declare(strict_types=1);
    36     protected \ILIAS\DI\LoggingServices 
$ilLog;
    45         $this->tpl = $DIC->ui()->mainTemplate();
    46         $this->
ctrl = $DIC->ctrl();
    48         $this->parent_object = $parent_gui->
getObject();
    49         $this->tabs_gui = $DIC->tabs();
    50         $this->
toolbar = $DIC->toolbar();
    51         $this->
lng = $DIC->language();
    53         $this->
lng->loadLanguageModule(
'user');
    54         $this->
ilLog = $DIC->logger();
    55         $this->ui_factory = $DIC[
'ui.factory'];
    57         $this->may_create_orgus = $this->
ilAccess->checkAccess(
"create_orgu", 
"", $this->parent_gui->getRefId(), 
'orgu');
    60         if (!$this->may_create_orgus) {
    61             $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"permission_denied"), 
true);
    70         $cmd = $this->
ctrl->getCmd();
    77                 $this->tabs_gui->clearTargets();
    78                 $this->tabs_gui->setBackTarget(
    79                     $this->
lng->txt(
"back"),
    80                     $this->
ctrl->getLinkTarget($this, 
'chooseImport')
    85                 $this->tabs_gui->clearTargets();
    86                 $this->tabs_gui->setBackTarget(
    87                     $this->
lng->txt(
"back"),
    88                     $this->
ctrl->getLinkTarget($this, 
'chooseImport')
    99         if (!$this->may_create_orgus || !$this->is_top_level_orgu) {
   100             $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"msg_no_perm_edit"));
   101             $this->
ctrl->redirectByClass(
'ilinfoscreengui', 
'');
   104         $this->tabs_gui->setTabActive(
'view_content');
   105         $this->tabs_gui->removeSubTab(
"page_editor");
   106         $this->tabs_gui->removeSubTab(
"ordering"); 
   108         if ($this->may_create_orgus && $this->is_top_level_orgu) {
   110                 $this->ui_factory->link()->standard(
   111                     $this->
lng->txt(
'simple_import'),
   112                     $this->
ctrl->getLinkTargetByClass(
"ilOrgUnitSimpleImportGUI", 
"importScreen")
   116                 $this->ui_factory->link()->standard(
   117                     $this->
lng->txt(
'simple_user_import'),
   118                     $this->
ctrl->getLinkTargetByClass(
"ilOrgUnitSimpleUserImportGUI", 
"userImportScreen")
   126         $form = $this->
initForm(
"startImport");
   127         $this->tpl->setContent($form->getHTML());
   135         $input->setSuffixes(array(
'zip', 
'xml'));
   136         $form->addItem($input);
   137         $form->setFormAction($this->
ctrl->getFormAction($this));
   138         $form->addCommandButton($submit_action, $this->
lng->txt(
"import"));
   145         $form = $this->
initForm(
"startImport");
   146         if (!$form->checkInput()) {
   147             $this->tpl->setContent($form->getHTML());
   149             $file = $form->getInput(
"import_file");
   152                 $file_path = $file[
"tmp_name"];
   153                 $file_type = pathinfo($file[
"name"], PATHINFO_EXTENSION);
   154                 $file_name = pathinfo($file[
"name"], PATHINFO_FILENAME);
   156                 if ($file_type == 
"zip") {
   157                     $extract_path = $file_path . 
'_extracted/';
   158                     $extracted_file = $extract_path . $file_name . 
'/manifest.xml';
   161                     $res = $zip->open($file_path);
   163                         $zip->extractTo($extract_path);
   166                         if (file_exists($extracted_file)) {
   167                             $file_path = $extracted_file;
   172                 $importer->simpleImport($file_path);
   174                 $this->
ilLog->
write($e->getMessage() . 
" - " . $e->getTraceAsString());
   175                 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"import_failed"), 
true);
   176                 $this->
ctrl->redirect($this, 
"render");
   187         if (!$importer->hasErrors() && !$importer->hasWarnings()) {
   188             $stats = $importer->getStats();
   189             $this->tpl->setOnScreenMessage(
   191                 sprintf($this->
lng->txt(
"import_successful"), $stats[
"created"], $stats[
"updated"], $stats[
"deleted"]),
   195         if ($importer->hasWarnings()) {
   196             $msg = $this->
lng->txt(
"import_terminated_with_warnings") . 
" <br/>";
   197             foreach ($importer->getWarnings() as $warning) {
   198                 $msg .= 
"-" . $this->
lng->txt($warning[
"lang_var"]) . 
" (Import ID: " . $warning[
"import_id"] . 
")<br />";
   200             $this->tpl->setOnScreenMessage(
'info', $msg, 
true);
   202         if ($importer->hasErrors()) {
   203             $msg = $this->
lng->txt(
"import_terminated_with_errors") . 
"<br/>";
   204             foreach ($importer->getErrors() as $warning) {
   205                 $msg .= 
"- " . $this->
lng->txt($warning[
"lang_var"]) . 
" (Import ID: " . $warning[
"import_id"] . 
")<br />";
   207             $this->tpl->setOnScreenMessage(
'failure', $msg, 
true);
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
ilAccessHandler $ilAccess
 
ilGlobalTemplateInterface $tpl
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
Class ilOrgUnitSimpleImportGUI. 
 
__construct(ilObjectGUI $parent_gui)
 
ILIAS DI LoggingServices $ilLog
 
Class ilObjectGUI Basic methods of all Output classes. 
 
ILIAS UI Factory $ui_factory
 
write(string $a_msg, $a_log_level=null)
logging 
 
displayImportResults($importer)