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

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

◆ chooseImport()

ilOrgUnitSimpleImportGUI::chooseImport ( )

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

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

Referenced by executeCommand().

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

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

Referenced by startImport().

170  {
171  if (! $importer->hasErrors() && ! $importer->hasWarnings()) {
172  $stats = $importer->getStats();
173  ilUtil::sendSuccess(sprintf($this->lng->txt("import_successful"), $stats["created"], $stats["updated"], $stats["deleted"]), true);
174  }
175  if ($importer->hasWarnings()) {
176  $msg = $this->lng->txt("import_terminated_with_warnings") . " <br/>";
177  foreach ($importer->getWarnings() as $warning) {
178  $msg .= "-" . $this->lng->txt($warning["lang_var"]) . " (Import ID: " . $warning["import_id"] . ")<br />";
179  }
180  ilUtil::sendInfo($msg, true);
181  }
182  if ($importer->hasErrors()) {
183  $msg = $this->lng->txt("import_terminated_with_errors") . "<br/>";
184  foreach ($importer->getErrors() as $warning) {
185  $msg .= "- " . $this->lng->txt($warning["lang_var"]) . " (Import ID: " . $warning["import_id"] . ")<br />";
186  }
187  ilUtil::sendFailure($msg, true);
188  }
189  }
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 72 of file class.ilOrgUnitSimpleImportGUI.php.

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

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

◆ importScreen()

ilOrgUnitSimpleImportGUI::importScreen ( )

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

References initForm().

Referenced by executeCommand().

110  {
111  $form = $this->initForm("startImport");
112  $this->tpl->setContent($form->getHTML());
113  }
+ 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 116 of file class.ilOrgUnitSimpleImportGUI.php.

References array, and ilFormPropertyGUI\setRequired().

Referenced by importScreen(), and startImport().

116  {
117  $form = new ilPropertyFormGUI();
118  $input = new ilFileInputGUI($this->lng->txt("import_xml_file"), "import_file");
119  $input->setRequired(true);
120  $input->setSuffixes(array('zip', 'xml'));
121  $form->addItem($input);
122  $form->setFormAction($this->ctrl->getFormAction($this));
123  $form->addCommandButton($submit_action, $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.
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 129 of file class.ilOrgUnitSimpleImportGUI.php.

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

Referenced by executeCommand().

129  {
130  $form = $this->initForm("startImport");
131  if (! $form->checkInput()) {
132  $this->tpl->setContent($form->getHTML());
133  } else {
134  $file = $form->getInput("import_file");
135  $importer = new ilOrgUnitSimpleImport();
136  try {
137  $file_path = $file["tmp_name"];
138  $file_type = pathinfo($file["name"], PATHINFO_EXTENSION);
139  $file_name = pathinfo($file["name"], PATHINFO_FILENAME);
140 
141  if($file_type == "zip") {
142  $extract_path = $file_path.'_extracted/';
143  $extracted_file = $extract_path.$file_name.'/manifest.xml';
144 
145  $zip = new ZipArchive();
146  $res = $zip->open($file_path);
147  if ($res === true) {
148  $zip->extractTo($extract_path);
149  $zip->close();
150 
151  if(file_exists($extracted_file)) {
152  $file_path = $extracted_file;
153  }
154  }
155  }
156 
157  $importer->simpleImport($file_path);
158  } catch (Exception $e) {
159  $this->ilLog->write($e->getMessage() . " - " . $e->getTraceAsString());
160  ilUtil::sendFailure($this->lng->txt("import_failed"), true);
161  $this->ctrl->redirect($this, "render");
162  }
163  $this->displayImportResults($importer);
164  }
165  }
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.
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: