ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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().

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

Member Function Documentation

◆ displayImportResults()

ilOrgUnitSimpleUserImportGUI::displayImportResults (   $importer)
Parameters
$importerilOrgUnitImporter

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

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

Referenced by startImport().

151  {
152  if (!$importer->hasErrors() AND !$importer->hasWarnings()) {
153  $stats = $importer->getStats();
154  ilUtil::sendSuccess(sprintf($this->lng->txt('user_import_successful'), $stats['created'], $stats['removed']), true);
155  }
156  if ($importer->hasWarnings()) {
157  $msg = $this->lng->txt('import_terminated_with_warnings') . '<br>';
158  foreach ($importer->getWarnings() as $warning) {
159  $msg .= '-' . $this->lng->txt($warning['lang_var']) . ' (Import ID: ' . $warning['import_id'] . ')<br>';
160  }
161  ilUtil::sendInfo($msg, true);
162  }
163  if ($importer->hasErrors()) {
164  $msg = $this->lng->txt('import_terminated_with_errors') . '<br>';
165  foreach ($importer->getErrors() as $warning) {
166  $msg .= '- ' . $this->lng->txt($warning['lang_var']) . ' (Import ID: ' . $warning['import_id'] . ')<br>';
167  }
168  ilUtil::sendFailure($msg, true);
169  }
170  }
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 74 of file class.ilOrgUnitSimpleUserImportGUI.php.

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

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

◆ initForm()

ilOrgUnitSimpleUserImportGUI::initForm ( )
protected

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

References ilFormPropertyGUI\setRequired().

Referenced by startImport(), and userImportScreen().

117  {
118  $form = new ilPropertyFormGUI();
119  $input = new ilFileInputGUI($this->lng->txt('import_xml_file'), 'import_file');
120  $input->setRequired(true);
121  $form->addItem($input);
122  $form->setFormAction($this->ctrl->getFormAction($this));
123  $form->addCommandButton('startImport', $this->lng->txt('import'));
124 
125  return $form;
126  }
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 129 of file class.ilOrgUnitSimpleUserImportGUI.php.

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

Referenced by executeCommand().

129  {
130  $form = $this->initForm();
131  if (!$form->checkInput()) {
132  $this->tpl->setContent($form->getHTML());
133  } else {
134  $file = $form->getInput('import_file');
135  $importer = new ilOrgUnitSimpleUserImport();
136  try {
137  $importer->simpleUserImport($file['tmp_name']);
138  } catch (Exception $e) {
139  $this->ilLog->write($e->getMessage() . ' - ' . $e->getTraceAsString());
140  ilUtil::sendFailure($this->lng->txt('import_failed'), true);
141  $this->ctrl->redirect($this, 'render');
142  }
143  $this->displayImportResults($importer);
144  }
145  }
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.
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 102 of file class.ilOrgUnitSimpleUserImportGUI.php.

References ilUtil\sendInfo().

102  {
103  return false;
104  $importer = new ilOrgUnitSimpleUserImport();
105  $string = '<Assignment action=\'add\'>
106  <User id_type=\'ilias_login\'>root</User>
107  <OrgUnit id_type=\'external_id\'>imported_001</OrgUnit>
108  <Role>superior</Role>
109  </Assignment>';
110 
111  $xml = new SimpleXMLElement($string);
112  $importer->simpleUserImportElement($xml);
113  ilUtil::sendInfo('<pre>' . print_r($importer->getErrors(), 1) . '</pre>');
114  }
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 93 of file class.ilOrgUnitSimpleUserImportGUI.php.

References initForm().

Referenced by executeCommand().

93  {
94  $form = $this->initForm();
95  $this->tpl->setContent($form->getHTML());
96  }
+ 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: