/** * display status information or report errors messages * in case of error * * @access public */ function importFileObject() { $new_type = $_REQUEST["new_type"]; // create permission is already checked in createObject. This check here is done to prevent hacking attempts if (!$this->checkPermissionBool("create", "", $new_type)) { $ilErr->raiseError($this->lng->txt("no_create_permission")); } $this->lng->loadLanguageModule($new_type); $this->ctrl->setParameter($this, "new_type", $new_type); $form = $this->initImportForm($new_type); if ($form->checkInput()) { $this->ctrl->setParameter($this, "new_type", ""); $upload = $_FILES["importfile"]; // create and insert object in objecttree include_once "./Modules/Glossary/classes/class.ilObjGlossary.php"; $newObj = new ilObjGlossary(); $newObj->setType($new_type); $newObj->setTitle($upload["name"]); $newObj->create(true); $this->putObjectInTree($newObj); // create import directory $newObj->createImportDirectory(); // copy uploaded file to import directory $file = pathinfo($upload["name"]); $full_path = $newObj->getImportDirectory() . "/" . $upload["name"]; ilUtil::moveUploadedFile($upload["tmp_name"], $upload["name"], $full_path); // unzip file ilUtil::unzip($full_path); // determine filename of xml file $subdir = basename($file["basename"], "." . $file["extension"]); $xml_file = $newObj->getImportDirectory() . "/" . $subdir . "/" . $subdir . ".xml"; // check whether this is a new export file. // this is the case if manifest.xml exits //echo "1-".$newObj->getImportDirectory()."/".$subdir."/manifest.xml"."-"; if (is_file($newObj->getImportDirectory() . "/" . $subdir . "/manifest.xml")) { include_once "./Services/Export/classes/class.ilImport.php"; $imp = new ilImport((int) $_GET["ref_id"]); $map = $imp->getMapping(); $map->addMapping("Modules/Glossary", "glo", "new_id", $newObj->getId()); $imp->importObject($newObj, $full_path, $upload["name"], "glo", "Modules/Glossary", true); ilUtil::sendSuccess($this->lng->txt("glo_added"), true); ilUtil::redirect("ilias.php?baseClass=ilGlossaryEditorGUI&ref_id=" . $newObj->getRefId()); } // check whether subdirectory exists within zip file if (!is_dir($newObj->getImportDirectory() . "/" . $subdir)) { $this->ilias->raiseError(sprintf($this->lng->txt("cont_no_subdir_in_zip"), $subdir), $this->ilias->error_obj->MESSAGE); } // check whether xml file exists within zip file if (!is_file($xml_file)) { $this->ilias->raiseError(sprintf($this->lng->txt("cont_zip_file_invalid"), $subdir . "/" . $subdir . ".xml"), $this->ilias->error_obj->MESSAGE); } include_once "./Modules/LearningModule/classes/class.ilContObjParser.php"; $contParser = new ilContObjParser($newObj, $xml_file, $subdir); $contParser->startParsing(); ilObject::_writeImportId($newObj->getId(), $newObj->getImportId()); // delete import directory ilUtil::delDir($newObj->getImportDirectory()); ilUtil::sendSuccess($this->lng->txt("glo_added"), true); ilUtil::redirect("ilias.php?baseClass=ilGlossaryEditorGUI&ref_id=" . $newObj->getRefId()); } // display form to correct errors $form->setValuesByPost(); $tpl->setContent($form->getHtml()); }
/** * Save glossary form */ public function saveGlossary() { global $tpl, $lng, $ilCtrl, $rbacsystem, $tree; $parent_ref_id = $tree->getParentId((int) $_GET["ref_id"]); if (!$rbacsystem->checkAccess("create", $parent_ref_id, "glo")) { ilUtil::sendFailure($lng->txt("no_permission"), true); $ilCtrl->redirect($this, "properties"); } $this->initGlossaryCreationForm(); if ($this->form->checkInput()) { include_once "./Modules/Glossary/classes/class.ilObjGlossary.php"; $newObj = new ilObjGlossary(); $newObj->setType("glo"); $newObj->setTitle($_POST["title"]); $newObj->setDescription($_POST["description"]); $newObj->setVirtualMode("none"); $newObj->create(); $newObj->createReference(); $newObj->putInTree($parent_ref_id); $newObj->setPermissions($parent_ref_id); $newObj->notify("new", $parent_ref_id, $_GET["parent_non_rbac_id"], $parent_ref_id, $newObj->getRefId()); // perform save $this->object->setAssignedGlossary($newObj->getId()); $this->object->update(); ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true); $ilCtrl->redirect($this, "properties"); } $this->form->setValuesByPost(); $tpl->setContent($this->form->getHtml()); }
function importGlossary($slm, $packageFolder) { global $ilias; // create and insert object in objecttree include_once "./Modules/Glossary/classes/class.ilObjGlossary.php"; $newObj = new ilObjGlossary(); $newObj->setType('glo'); $newObj->setTitle(''); $newObj->create(true); $newObj->createReference(); $newObj->putInTree($_GET["ref_id"]); $newObj->setPermissions($_GET["ref_id"]); $newObj->notify("new", $_GET["ref_id"], $_GET["parent_non_rbac_id"], $_GET["ref_id"], $newObj->getRefId()); $xml_file = $packageFolder . "/glossary.xml"; // check whether xml file exists within zip file if (!is_file($xml_file)) { return; } include_once "./Modules/LearningModule/classes/class.ilContObjParser.php"; $contParser = new ilContObjParser($newObj, $xml_file, $packageFolder); $contParser->startParsing(); $newObj->update(); //ilObject::_writeImportId($newObj->getId(), $newObj->getImportId()); $slm->setAssignedGlossary($newObj->getId()); $slm->update(); }