ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilOrgUnitSimpleUserImportGUI Class Reference

Class ilOrgUnitSimpleUserImportGUI. More...

+ Collaboration diagram for ilOrgUnitSimpleUserImportGUI:

Public Member Functions

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

Protected Member Functions

 testImport ()
 FSX Can be deleted; Just for a single Test of a UserImport More...
 
 initForm ()
 

Protected Attributes

 $tabs_gui
 
 $toolbar
 
 $ctrl
 
 $tpl
 
 $parent_object
 
 $lng
 
 $ilAccess
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilOrgUnitSimpleUserImportGUI::__construct (   $parent_gui)
Parameters
$parent_gui

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

References $ilAccess, $ilCtrl, $lng, $log, $tpl, and ilUtil\sendFailure().

47  {
48  global $tpl, $ilCtrl, $ilToolbar, $lng, $ilAccess, $log;
49  $this->tpl = $tpl;
50  $this->ctrl = $ilCtrl;
51  $this->parent_gui = $parent_gui;
52  $this->parent_object = $parent_gui->object;
53  $this->tabs_gui = $this->parent_gui->tabs_gui;
54  $this->toolbar = $ilToolbar;
55  $this->lng = $lng;
56  $this->ilLog = $log;
57  $this->ilAccess = $ilAccess;
58  $this->lng->loadLanguageModule('user');
59  if (!$this->ilAccess->checkaccess('write', '', $this->parent_gui->object->getRefId())) {
60  ilUtil::sendFailure($this->lng->txt('permission_denied'), true);
61  }
62  }
logging
Definition: class.ilLog.php:18
global $ilCtrl
Definition: ilias.php:18
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
+ Here is the call graph for this function:

Member Function Documentation

◆ displayImportResults()

ilOrgUnitSimpleUserImportGUI::displayImportResults (   $importer)
Parameters
$importerilOrgUnitImporter

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

References ilUtil\sendFailure(), ilUtil\sendInfo(), and ilUtil\sendSuccess().

Referenced by startImport().

145  {
146  if (!$importer->hasErrors() AND !$importer->hasWarnings()) {
147  $stats = $importer->getStats();
148  ilUtil::sendSuccess(sprintf($this->lng->txt('user_import_successful'), $stats['created'], $stats['removed']), true);
149  }
150  if ($importer->hasWarnings()) {
151  $msg = $this->lng->txt('import_terminated_with_warnings') . '<br>';
152  foreach ($importer->getWarnings() as $warning) {
153  $msg .= '-' . $this->lng->txt($warning['lang_var']) . ' (Import ID: ' . $warning['import_id'] . ')<br>';
154  }
155  ilUtil::sendInfo($msg, true);
156  }
157  if ($importer->hasErrors()) {
158  $msg = $this->lng->txt('import_terminated_with_errors') . '<br>';
159  foreach ($importer->getErrors() as $warning) {
160  $msg .= '- ' . $this->lng->txt($warning['lang_var']) . ' (Import ID: ' . $warning['import_id'] . ')<br>';
161  }
162  ilUtil::sendFailure($msg, true);
163  }
164  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeCommand()

ilOrgUnitSimpleUserImportGUI::executeCommand ( )
Returns
bool

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

References $cmd, startImport(), and userImportScreen().

68  {
69  $cmd = $this->ctrl->getCmd();
70 
71  $this->tabs_gui->clearTargets();
72  $this->tabs_gui->setBackTarget($this->lng->txt("back"), $this->ctrl->getLinkTargetByClass('ilOrgUnitSimpleImportGUI','chooseImport'));
73 
74  switch ($cmd) {
75  case 'userImportScreen':
76  $this->userImportScreen();
77  break;
78  case 'startImport':
79  $this->startImport();
80  break;
81  }
82 
83  return true;
84  }
$cmd
Definition: sahs_server.php:35
+ Here is the call graph for this function:

◆ initForm()

ilOrgUnitSimpleUserImportGUI::initForm ( )
protected

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

References ilFormPropertyGUI\setRequired().

Referenced by startImport(), and userImportScreen().

111  {
112  $form = new ilPropertyFormGUI();
113  $input = new ilFileInputGUI($this->lng->txt('import_xml_file'), 'import_file');
114  $input->setRequired(true);
115  $form->addItem($input);
116  $form->setFormAction($this->ctrl->getFormAction($this));
117  $form->addCommandButton('startImport', $this->lng->txt('import'));
118 
119  return $form;
120  }
This class represents a property form user interface.
This class represents a file property in a property form.
setRequired($a_required)
Set Required.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ startImport()

ilOrgUnitSimpleUserImportGUI::startImport ( )

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

References $file, displayImportResults(), initForm(), ilUtil\sendFailure(), and ilLog\write().

Referenced by executeCommand().

123  {
124  $form = $this->initForm();
125  if (!$form->checkInput()) {
126  $this->tpl->setContent($form->getHTML());
127  } else {
128  $file = $form->getInput('import_file');
129  $importer = new ilOrgUnitSimpleUserImport();
130  try {
131  $importer->simpleUserImport($file['tmp_name']);
132  } catch (Exception $e) {
133  $this->ilLog->write($e->getMessage() . ' - ' . $e->getTraceAsString());
134  ilUtil::sendFailure($this->lng->txt('import_failed'), true);
135  $this->ctrl->redirect($this, 'render');
136  }
137  $this->displayImportResults($importer);
138  }
139  }
print $file
Class ilOrgUnitSimpleUserImport.
logging
Definition: class.ilLog.php:18
write($a_msg, $a_log_level=NULL)
logging
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ testImport()

ilOrgUnitSimpleUserImportGUI::testImport ( )
protected

FSX Can be deleted; Just for a single Test of a UserImport

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

References ilUtil\sendInfo().

96  {
97  return false;
98  $importer = new ilOrgUnitSimpleUserImport();
99  $string = '<Assignment action=\'add\'>
100  <User id_type=\'ilias_login\'>root</User>
101  <OrgUnit id_type=\'external_id\'>imported_001</OrgUnit>
102  <Role>superior</Role>
103  </Assignment>';
104 
105  $xml = new SimpleXMLElement($string);
106  $importer->simpleUserImportElement($xml);
107  ilUtil::sendInfo('<pre>' . print_r($importer->getErrors(), 1) . '</pre>');
108  }
Class ilOrgUnitSimpleUserImport.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
+ Here is the call graph for this function:

◆ userImportScreen()

ilOrgUnitSimpleUserImportGUI::userImportScreen ( )

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

References initForm().

Referenced by executeCommand().

87  {
88  $form = $this->initForm();
89  $this->tpl->setContent($form->getHTML());
90  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $ctrl

ilOrgUnitSimpleUserImportGUI::$ctrl
protected

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

◆ $ilAccess

ilOrgUnitSimpleUserImportGUI::$ilAccess
protected

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

Referenced by __construct().

◆ $lng

ilOrgUnitSimpleUserImportGUI::$lng
protected

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

Referenced by __construct().

◆ $parent_object

ilOrgUnitSimpleUserImportGUI::$parent_object
protected

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

◆ $tabs_gui

ilOrgUnitSimpleUserImportGUI::$tabs_gui
protected

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

◆ $toolbar

ilOrgUnitSimpleUserImportGUI::$toolbar
protected

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

◆ $tpl

ilOrgUnitSimpleUserImportGUI::$tpl
protected

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

Referenced by __construct().


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