ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilOrgUnitSimpleImportGUI Class Reference

Class ilOrgUnitSimpleImportGUI. More...

+ Collaboration diagram for ilOrgUnitSimpleImportGUI:

Public Member Functions

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

Protected Member Functions

 initForm ($submit_action)
 

Protected Attributes

ilTabsGUI $tabs_gui
 
ilToolbarGUI $toolbar
 
ilCtrl $ctrl
 
ilGlobalTemplateInterface $tpl
 
ilObjectGUI $parent_gui
 
object $parent_object
 
ilLanguage $lng
 
ilAccessHandler $ilAccess
 
ILIAS DI LoggingServices $ilLog
 
ILIAS UI Factory $ui_factory
 
bool $may_create_orgus = false
 
bool $is_top_level_orgu = false
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilOrgUnitSimpleImportGUI::__construct ( ilObjectGUI  $parent_gui)

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

43 {
44 global $DIC;
45 $this->tpl = $DIC->ui()->mainTemplate();
46 $this->ctrl = $DIC->ctrl();
47 $this->parent_gui = $parent_gui;
48 $this->parent_object = $parent_gui->getObject();
49 $this->tabs_gui = $DIC->tabs();
50 $this->toolbar = $DIC->toolbar();
51 $this->lng = $DIC->language();
52 $this->ilAccess = $DIC->access();
53 $this->lng->loadLanguageModule('user');
54 $this->ilLog = $DIC->logger();
55 $this->ui_factory = $DIC['ui.factory'];
56
57 $this->may_create_orgus = $this->ilAccess->checkAccess("create_orgu", "", $this->parent_gui->getRefId(), 'orgu');
58 $this->is_top_level_orgu = ($this->parent_object->getRefId() == ilObjOrgUnit::getRootOrgRefId());
59
60 if (!$this->may_create_orgus) {
61 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("permission_denied"), true);
62 }
63 }
Class ilAccessHandler Checks access for ILIAS objects.
checkAccess(string $a_permission, string $a_cmd, int $a_ref_id, string $a_type="", ?int $a_obj_id=null, ?int $a_tree_id=null)
check access for an object (provide $a_type and $a_obj_id if available for better performance)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: class.ilLog.php:31
static getRootOrgRefId()
global $DIC
Definition: shib_login.php:26

References $DIC, $parent_gui, ilAccess\checkAccess(), ILIAS\Repository\ctrl(), ilObjectGUI\getObject(), ilObjOrgUnit\getRootOrgRefId(), ILIAS\Repository\lng(), and ILIAS\Repository\toolbar().

+ Here is the call graph for this function:

Member Function Documentation

◆ chooseImport()

ilOrgUnitSimpleImportGUI::chooseImport ( )

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

98 {
99 if (!$this->may_create_orgus || !$this->is_top_level_orgu) {
100 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("msg_no_perm_edit"));
101 $this->ctrl->redirectByClass('ilinfoscreengui', '');
102 }
103
104 $this->tabs_gui->setTabActive('view_content');
105 $this->tabs_gui->removeSubTab("page_editor");
106 $this->tabs_gui->removeSubTab("ordering"); // Mantis 0014728
107
108 if ($this->may_create_orgus && $this->is_top_level_orgu) {
109 $this->toolbar->addComponent(
110 $this->ui_factory->link()->standard(
111 $this->lng->txt('simple_import'),
112 $this->ctrl->getLinkTargetByClass("ilOrgUnitSimpleImportGUI", "importScreen")
113 )
114 );
115 $this->toolbar->addComponent(
116 $this->ui_factory->link()->standard(
117 $this->lng->txt('simple_user_import'),
118 $this->ctrl->getLinkTargetByClass("ilOrgUnitSimpleUserImportGUI", "userImportScreen")
119 )
120 );
121 }
122 }

References ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), and ILIAS\Repository\toolbar().

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

186 {
187 if (!$importer->hasErrors() && !$importer->hasWarnings()) {
188 $stats = $importer->getStats();
189 $this->tpl->setOnScreenMessage(
190 'success',
191 sprintf($this->lng->txt("import_successful"), $stats["created"], $stats["updated"], $stats["deleted"]),
192 true
193 );
194 }
195 if ($importer->hasWarnings()) {
196 $msg = $this->lng->txt("import_terminated_with_warnings") . " <br/>";
197 foreach ($importer->getWarnings() as $warning) {
198 $msg .= "-" . $this->lng->txt($warning["lang_var"]) . " (Import ID: " . $warning["import_id"] . ")<br />";
199 }
200 $this->tpl->setOnScreenMessage('info', $msg, true);
201 }
202 if ($importer->hasErrors()) {
203 $msg = $this->lng->txt("import_terminated_with_errors") . "<br/>";
204 foreach ($importer->getErrors() as $warning) {
205 $msg .= "- " . $this->lng->txt($warning["lang_var"]) . " (Import ID: " . $warning["import_id"] . ")<br />";
206 }
207 $this->tpl->setOnScreenMessage('failure', $msg, true);
208 }
209 }

References ILIAS\Repository\lng().

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

69 {
70 $cmd = $this->ctrl->getCmd();
71
72 switch ($cmd) {
73 case 'chooseImport':
74 $this->chooseImport();
75 break;
76 case 'importScreen':
77 $this->tabs_gui->clearTargets();
78 $this->tabs_gui->setBackTarget(
79 $this->lng->txt("back"),
80 $this->ctrl->getLinkTarget($this, 'chooseImport')
81 );
82 $this->importScreen();
83 break;
84 case 'startImport':
85 $this->tabs_gui->clearTargets();
86 $this->tabs_gui->setBackTarget(
87 $this->lng->txt("back"),
88 $this->ctrl->getLinkTarget($this, 'chooseImport')
89 );
90 $this->startImport();
91 break;
92 }
93
94 return true;
95 }

References chooseImport(), ILIAS\Repository\ctrl(), importScreen(), ILIAS\Repository\lng(), and startImport().

+ Here is the call graph for this function:

◆ importScreen()

ilOrgUnitSimpleImportGUI::importScreen ( )

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

125 {
126 $form = $this->initForm("startImport");
127 $this->tpl->setContent($form->getHTML());
128 }

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

131 {
132 $form = new ilPropertyFormGUI();
133 $input = new ilFileInputGUI($this->lng->txt("import_xml_file"), "import_file");
134 $input->setRequired(true);
135 $input->setSuffixes(array('zip', 'xml'));
136 $form->addItem($input);
137 $form->setFormAction($this->ctrl->getFormAction($this));
138 $form->addCommandButton($submit_action, $this->lng->txt("import"));
139
140 return $form;
141 }
This class represents a file property in a property form.
This class represents a property form user interface.

References ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

Referenced by importScreen(), and startImport().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ startImport()

ilOrgUnitSimpleImportGUI::startImport ( )

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

144 {
145 $form = $this->initForm("startImport");
146 if (!$form->checkInput()) {
147 $this->tpl->setContent($form->getHTML());
148 } else {
149 $file = $form->getInput("import_file");
150 $importer = new ilOrgUnitSimpleImport();
151 try {
152 $file_path = $file["tmp_name"];
153 $file_type = pathinfo($file["name"], PATHINFO_EXTENSION);
154 $file_name = pathinfo($file["name"], PATHINFO_FILENAME);
155
156 if ($file_type == "zip") {
157 $extract_path = $file_path . '_extracted/';
158 $extracted_file = $extract_path . $file_name . '/manifest.xml';
159
160 $zip = new ZipArchive();
161 $res = $zip->open($file_path);
162 if ($res === true) {
163 $zip->extractTo($extract_path);
164 $zip->close();
165
166 if (file_exists($extracted_file)) {
167 $file_path = $extracted_file;
168 }
169 }
170 }
171
172 $importer->simpleImport($file_path);
173 } catch (Exception $e) {
174 $this->ilLog->write($e->getMessage() . " - " . $e->getTraceAsString());
175 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("import_failed"), true);
176 $this->ctrl->redirect($this, "render");
177 }
178 $this->displayImportResults($importer);
179 }
180 }
write(string $a_msg, $a_log_level=null)
logging
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$res
Definition: ltiservices.php:69

References Vendor\Package\$e, $res, ILIAS\Repository\ctrl(), displayImportResults(), initForm(), ILIAS\Repository\lng(), 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

ilCtrl ilOrgUnitSimpleImportGUI::$ctrl
protected

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

◆ $ilAccess

ilAccessHandler ilOrgUnitSimpleImportGUI::$ilAccess
protected

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

◆ $ilLog

ILIAS DI LoggingServices ilOrgUnitSimpleImportGUI::$ilLog
protected

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

◆ $is_top_level_orgu

bool ilOrgUnitSimpleImportGUI::$is_top_level_orgu = false
protected

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

◆ $lng

ilLanguage ilOrgUnitSimpleImportGUI::$lng
protected

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

◆ $may_create_orgus

bool ilOrgUnitSimpleImportGUI::$may_create_orgus = false
protected

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

◆ $parent_gui

ilObjectGUI ilOrgUnitSimpleImportGUI::$parent_gui
protected

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

Referenced by __construct().

◆ $parent_object

object ilOrgUnitSimpleImportGUI::$parent_object
protected

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

◆ $tabs_gui

ilTabsGUI ilOrgUnitSimpleImportGUI::$tabs_gui
protected

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

◆ $toolbar

ilToolbarGUI ilOrgUnitSimpleImportGUI::$toolbar
protected

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

◆ $tpl

ilGlobalTemplateInterface ilOrgUnitSimpleImportGUI::$tpl
protected

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

◆ $ui_factory

ILIAS UI Factory ilOrgUnitSimpleImportGUI::$ui_factory
protected

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


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