ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
All Data Structures Namespaces Files Functions Variables Modules Pages
ilOrgUnitSimpleImportGUI Class Reference

Class ilOrgUnitSimpleImportGUI. More...

+ Collaboration diagram for ilOrgUnitSimpleImportGUI:

Public Member Functions

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

Protected Member Functions

 initForm ($submit_action)
 

Protected Attributes

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

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilOrgUnitSimpleImportGUI::__construct (   $parent_gui)
Parameters
$parent_gui

Definition at line 45 of file class.ilOrgUnitSimpleImportGUI.php.

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

45  {
46  global $tpl, $ilCtrl, $ilTabs, $ilToolbar, $lng, $ilAccess, $ilLog;
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  $this->ilLog = $ilLog;
57  if (! $this->ilAccess->checkaccess("write", "", $this->parent_gui->object->getRefId())) {
58  ilUtil::sendFailure($this->lng->txt("permission_denied"), true);
59  }
60  }
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()

ilOrgUnitSimpleImportGUI::displayImportResults (   $importer)
Parameters
$importerilOrgUnitImporter

Definition at line 140 of file class.ilOrgUnitSimpleImportGUI.php.

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

Referenced by startImport().

140  {
141  if (! $importer->hasErrors() && ! $importer->hasWarnings()) {
142  $stats = $importer->getStats();
143  ilUtil::sendSuccess(sprintf($this->lng->txt("import_successful"), $stats["created"], $stats["updated"], $stats["deleted"]), true);
144  }
145  if ($importer->hasWarnings()) {
146  $msg = $this->lng->txt("import_terminated_with_warnings") . " <br/>";
147  foreach ($importer->getWarnings() as $warning) {
148  $msg .= "-" . $this->lng->txt($warning["lang_var"]) . " (Import ID: " . $warning["import_id"] . ")<br />";
149  }
150  ilUtil::sendInfo($msg, true);
151  }
152  if ($importer->hasErrors()) {
153  $msg = $this->lng->txt("import_terminated_with_errors") . "<br/>";
154  foreach ($importer->getErrors() as $warning) {
155  $msg .= "- " . $this->lng->txt($warning["lang_var"]) . " (Import ID: " . $warning["import_id"] . ")<br />";
156  }
157  ilUtil::sendFailure($msg, true);
158  }
159  }
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()

ilOrgUnitSimpleImportGUI::executeCommand ( )
Returns
bool

Definition at line 65 of file class.ilOrgUnitSimpleImportGUI.php.

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

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

◆ importScreen()

ilOrgUnitSimpleImportGUI::importScreen ( )

Definition at line 80 of file class.ilOrgUnitSimpleImportGUI.php.

References initForm().

Referenced by executeCommand().

80  {
81  $form = $this->initForm("startImport");
82  $this->tpl->setContent($form->getHTML());
83  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initForm()

ilOrgUnitSimpleImportGUI::initForm (   $submit_action)
protected

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

References ilFormPropertyGUI\setRequired().

Referenced by importScreen(), and startImport().

86  {
87  $form = new ilPropertyFormGUI();
88  $input = new ilFileInputGUI($this->lng->txt("import_xml_file"), "import_file");
89  $input->setRequired(true);
90  $input->setSuffixes(array('zip', 'xml'));
91  $form->addItem($input);
92  $form->setFormAction($this->ctrl->getFormAction($this));
93  $form->addCommandButton($submit_action, $this->lng->txt("import"));
94 
95  return $form;
96  }
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()

ilOrgUnitSimpleImportGUI::startImport ( )

Definition at line 99 of file class.ilOrgUnitSimpleImportGUI.php.

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

Referenced by executeCommand().

99  {
100  $form = $this->initForm("startImport");
101  if (! $form->checkInput()) {
102  $this->tpl->setContent($form->getHTML());
103  } else {
104  $file = $form->getInput("import_file");
105  $importer = new ilOrgUnitSimpleImport();
106  try {
107  $file_path = $file["tmp_name"];
108  $file_type = pathinfo($file["name"], PATHINFO_EXTENSION);
109  $file_name = pathinfo($file["name"], PATHINFO_FILENAME);
110 
111  if($file_type == "zip") {
112  $extract_path = $file_path.'_extracted/';
113  $extracted_file = $extract_path.$file_name.'/manifest.xml';
114 
115  $zip = new ZipArchive();
116  $res = $zip->open($file_path);
117  if ($res === true) {
118  $zip->extractTo($extract_path);
119  $zip->close();
120 
121  if(file_exists($extracted_file)) {
122  $file_path = $extracted_file;
123  }
124  }
125  }
126 
127  $importer->simpleImport($file_path);
128  } catch (Exception $e) {
129  $this->ilLog->write($e->getMessage() . " - " . $e->getTraceAsString());
130  ilUtil::sendFailure($this->lng->txt("import_failed"), true);
131  $this->ctrl->redirect($this, "render");
132  }
133  $this->displayImportResults($importer);
134  }
135  }
print $file
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.
Class ilOrgUnitSimpleImport.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $ctrl

ilOrgUnitSimpleImportGUI::$ctrl
protected

Definition at line 23 of file class.ilOrgUnitSimpleImportGUI.php.

◆ $ilAccess

ilOrgUnitSimpleImportGUI::$ilAccess
protected

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

Referenced by __construct().

◆ $lng

ilOrgUnitSimpleImportGUI::$lng
protected

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

Referenced by __construct().

◆ $parent_object

ilOrgUnitSimpleImportGUI::$parent_object
protected

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

◆ $tabs_gui

ilOrgUnitSimpleImportGUI::$tabs_gui
protected

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

◆ $toolbar

ilOrgUnitSimpleImportGUI::$toolbar
protected

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

◆ $tpl

ilOrgUnitSimpleImportGUI::$tpl
protected

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

Referenced by __construct().


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