ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 45 of file class.ilOrgUnitSimpleImportGUI.php.

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

46  {
47  global $DIC;
48  $tpl = $DIC['tpl'];
49  $ilCtrl = $DIC['ilCtrl'];
50  $ilTabs = $DIC['ilTabs'];
51  $ilToolbar = $DIC['ilToolbar'];
52  $lng = $DIC['lng'];
53  $ilAccess = $DIC['ilAccess'];
54  $ilLog = $DIC['ilLog'];
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->ilAccess = $ilAccess;
63  $this->lng->loadLanguageModule('user');
64  $this->ilLog = $ilLog;
65  if (!$this->ilAccess->checkaccess("write", "", $this->parent_gui->object->getRefId())) {
66  ilUtil::sendFailure($this->lng->txt("permission_denied"), true);
67  }
68  }
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

◆ chooseImport()

ilOrgUnitSimpleImportGUI::chooseImport ( )

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

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

Referenced by executeCommand().

96  {
97  if (!$this->ilAccess->checkAccess("write", "", $_GET["ref_id"]) or !$this->parent_object->getRefId() == ilObjOrgUnit::getRootOrgRefId()) {
98  ilUtil::sendFailure($this->lng->txt("msg_no_perm_edit"));
99  $this->ctrl->redirectByClass('ilinfoscreengui', '');
100  }
101 
102  $this->tabs_gui->setTabActive('view_content');
103  $this->tabs_gui->removeSubTab("page_editor");
104  $this->tabs_gui->removeSubTab("ordering"); // Mantis 0014728
105 
106  if ($this->ilAccess->checkAccess("write", "", $_GET["ref_id"]) and $this->parent_object->getRefId() == ilObjOrgUnit::getRootOrgRefId()) {
107  $this->toolbar->addButton($this->lng->txt("simple_import"), $this->ctrl->getLinkTargetByClass("ilOrgUnitSimpleImportGUI", "importScreen"));
108  $this->toolbar->addButton($this->lng->txt("simple_user_import"), $this->ctrl->getLinkTargetByClass("ilOrgUnitSimpleUserImportGUI", "userImportScreen"));
109  }
110  }
$_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 175 of file class.ilOrgUnitSimpleImportGUI.php.

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

Referenced by startImport().

176  {
177  if (!$importer->hasErrors() && !$importer->hasWarnings()) {
178  $stats = $importer->getStats();
179  ilUtil::sendSuccess(sprintf($this->lng->txt("import_successful"), $stats["created"], $stats["updated"], $stats["deleted"]), true);
180  }
181  if ($importer->hasWarnings()) {
182  $msg = $this->lng->txt("import_terminated_with_warnings") . " <br/>";
183  foreach ($importer->getWarnings() as $warning) {
184  $msg .= "-" . $this->lng->txt($warning["lang_var"]) . " (Import ID: " . $warning["import_id"] . ")<br />";
185  }
186  ilUtil::sendInfo($msg, true);
187  }
188  if ($importer->hasErrors()) {
189  $msg = $this->lng->txt("import_terminated_with_errors") . "<br/>";
190  foreach ($importer->getErrors() as $warning) {
191  $msg .= "- " . $this->lng->txt($warning["lang_var"]) . " (Import ID: " . $warning["import_id"] . ")<br />";
192  }
193  ilUtil::sendFailure($msg, true);
194  }
195  }
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()

ilOrgUnitSimpleImportGUI::executeCommand ( )
Returns
bool

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

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

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

◆ importScreen()

ilOrgUnitSimpleImportGUI::importScreen ( )

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

References $form, and initForm().

Referenced by executeCommand().

113  {
114  $form = $this->initForm("startImport");
115  $this->tpl->setContent($form->getHTML());
116  }
if(isset($_POST['submit'])) $form
+ 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 119 of file class.ilOrgUnitSimpleImportGUI.php.

References $form, array, and ilFormPropertyGUI\setRequired().

Referenced by importScreen(), and startImport().

120  {
121  $form = new ilPropertyFormGUI();
122  $input = new ilFileInputGUI($this->lng->txt("import_xml_file"), "import_file");
123  $input->setRequired(true);
124  $input->setSuffixes(array('zip', 'xml'));
125  $form->addItem($input);
126  $form->setFormAction($this->ctrl->getFormAction($this));
127  $form->addCommandButton($submit_action, $this->lng->txt("import"));
128 
129  return $form;
130  }
This class represents a property form user interface.
This class represents a file property in a property form.
if(isset($_POST['submit'])) $form
Create styles array
The data for the language used.
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 133 of file class.ilOrgUnitSimpleImportGUI.php.

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

Referenced by executeCommand().

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

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: