ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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 ()
 
 chooseImport ()
 
 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 46 of file class.ilOrgUnitSimpleImportGUI.php.

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

47  {
48  global $DIC;
49  $tpl = $DIC['tpl'];
50  $ilCtrl = $DIC['ilCtrl'];
51  $ilTabs = $DIC['ilTabs'];
52  $ilToolbar = $DIC['ilToolbar'];
53  $lng = $DIC['lng'];
54  $ilAccess = $DIC['ilAccess'];
55  $ilLog = $DIC['ilLog'];
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->ilAccess = $ilAccess;
64  $this->lng->loadLanguageModule('user');
65  $this->ilLog = $ilLog;
66  if (!$this->ilAccess->checkaccess("write", "", $this->parent_gui->object->getRefId())) {
67  ilUtil::sendFailure($this->lng->txt("permission_denied"), true);
68  }
69  }
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.
$DIC
Definition: xapitoken.php:46
+ Here is the call graph for this function:

Member Function Documentation

◆ chooseImport()

ilOrgUnitSimpleImportGUI::chooseImport ( )

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

References $_GET, ilAccess\checkAccess(), ilObjOrgUnit\getRootOrgRefId(), and ilUtil\sendFailure().

Referenced by executeCommand().

100  {
101  if (!$this->ilAccess->checkAccess("write", "", $_GET["ref_id"]) or !$this->parent_object->getRefId() == ilObjOrgUnit::getRootOrgRefId()) {
102  ilUtil::sendFailure($this->lng->txt("msg_no_perm_edit"));
103  $this->ctrl->redirectByClass('ilinfoscreengui', '');
104  }
105 
106  $this->tabs_gui->setTabActive('view_content');
107  $this->tabs_gui->removeSubTab("page_editor");
108  $this->tabs_gui->removeSubTab("ordering"); // Mantis 0014728
109 
110  if ($this->ilAccess->checkAccess("write", "", $_GET["ref_id"]) and $this->parent_object->getRefId() == ilObjOrgUnit::getRootOrgRefId()) {
111  $this->toolbar->addButton($this->lng->txt("simple_import"), $this->ctrl->getLinkTargetByClass("ilOrgUnitSimpleImportGUI", "importScreen"));
112  $this->toolbar->addButton($this->lng->txt("simple_user_import"), $this->ctrl->getLinkTargetByClass("ilOrgUnitSimpleUserImportGUI", "userImportScreen"));
113  }
114  }
$_GET["client_id"]
Class ilAccessHandler.
checkAccess($a_permission, $a_cmd, $a_ref_id, $a_type="", $a_obj_id="", $a_tree_id="")
check access for an object (provide $a_type and $a_obj_id if available for better performance)(option...
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static getRootOrgRefId()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ displayImportResults()

ilOrgUnitSimpleImportGUI::displayImportResults (   $importer)
Parameters
$importerilOrgUnitImporter

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

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

Referenced by startImport().

182  {
183  if (!$importer->hasErrors() && !$importer->hasWarnings()) {
184  $stats = $importer->getStats();
185  ilUtil::sendSuccess(sprintf($this->lng->txt("import_successful"), $stats["created"], $stats["updated"], $stats["deleted"]), true);
186  }
187  if ($importer->hasWarnings()) {
188  $msg = $this->lng->txt("import_terminated_with_warnings") . " <br/>";
189  foreach ($importer->getWarnings() as $warning) {
190  $msg .= "-" . $this->lng->txt($warning["lang_var"]) . " (Import ID: " . $warning["import_id"] . ")<br />";
191  }
192  ilUtil::sendInfo($msg, true);
193  }
194  if ($importer->hasErrors()) {
195  $msg = $this->lng->txt("import_terminated_with_errors") . "<br/>";
196  foreach ($importer->getErrors() as $warning) {
197  $msg .= "- " . $this->lng->txt($warning["lang_var"]) . " (Import ID: " . $warning["import_id"] . ")<br />";
198  }
199  ilUtil::sendFailure($msg, true);
200  }
201  }
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 75 of file class.ilOrgUnitSimpleImportGUI.php.

References chooseImport(), importScreen(), and startImport().

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

◆ importScreen()

ilOrgUnitSimpleImportGUI::importScreen ( )

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

References initForm().

Referenced by executeCommand().

118  {
119  $form = $this->initForm("startImport");
120  $this->tpl->setContent($form->getHTML());
121  }
+ 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 124 of file class.ilOrgUnitSimpleImportGUI.php.

References ilFormPropertyGUI\setRequired().

Referenced by importScreen(), and startImport().

125  {
126  $form = new ilPropertyFormGUI();
127  $input = new ilFileInputGUI($this->lng->txt("import_xml_file"), "import_file");
128  $input->setRequired(true);
129  $input->setSuffixes(array('zip', 'xml'));
130  $form->addItem($input);
131  $form->setFormAction($this->ctrl->getFormAction($this));
132  $form->addCommandButton($submit_action, $this->lng->txt("import"));
133 
134  return $form;
135  }
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 138 of file class.ilOrgUnitSimpleImportGUI.php.

References Vendor\Package\$e, $res, displayImportResults(), initForm(), ilUtil\sendFailure(), and ilLog\write().

Referenced by executeCommand().

139  {
140  $form = $this->initForm("startImport");
141  if (!$form->checkInput()) {
142  $this->tpl->setContent($form->getHTML());
143  } else {
144  $file = $form->getInput("import_file");
145  $importer = new ilOrgUnitSimpleImport();
146  try {
147  $file_path = $file["tmp_name"];
148  $file_type = pathinfo($file["name"], PATHINFO_EXTENSION);
149  $file_name = pathinfo($file["name"], PATHINFO_FILENAME);
150 
151  if ($file_type == "zip") {
152  $extract_path = $file_path . '_extracted/';
153  $extracted_file = $extract_path . $file_name . '/manifest.xml';
154 
155  $zip = new ZipArchive();
156  $res = $zip->open($file_path);
157  if ($res === true) {
158  $zip->extractTo($extract_path);
159  $zip->close();
160 
161  if (file_exists($extracted_file)) {
162  $file_path = $extracted_file;
163  }
164  }
165  }
166 
167  $importer->simpleImport($file_path);
168  } catch (Exception $e) {
169  $this->ilLog->write($e->getMessage() . " - " . $e->getTraceAsString());
170  ilUtil::sendFailure($this->lng->txt("import_failed"), true);
171  $this->ctrl->redirect($this, "render");
172  }
173  $this->displayImportResults($importer);
174  }
175  }
logging
Definition: class.ilLog.php:18
write($a_msg, $a_log_level=null)
logging
foreach($_POST as $key=> $value) $res
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:

Field Documentation

◆ $ctrl

ilOrgUnitSimpleImportGUI::$ctrl
protected

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

◆ $ilAccess

ilOrgUnitSimpleImportGUI::$ilAccess
protected

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

Referenced by __construct().

◆ $lng

ilOrgUnitSimpleImportGUI::$lng
protected

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

Referenced by __construct().

◆ $parent_object

ilOrgUnitSimpleImportGUI::$parent_object
protected

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

◆ $tabs_gui

ilOrgUnitSimpleImportGUI::$tabs_gui
protected

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

◆ $toolbar

ilOrgUnitSimpleImportGUI::$toolbar
protected

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

◆ $tpl

ilOrgUnitSimpleImportGUI::$tpl
protected

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

Referenced by __construct().


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