ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilOrgUnitSimpleImportGUI Class Reference

Class ilOrgUnitSimpleImportGUI. More...

+ Collaboration diagram for ilOrgUnitSimpleImportGUI:

Public Member Functions

 __construct ($parent_gui)
 executeCommand ()
 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

ilOrgUnitSimpleImportGUI::__construct (   $parent_gui)
Parameters
$parent_gui

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

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

{
global $tpl, $ilCtrl, $ilTabs, $ilToolbar, $lng, $ilAccess, $ilLog;
$this->tpl = $tpl;
$this->ctrl = $ilCtrl;
$this->parent_gui = $parent_gui;
$this->parent_object = $parent_gui->object;
$this->tabs_gui = $this->parent_gui->tabs_gui;
$this->toolbar = $ilToolbar;
$this->lng = $lng;
$this->ilAccess = $ilAccess;
$this->lng->loadLanguageModule('user');
$this->ilLog = $ilLog;
if (! $this->ilAccess->checkaccess("write", "", $this->parent_gui->object->getRefId())) {
ilUtil::sendFailure($this->lng->txt("permission_denied"), true);
}
}

+ Here is the call graph for this function:

Member Function Documentation

ilOrgUnitSimpleImportGUI::displayImportResults (   $importer)
Parameters
$importerilOrgUnitImporter

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

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

Referenced by startImport().

{
if (! $importer->hasErrors() && ! $importer->hasWarnings()) {
$stats = $importer->getStats();
ilUtil::sendSuccess(sprintf($this->lng->txt("import_successful"), $stats["created"], $stats["updated"], $stats["deleted"]), true);
}
if ($importer->hasWarnings()) {
$msg = $this->lng->txt("import_terminated_with_warnings") . " <br/>";
foreach ($importer->getWarnings() as $warning) {
$msg .= "-" . $this->lng->txt($warning["lang_var"]) . " (Import ID: " . $warning["import_id"] . ")<br>";
}
ilUtil::sendInfo($msg, true);
}
if ($importer->hasErrors()) {
$msg = $this->lng->txt("import_terminated_with_errors") . "<br/>";
foreach ($importer->getErrors() as $warning) {
$msg .= "- " . $this->lng->txt($warning["lang_var"]) . " (Import ID: " . $warning["import_id"] . ")<br>";
}
ilUtil::sendFailure($msg, true);
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilOrgUnitSimpleImportGUI::executeCommand ( )
Returns
bool

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

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

{
$cmd = $this->ctrl->getCmd();
switch ($cmd) {
case 'importScreen':
$this->importScreen();
break;
case 'startImport':
$this->startImport();
break;
}
return true;
}

+ Here is the call graph for this function:

ilOrgUnitSimpleImportGUI::importScreen ( )

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

References initForm().

Referenced by executeCommand().

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilOrgUnitSimpleImportGUI::initForm (   $submit_action)
protected

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

References ilFormPropertyGUI\setRequired().

Referenced by importScreen(), and startImport().

{
$form = new ilPropertyFormGUI();
$input = new ilFileInputGUI($this->lng->txt("import_xml_file"), "import_file");
$input->setRequired(true);
$input->setSuffixes(array('zip', 'xml'));
$form->addItem($input);
$form->setFormAction($this->ctrl->getFormAction($this));
$form->addCommandButton($submit_action, $this->lng->txt("import"));
return $form;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilOrgUnitSimpleImportGUI::startImport ( )

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

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

Referenced by executeCommand().

{
$form = $this->initForm("startImport");
if (! $form->checkInput()) {
$this->tpl->setContent($form->getHTML());
} else {
$file = $form->getInput("import_file");
$importer = new ilOrgUnitSimpleImport();
try {
$file_path = $file["tmp_name"];
$file_type = pathinfo($file["name"], PATHINFO_EXTENSION);
$file_name = pathinfo($file["name"], PATHINFO_FILENAME);
if($file_type == "zip") {
$extract_path = $file_path.'_extracted/';
$extracted_file = $extract_path.$file_name.'/manifest.xml';
$zip = new ZipArchive();
$res = $zip->open($file_path);
if ($res === true) {
$zip->extractTo($extract_path);
$zip->close();
if(file_exists($extracted_file)) {
$file_path = $extracted_file;
}
}
}
$importer->simpleImport($file_path);
} catch (Exception $e) {
$this->ilLog->write($e->getMessage() . " - " . $e->getTraceAsString());
ilUtil::sendFailure($this->lng->txt("import_failed"), true);
$this->ctrl->redirect($this, "render");
}
$this->displayImportResults($importer);
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Field Documentation

ilOrgUnitSimpleImportGUI::$ctrl
protected

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

ilOrgUnitSimpleImportGUI::$ilAccess
protected

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

Referenced by __construct().

ilOrgUnitSimpleImportGUI::$lng
protected

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

Referenced by __construct().

ilOrgUnitSimpleImportGUI::$parent_object
protected

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

ilOrgUnitSimpleImportGUI::$tabs_gui
protected

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

ilOrgUnitSimpleImportGUI::$toolbar
protected

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

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: