ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
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 27 of file class.ilOrgUnitSimpleUserImportGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilOrgUnitSimpleUserImportGUI::__construct ( object  $parent_gui)

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

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

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

Member Function Documentation

◆ displayImportResults()

ilOrgUnitSimpleUserImportGUI::displayImportResults ( ilOrgUnitImporter  $importer)

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

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

Referenced by startImport().

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

◆ executeCommand()

ilOrgUnitSimpleUserImportGUI::executeCommand ( )

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

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

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

◆ initForm()

ilOrgUnitSimpleUserImportGUI::initForm ( )
private

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

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

Referenced by startImport(), and userImportScreen().

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

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

Referenced by executeCommand().

98  : void
99  {
100  $form = $this->initForm();
101  if (!$form->checkInput()) {
102  $this->tpl->setContent($form->getHTML());
103  } else {
104  $file = $form->getInput('import_file');
105  $importer = new ilOrgUnitSimpleUserImport();
106  try {
107  $importer->simpleUserImport($file['tmp_name']);
108  } catch (Exception $e) {
109  $this->ilLog->write($e->getMessage() . ' - ' . $e->getTraceAsString());
110  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('import_failed'), true);
111  $this->ctrl->redirect($this, 'render');
112  }
113  $this->displayImportResults($importer);
114  }
115  }
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 80 of file class.ilOrgUnitSimpleUserImportGUI.php.

References initForm().

Referenced by executeCommand().

80  : void
81  {
82  $form = $this->initForm();
83  $this->tpl->setContent($form->getHTML());
84  }
+ 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 31 of file class.ilOrgUnitSimpleUserImportGUI.php.

◆ $ilAccess

ilAccessHandler ilOrgUnitSimpleUserImportGUI::$ilAccess
protected

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

◆ $ilLog

ILIAS DI LoggingServices ilOrgUnitSimpleUserImportGUI::$ilLog
protected

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

◆ $lng

ilLanguage ilOrgUnitSimpleUserImportGUI::$lng
protected

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

◆ $parent_gui

object ilOrgUnitSimpleUserImportGUI::$parent_gui
protected

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

Referenced by __construct().

◆ $parent_object

object ilOrgUnitSimpleUserImportGUI::$parent_object
protected

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

◆ $tabs_gui

ilTabsGUI ilOrgUnitSimpleUserImportGUI::$tabs_gui
protected

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

◆ $toolbar

ilToolbarGUI ilOrgUnitSimpleUserImportGUI::$toolbar
protected

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

◆ $tpl

ilGlobalTemplateInterface ilOrgUnitSimpleUserImportGUI::$tpl
protected

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


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