ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 $DIC, $ilAccess, $ilCtrl, $lng, $log, $tpl, and ilUtil\sendFailure().

48  {
49  global $DIC;
50  $tpl = $DIC['tpl'];
51  $ilCtrl = $DIC['ilCtrl'];
52  $ilToolbar = $DIC['ilToolbar'];
53  $lng = $DIC['lng'];
54  $ilAccess = $DIC['ilAccess'];
55  $log = $DIC['log'];
56  $this->tpl = $tpl;
57  $this->ctrl = $ilCtrl;
58  $this->parent_gui = $parent_gui;
59  $this->parent_object = $parent_gui->object;
60  $this->tabs_gui = $this->parent_gui->tabs_gui;
61  $this->toolbar = $ilToolbar;
62  $this->lng = $lng;
63  $this->ilLog = $log;
64  $this->ilAccess = $ilAccess;
65  $this->lng->loadLanguageModule('user');
66  if (!$this->ilAccess->checkaccess('write', '', $this->parent_gui->object->getRefId())) {
67  ilUtil::sendFailure($this->lng->txt('permission_denied'), true);
68  }
69  }
global $DIC
Definition: saml.php:7
logging
Definition: class.ilLog.php:18
Class ilAccessHandler.
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 157 of file class.ilOrgUnitSimpleUserImportGUI.php.

References $stats, $warning, ilUtil\sendFailure(), ilUtil\sendInfo(), and ilUtil\sendSuccess().

Referenced by startImport().

158  {
159  if (!$importer->hasErrors() and !$importer->hasWarnings()) {
160  $stats = $importer->getStats();
161  ilUtil::sendSuccess(sprintf($this->lng->txt('user_import_successful'), $stats['created'], $stats['removed']), true);
162  }
163  if ($importer->hasWarnings()) {
164  $msg = $this->lng->txt('import_terminated_with_warnings') . '<br>';
165  foreach ($importer->getWarnings() as $warning) {
166  $msg .= '-' . $this->lng->txt($warning['lang_var']) . ' (Import ID: ' . $warning['import_id'] . ')<br>';
167  }
168  ilUtil::sendInfo($msg, true);
169  }
170  if ($importer->hasErrors()) {
171  $msg = $this->lng->txt('import_terminated_with_errors') . '<br>';
172  foreach ($importer->getErrors() as $warning) {
173  $msg .= '- ' . $this->lng->txt($warning['lang_var']) . ' (Import ID: ' . $warning['import_id'] . ')<br>';
174  }
175  ilUtil::sendFailure($msg, true);
176  }
177  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
$stats
$warning
Definition: X509warning.php:13
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 75 of file class.ilOrgUnitSimpleUserImportGUI.php.

References startImport(), and userImportScreen().

76  {
77  $cmd = $this->ctrl->getCmd();
78 
79  $this->tabs_gui->clearTargets();
80  $this->tabs_gui->setBackTarget($this->lng->txt("back"), $this->ctrl->getLinkTargetByClass('ilOrgUnitSimpleImportGUI', 'chooseImport'));
81 
82  switch ($cmd) {
83  case 'userImportScreen':
84  $this->userImportScreen();
85  break;
86  case 'startImport':
87  $this->startImport();
88  break;
89  }
90 
91  return true;
92  }
+ Here is the call graph for this function:

◆ initForm()

ilOrgUnitSimpleUserImportGUI::initForm ( )
protected

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

References $form, and ilFormPropertyGUI\setRequired().

Referenced by startImport(), and userImportScreen().

122  {
123  $form = new ilPropertyFormGUI();
124  $input = new ilFileInputGUI($this->lng->txt('import_xml_file'), 'import_file');
125  $input->setRequired(true);
126  $form->addItem($input);
127  $form->setFormAction($this->ctrl->getFormAction($this));
128  $form->addCommandButton('startImport', $this->lng->txt('import'));
129 
130  return $form;
131  }
This class represents a property form user interface.
This class represents a file property in a property form.
if(isset($_POST['submit'])) $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 134 of file class.ilOrgUnitSimpleUserImportGUI.php.

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

Referenced by executeCommand().

135  {
136  $form = $this->initForm();
137  if (!$form->checkInput()) {
138  $this->tpl->setContent($form->getHTML());
139  } else {
140  $file = $form->getInput('import_file');
141  $importer = new ilOrgUnitSimpleUserImport();
142  try {
143  $importer->simpleUserImport($file['tmp_name']);
144  } catch (Exception $e) {
145  $this->ilLog->write($e->getMessage() . ' - ' . $e->getTraceAsString());
146  ilUtil::sendFailure($this->lng->txt('import_failed'), true);
147  $this->ctrl->redirect($this, 'render');
148  }
149  $this->displayImportResults($importer);
150  }
151  }
Class ilOrgUnitSimpleUserImport.
logging
Definition: class.ilLog.php:18
write($a_msg, $a_log_level=null)
logging
if(isset($_POST['submit'])) $form
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
+ 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 105 of file class.ilOrgUnitSimpleUserImportGUI.php.

References $xml, and ilUtil\sendInfo().

106  {
107  return false;
108  $importer = new ilOrgUnitSimpleUserImport();
109  $string = '<Assignment action=\'add\'>
110  <User id_type=\'ilias_login\'>root</User>
111  <OrgUnit id_type=\'external_id\'>imported_001</OrgUnit>
112  <Role>superior</Role>
113  </Assignment>';
114 
115  $xml = new SimpleXMLElement($string);
116  $importer->simpleUserImportElement($xml);
117  ilUtil::sendInfo('<pre>' . print_r($importer->getErrors(), 1) . '</pre>');
118  }
Class ilOrgUnitSimpleUserImport.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
$xml
Definition: metadata.php:240
+ Here is the call graph for this function:

◆ userImportScreen()

ilOrgUnitSimpleUserImportGUI::userImportScreen ( )

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

References $form, and initForm().

Referenced by executeCommand().

96  {
97  $form = $this->initForm();
98  $this->tpl->setContent($form->getHTML());
99  }
if(isset($_POST['submit'])) $form
+ 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: