ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
ilOrgUnitSimpleUserImportGUI Class Reference

Class ilOrgUnitSimpleUserImportGUI. More...

+ Collaboration diagram for ilOrgUnitSimpleUserImportGUI:

Public Member Functions

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

Protected Member Functions

 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 45 of file class.ilOrgUnitSimpleUserImportGUI.php.

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

45  {
46  global $tpl, $ilCtrl, $ilTabs, $ilToolbar, $lng, $ilAccess;
47  $this->tpl = $tpl;
48  $this->ctrl = $ilCtrl;
49  $this->parent_gui = $parent_gui;
50  $this->parent_object = $parent_gui->object;
51  $this->tabs_gui = $this->parent_gui->tabs_gui;
52  $this->toolbar = $ilToolbar;
53  $this->lng = $lng;
54  $this->ilAccess = $ilAccess;
55  $this->lng->loadLanguageModule('user');
56  if (! $this->ilAccess->checkaccess("write", "", $this->parent_gui->object->getRefId())) {
57  ilUtil::sendFailure($this->lng->txt("permission_denied"), true);
58  }
59  }
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 117 of file class.ilOrgUnitSimpleUserImportGUI.php.

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

Referenced by startImport().

117  {
118  if (! $importer->hasErrors() && ! $importer->hasWarnings()) {
119  $stats = $importer->getStats();
120  ilUtil::sendSuccess(sprintf($this->lng->txt("user_import_successful"), $stats["created"], $stats["removed"]), true);
121  }
122  if ($importer->hasWarnings()) {
123  $msg = $this->lng->txt("import_terminated_with_warnings") . "<br>";
124  foreach ($importer->getWarnings() as $warning) {
125  $msg .= "-" . $this->lng->txt($warning["lang_var"]) . " (Import ID: " . $warning["import_id"] . ")<br>";
126  }
127  ilUtil::sendInfo($msg, true);
128  }
129  if ($importer->hasErrors()) {
130  $msg = $this->lng->txt("import_terminated_with_errors") . "<br>";
131  foreach ($importer->getErrors() as $warning) {
132  $msg .= "- " . $this->lng->txt($warning["lang_var"]) . " (Import ID: " . $warning["import_id"] . ")<br>";
133  }
134  ilUtil::sendFailure($msg, true);
135  }
136  }
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 64 of file class.ilOrgUnitSimpleUserImportGUI.php.

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

65  {
66  $cmd = $this->ctrl->getCmd();
67 
68  switch ($cmd) {
69  case 'userImportScreen':
70  $this->userImportScreen();
71  break;
72  case 'startImport':
73  $this->startImport();
74  break;
75  }
76  return true;
77  }
$cmd
Definition: sahs_server.php:35
+ Here is the call graph for this function:

◆ initForm()

ilOrgUnitSimpleUserImportGUI::initForm ( )
protected

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

References ilFormPropertyGUI\setRequired().

Referenced by startImport(), and userImportScreen().

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

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

Referenced by executeCommand().

96  {
97  $form = $this->initForm();
98  if (! $form->checkInput()) {
99  $this->tpl->setContent($form->getHTML());
100  } else {
101  $file = $form->getInput("import_file");
102  $importer = new ilOrgUnitSimpleUserImport();
103  try {
104  $importer->simpleUserImport($file["tmp_name"]);
105  } catch (Exception $e) {
106  $this->ilLog->wirte($e->getMessage() . " - " . $e->getTraceAsString());
107  ilUtil::sendFailure($lng->txt("import_failed"), true);
108  $this->ctrl->redirect($this, "render");
109  }
110  $this->displayImportResults($importer);
111  }
112  }
print $file
Class ilOrgUnitSimpleUserImport.
logging
Definition: class.ilLog.php:18
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:

◆ userImportScreen()

ilOrgUnitSimpleUserImportGUI::userImportScreen ( )

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

References initForm().

Referenced by executeCommand().

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

◆ $ilAccess

ilOrgUnitSimpleUserImportGUI::$ilAccess
protected

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

Referenced by __construct().

◆ $lng

ilOrgUnitSimpleUserImportGUI::$lng
protected

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

Referenced by __construct(), and startImport().

◆ $parent_object

ilOrgUnitSimpleUserImportGUI::$parent_object
protected

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

◆ $tabs_gui

ilOrgUnitSimpleUserImportGUI::$tabs_gui
protected

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

◆ $toolbar

ilOrgUnitSimpleUserImportGUI::$toolbar
protected

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

◆ $tpl

ilOrgUnitSimpleUserImportGUI::$tpl
protected

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

Referenced by __construct().


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