ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilOrgUnitSimpleImportGUI Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Collaboration diagram for ilOrgUnitSimpleImportGUI:

Public Member Functions

 __construct (ilObjectGUI $parent_gui)
 
 executeCommand ()
 
 chooseImport ()
 
 importScreen ()
 
 startImport ()
 
 displayImportResults ($importer)
 

Protected Member Functions

 initForm ($submit_action)
 

Protected Attributes

ilTabsGUI $tabs_gui
 
ilToolbarGUI $toolbar
 
ilCtrl $ctrl
 
ilGlobalTemplateInterface $tpl
 
ilObjectGUI $parent_gui
 
object $parent_object
 
ilLanguage $lng
 
ilAccessHandler $ilAccess
 
ILIAS DI LoggingServices $ilLog
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Class ilOrgUnitSimpleImportGUI

Author
Oskar Truffer ot@st.nosp@m.uder.nosp@m.-raim.nosp@m.ann..nosp@m.ch
Martin Studer ms@st.nosp@m.uder.nosp@m.-raim.nosp@m.ann..nosp@m.ch

Definition at line 25 of file class.ilOrgUnitSimpleImportGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilOrgUnitSimpleImportGUI::__construct ( ilObjectGUI  $parent_gui)

Definition at line 37 of file class.ilOrgUnitSimpleImportGUI.php.

References $DIC, $parent_gui, ILIAS\Repository\ctrl(), ilObjectGUI\getObject(), ilObjOrgUnit\getRootOrgRefId(), ILIAS\Repository\lng(), and ILIAS\Repository\toolbar().

38  {
39  global $DIC;
40  $this->tpl = $DIC->ui()->mainTemplate();
41  $this->ctrl = $DIC->ctrl();
42  $this->parent_gui = $parent_gui;
43  $this->parent_object = $parent_gui->getObject();
44  $this->tabs_gui = $DIC->tabs();
45  $this->toolbar = $DIC->toolbar();
46  $this->lng = $DIC->language();
47  $this->ilAccess = $DIC->access();
48  $this->lng->loadLanguageModule('user');
49  $this->ilLog = $DIC->logger();
50 
51  $this->may_create_orgus = $this->ilAccess->checkAccess("create_orgu", "", $this->parent_gui->getRefId(), 'orgu');
52  $this->is_top_level_orgu = ($this->parent_object->getRefId() == ilObjOrgUnit::getRootOrgRefId());
53 
54  if (!$this->may_create_orgus) {
55  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("permission_denied"), true);
56  }
57  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: class.ilLog.php:30
global $DIC
Definition: feed.php:28
static getRootOrgRefId()
+ Here is the call graph for this function:

Member Function Documentation

◆ chooseImport()

ilOrgUnitSimpleImportGUI::chooseImport ( )

Definition at line 91 of file class.ilOrgUnitSimpleImportGUI.php.

References ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), and ILIAS\Repository\toolbar().

Referenced by executeCommand().

92  {
93  if (!$this->may_create_orgus || !$this->is_top_level_orgu) {
94  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("msg_no_perm_edit"));
95  $this->ctrl->redirectByClass('ilinfoscreengui', '');
96  }
97 
98  $this->tabs_gui->setTabActive('view_content');
99  $this->tabs_gui->removeSubTab("page_editor");
100  $this->tabs_gui->removeSubTab("ordering"); // Mantis 0014728
101 
102  if ($this->may_create_orgus && $this->is_top_level_orgu) {
103  $this->toolbar->addButton(
104  $this->lng->txt("simple_import"),
105  $this->ctrl->getLinkTargetByClass("ilOrgUnitSimpleImportGUI", "importScreen")
106  );
107  $this->toolbar->addButton(
108  $this->lng->txt("simple_user_import"),
109  $this->ctrl->getLinkTargetByClass("ilOrgUnitSimpleUserImportGUI", "userImportScreen")
110  );
111  }
112  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ displayImportResults()

ilOrgUnitSimpleImportGUI::displayImportResults (   $importer)
Parameters
$importerilOrgUnitImporter

Definition at line 175 of file class.ilOrgUnitSimpleImportGUI.php.

References ILIAS\Repository\lng().

Referenced by startImport().

176  {
177  if (!$importer->hasErrors() && !$importer->hasWarnings()) {
178  $stats = $importer->getStats();
179  $this->tpl->setOnScreenMessage(
180  'success',
181  sprintf($this->lng->txt("import_successful"), $stats["created"], $stats["updated"], $stats["deleted"]),
182  true
183  );
184  }
185  if ($importer->hasWarnings()) {
186  $msg = $this->lng->txt("import_terminated_with_warnings") . " <br/>";
187  foreach ($importer->getWarnings() as $warning) {
188  $msg .= "-" . $this->lng->txt($warning["lang_var"]) . " (Import ID: " . $warning["import_id"] . ")<br />";
189  }
190  $this->tpl->setOnScreenMessage('info', $msg, true);
191  }
192  if ($importer->hasErrors()) {
193  $msg = $this->lng->txt("import_terminated_with_errors") . "<br/>";
194  foreach ($importer->getErrors() as $warning) {
195  $msg .= "- " . $this->lng->txt($warning["lang_var"]) . " (Import ID: " . $warning["import_id"] . ")<br />";
196  }
197  $this->tpl->setOnScreenMessage('failure', $msg, true);
198  }
199  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeCommand()

ilOrgUnitSimpleImportGUI::executeCommand ( )
Returns
bool

Definition at line 62 of file class.ilOrgUnitSimpleImportGUI.php.

References chooseImport(), ILIAS\Repository\ctrl(), importScreen(), ILIAS\Repository\lng(), and startImport().

63  {
64  $cmd = $this->ctrl->getCmd();
65 
66  switch ($cmd) {
67  case 'chooseImport':
68  $this->chooseImport();
69  break;
70  case 'importScreen':
71  $this->tabs_gui->clearTargets();
72  $this->tabs_gui->setBackTarget(
73  $this->lng->txt("back"),
74  $this->ctrl->getLinkTarget($this, 'chooseImport')
75  );
76  $this->importScreen();
77  break;
78  case 'startImport':
79  $this->tabs_gui->clearTargets();
80  $this->tabs_gui->setBackTarget(
81  $this->lng->txt("back"),
82  $this->ctrl->getLinkTarget($this, 'chooseImport')
83  );
84  $this->startImport();
85  break;
86  }
87 
88  return true;
89  }
+ Here is the call graph for this function:

◆ importScreen()

ilOrgUnitSimpleImportGUI::importScreen ( )

Definition at line 114 of file class.ilOrgUnitSimpleImportGUI.php.

References initForm().

Referenced by executeCommand().

115  {
116  $form = $this->initForm("startImport");
117  $this->tpl->setContent($form->getHTML());
118  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initForm()

ilOrgUnitSimpleImportGUI::initForm (   $submit_action)
protected

Definition at line 120 of file class.ilOrgUnitSimpleImportGUI.php.

References ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), and ilFormPropertyGUI\setRequired().

Referenced by importScreen(), and startImport().

121  {
122  $form = new ilPropertyFormGUI();
123  $input = new ilFileInputGUI($this->lng->txt("import_xml_file"), "import_file");
124  $input->setRequired(true);
125  $input->setSuffixes(array('zip', 'xml'));
126  $form->addItem($input);
127  $form->setFormAction($this->ctrl->getFormAction($this));
128  $form->addCommandButton($submit_action, $this->lng->txt("import"));
129 
130  return $form;
131  }
This class represents a file property in a property form.
setRequired(bool $a_required)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ startImport()

ilOrgUnitSimpleImportGUI::startImport ( )

Definition at line 133 of file class.ilOrgUnitSimpleImportGUI.php.

References Vendor\Package\$e, $res, ILIAS\Repository\ctrl(), displayImportResults(), initForm(), ILIAS\Repository\lng(), and ilLog\write().

Referenced by executeCommand().

134  {
135  $form = $this->initForm("startImport");
136  if (!$form->checkInput()) {
137  $this->tpl->setContent($form->getHTML());
138  } else {
139  $file = $form->getInput("import_file");
140  $importer = new ilOrgUnitSimpleImport();
141  try {
142  $file_path = $file["tmp_name"];
143  $file_type = pathinfo($file["name"], PATHINFO_EXTENSION);
144  $file_name = pathinfo($file["name"], PATHINFO_FILENAME);
145 
146  if ($file_type == "zip") {
147  $extract_path = $file_path . '_extracted/';
148  $extracted_file = $extract_path . $file_name . '/manifest.xml';
149 
150  $zip = new ZipArchive();
151  $res = $zip->open($file_path);
152  if ($res === true) {
153  $zip->extractTo($extract_path);
154  $zip->close();
155 
156  if (file_exists($extracted_file)) {
157  $file_path = $extracted_file;
158  }
159  }
160  }
161 
162  $importer->simpleImport($file_path);
163  } catch (Exception $e) {
164  $this->ilLog->write($e->getMessage() . " - " . $e->getTraceAsString());
165  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("import_failed"), true);
166  $this->ctrl->redirect($this, "render");
167  }
168  $this->displayImportResults($importer);
169  }
170  }
$res
Definition: ltiservices.php:69
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: class.ilLog.php:30
write(string $a_msg, $a_log_level=null)
logging
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $ctrl

ilCtrl ilOrgUnitSimpleImportGUI::$ctrl
protected

Definition at line 29 of file class.ilOrgUnitSimpleImportGUI.php.

◆ $ilAccess

ilAccessHandler ilOrgUnitSimpleImportGUI::$ilAccess
protected

Definition at line 34 of file class.ilOrgUnitSimpleImportGUI.php.

◆ $ilLog

ILIAS DI LoggingServices ilOrgUnitSimpleImportGUI::$ilLog
protected

Definition at line 35 of file class.ilOrgUnitSimpleImportGUI.php.

◆ $lng

ilLanguage ilOrgUnitSimpleImportGUI::$lng
protected

Definition at line 33 of file class.ilOrgUnitSimpleImportGUI.php.

◆ $parent_gui

ilObjectGUI ilOrgUnitSimpleImportGUI::$parent_gui
protected

Definition at line 31 of file class.ilOrgUnitSimpleImportGUI.php.

Referenced by __construct().

◆ $parent_object

object ilOrgUnitSimpleImportGUI::$parent_object
protected

Definition at line 32 of file class.ilOrgUnitSimpleImportGUI.php.

◆ $tabs_gui

ilTabsGUI ilOrgUnitSimpleImportGUI::$tabs_gui
protected

Definition at line 27 of file class.ilOrgUnitSimpleImportGUI.php.

◆ $toolbar

ilToolbarGUI ilOrgUnitSimpleImportGUI::$toolbar
protected

Definition at line 28 of file class.ilOrgUnitSimpleImportGUI.php.

◆ $tpl

ilGlobalTemplateInterface ilOrgUnitSimpleImportGUI::$tpl
protected

Definition at line 30 of file class.ilOrgUnitSimpleImportGUI.php.


The documentation for this class was generated from the following file: