ILIAS  release_8 Revision v8.23
ilOrgUnitSimpleUserImportGUI 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 ilOrgUnitSimpleUserImportGUI:

Public Member Functions

 __construct (object $parent_gui)
 
 executeCommand ()
 
 userImportScreen ()
 
 startImport ()
 
 displayImportResults (ilOrgUnitImporter $importer)
 

Protected Attributes

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

Private Member Functions

 initForm ()
 

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 ilOrgUnitSimpleUserImportGUI

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
Fabian Schmid fs@st.nosp@m.uder.nosp@m.-raim.nosp@m.ann..nosp@m.ch

Definition at line 26 of file class.ilOrgUnitSimpleUserImportGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilOrgUnitSimpleUserImportGUI::__construct ( object  $parent_gui)

Definition at line 39 of file class.ilOrgUnitSimpleUserImportGUI.php.

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

40  {
41  global $DIC;
42  $this->tpl = $DIC->ui()->mainTemplate();
43  $this->ctrl = $DIC->ctrl();
44  $this->parent_gui = $parent_gui;
45  $this->parent_object = $parent_gui->getObject();
46  $this->tabs_gui = $DIC->tabs();
47  $this->toolbar = $DIC->toolbar();
48  $this->lng = $DIC->language();
49  $this->ilLog = $DIC->logger();
50  $this->ilAccess = $DIC->access();
51  $this->lng->loadLanguageModule('user');
52  if (!$this->ilAccess->checkaccess('write', '', $this->parent_gui->getObject()->getRefId())) {
53  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('permission_denied'), true);
54  }
55  }
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
+ Here is the call graph for this function:

Member Function Documentation

◆ displayImportResults()

ilOrgUnitSimpleUserImportGUI::displayImportResults ( ilOrgUnitImporter  $importer)

Definition at line 116 of file class.ilOrgUnitSimpleUserImportGUI.php.

References ilOrgUnitImporter\getErrors(), ilOrgUnitImporter\getStats(), ilOrgUnitImporter\getWarnings(), ilOrgUnitImporter\hasErrors(), ilOrgUnitImporter\hasWarnings(), and ILIAS\Repository\lng().

Referenced by startImport().

116  : void
117  {
118  if (!$importer->hasErrors() and !$importer->hasWarnings()) {
119  $stats = $importer->getStats();
120  $this->tpl->setOnScreenMessage(
121  'success',
122  sprintf($this->lng->txt('user_import_successful'), $stats['created'], $stats['removed']),
123  true
124  );
125  }
126  if ($importer->hasWarnings()) {
127  $msg = $this->lng->txt('import_terminated_with_warnings') . '<br>';
128  foreach ($importer->getWarnings() as $warning) {
129  $msg .= '-' . $this->lng->txt($warning['lang_var']) . ' (Import ID: ' . $warning['import_id'] . ')<br>';
130  }
131  $this->tpl->setOnScreenMessage('info', $msg, true);
132  }
133  if ($importer->hasErrors()) {
134  $msg = $this->lng->txt('import_terminated_with_errors') . '<br>';
135  foreach ($importer->getErrors() as $warning) {
136  $msg .= '- ' . $this->lng->txt($warning['lang_var']) . ' (Import ID: ' . $warning['import_id'] . ')<br>';
137  }
138  $this->tpl->setOnScreenMessage('failure', $msg, true);
139  }
140  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeCommand()

ilOrgUnitSimpleUserImportGUI::executeCommand ( )

Definition at line 57 of file class.ilOrgUnitSimpleUserImportGUI.php.

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

57  : bool
58  {
59  $cmd = $this->ctrl->getCmd();
60 
61  $this->tabs_gui->clearTargets();
62  $this->tabs_gui->setBackTarget(
63  $this->lng->txt("back"),
64  $this->ctrl->getLinkTargetByClass('ilOrgUnitSimpleImportGUI', 'chooseImport')
65  );
66 
67  switch ($cmd) {
68  case 'userImportScreen':
69  $this->userImportScreen();
70  break;
71  case 'startImport':
72  $this->startImport();
73  break;
74  }
75 
76  return true;
77  }
+ Here is the call graph for this function:

◆ initForm()

ilOrgUnitSimpleUserImportGUI::initForm ( )
private

Definition at line 85 of file class.ilOrgUnitSimpleUserImportGUI.php.

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

Referenced by startImport(), and userImportScreen().

86  {
87  $form = new ilPropertyFormGUI();
88  $input = new ilFileInputGUI($this->lng->txt('import_xml_file'), 'import_file');
89  $input->setRequired(true);
90  $form->addItem($input);
91  $form->setFormAction($this->ctrl->getFormAction($this));
92  $form->addCommandButton('startImport', $this->lng->txt('import'));
93 
94  return $form;
95  }
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()

ilOrgUnitSimpleUserImportGUI::startImport ( )

Definition at line 97 of file class.ilOrgUnitSimpleUserImportGUI.php.

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

Referenced by executeCommand().

97  : void
98  {
99  $form = $this->initForm();
100  if (!$form->checkInput()) {
101  $this->tpl->setContent($form->getHTML());
102  } else {
103  $file = $form->getInput('import_file');
104  $importer = new ilOrgUnitSimpleUserImport();
105  try {
106  $importer->simpleUserImport($file['tmp_name']);
107  } catch (Exception $e) {
108  $this->ilLog->write($e->getMessage() . ' - ' . $e->getTraceAsString());
109  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('import_failed'), true);
110  $this->ctrl->redirect($this, 'render');
111  }
112  $this->displayImportResults($importer);
113  }
114  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: class.ilLog.php:30
displayImportResults(ilOrgUnitImporter $importer)
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:

◆ userImportScreen()

ilOrgUnitSimpleUserImportGUI::userImportScreen ( )

Definition at line 79 of file class.ilOrgUnitSimpleUserImportGUI.php.

References initForm().

Referenced by executeCommand().

79  : void
80  {
81  $form = $this->initForm();
82  $this->tpl->setContent($form->getHTML());
83  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $ctrl

ilCtrl ilOrgUnitSimpleUserImportGUI::$ctrl
protected

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

◆ $ilAccess

ilAccessHandler ilOrgUnitSimpleUserImportGUI::$ilAccess
protected

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

◆ $ilLog

ILIAS DI LoggingServices ilOrgUnitSimpleUserImportGUI::$ilLog
protected

Definition at line 36 of file class.ilOrgUnitSimpleUserImportGUI.php.

◆ $lng

ilLanguage ilOrgUnitSimpleUserImportGUI::$lng
protected

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

◆ $parent_gui

object ilOrgUnitSimpleUserImportGUI::$parent_gui
protected

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

Referenced by __construct().

◆ $parent_object

object ilOrgUnitSimpleUserImportGUI::$parent_object
protected

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

◆ $tabs_gui

ilTabsGUI ilOrgUnitSimpleUserImportGUI::$tabs_gui
protected

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

◆ $toolbar

ilToolbarGUI ilOrgUnitSimpleUserImportGUI::$toolbar
protected

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

◆ $tpl

ilGlobalTemplateInterface ilOrgUnitSimpleUserImportGUI::$tpl
protected

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


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