ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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.

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:19
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
global $ilCtrl
Definition: ilias.php:18

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

+ Here is the call graph for this function:

Member Function Documentation

◆ chooseImport()

ilOrgUnitSimpleImportGUI::chooseImport ( )

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

87 {
88 if (!$this->ilAccess->checkAccess("write", "", $_GET["ref_id"]) OR !$this->parent_object->getRefId() == ilObjOrgUnit::getRootOrgRefId()) {
89 ilUtil::sendFailure($this->lng->txt("msg_no_perm_edit"));
90 $this->ctrl->redirectByClass('ilinfoscreengui', '');
91 }
92
93 $this->tabs_gui->setTabActive("import");
94 $this->tabs_gui->removeSubTab("page_editor");
95 $this->tabs_gui->removeSubTab("ordering"); // Mantis 0014728
96
97 if ($this->ilAccess->checkAccess("write", "", $_GET["ref_id"]) AND $this->parent_object->getRefId() == ilObjOrgUnit::getRootOrgRefId()) {
98 $this->toolbar->addButton($this->lng->txt("simple_import"), $this->ctrl->getLinkTargetByClass("ilOrgUnitSimpleImportGUI", "importScreen"));
99 $this->toolbar->addButton($this->lng->txt("simple_user_import"), $this->ctrl->getLinkTargetByClass("ilOrgUnitSimpleUserImportGUI", "userImportScreen"));
100 }
101 }
$_GET["client_id"]
static getRootOrgRefId()

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

Referenced by executeCommand().

+ 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 163 of file class.ilOrgUnitSimpleImportGUI.php.

163 {
164 if (! $importer->hasErrors() && ! $importer->hasWarnings()) {
165 $stats = $importer->getStats();
166 ilUtil::sendSuccess(sprintf($this->lng->txt("import_successful"), $stats["created"], $stats["updated"], $stats["deleted"]), true);
167 }
168 if ($importer->hasWarnings()) {
169 $msg = $this->lng->txt("import_terminated_with_warnings") . " <br/>";
170 foreach ($importer->getWarnings() as $warning) {
171 $msg .= "-" . $this->lng->txt($warning["lang_var"]) . " (Import ID: " . $warning["import_id"] . ")<br />";
172 }
173 ilUtil::sendInfo($msg, true);
174 }
175 if ($importer->hasErrors()) {
176 $msg = $this->lng->txt("import_terminated_with_errors") . "<br/>";
177 foreach ($importer->getErrors() as $warning) {
178 $msg .= "- " . $this->lng->txt($warning["lang_var"]) . " (Import ID: " . $warning["import_id"] . ")<br />";
179 }
180 ilUtil::sendFailure($msg, true);
181 }
182 }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.

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

Referenced by startImport().

+ 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.

66 {
67 $cmd = $this->ctrl->getCmd();
68
69 switch ($cmd) {
70 case 'chooseImport':
71 $this->chooseImport();
72 break;
73 case 'importScreen':
74 $this->tabs_gui->clearTargets();
75 $this->tabs_gui->setBackTarget($this->lng->txt("back"), $this->ctrl->getLinkTarget($this,'chooseImport'));
76 $this->importScreen();
77 break;
78 case 'startImport':
79 $this->tabs_gui->clearTargets();
80 $this->tabs_gui->setBackTarget($this->lng->txt("back"), $this->ctrl->getLinkTarget($this,'chooseImport'));
81 $this->startImport();
82 break;
83 }
84 return true;
85 }
$cmd
Definition: sahs_server.php:35

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

+ Here is the call graph for this function:

◆ importScreen()

ilOrgUnitSimpleImportGUI::importScreen ( )

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

103 {
104 $form = $this->initForm("startImport");
105 $this->tpl->setContent($form->getHTML());
106 }

References initForm().

Referenced by executeCommand().

+ 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 109 of file class.ilOrgUnitSimpleImportGUI.php.

109 {
110 $form = new ilPropertyFormGUI();
111 $input = new ilFileInputGUI($this->lng->txt("import_xml_file"), "import_file");
112 $input->setRequired(true);
113 $input->setSuffixes(array('zip', 'xml'));
114 $form->addItem($input);
115 $form->setFormAction($this->ctrl->getFormAction($this));
116 $form->addCommandButton($submit_action, $this->lng->txt("import"));
117
118 return $form;
119 }
This class represents a file property in a property form.
This class represents a property form user interface.

Referenced by importScreen(), and startImport().

+ Here is the caller graph for this function:

◆ startImport()

ilOrgUnitSimpleImportGUI::startImport ( )

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

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

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

Referenced by executeCommand().

+ 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: