/** * display status information or report errors messages * in case of error * * @access public */ function uploadObject() { global $_FILES, $rbacsystem; include_once 'Services/FileSystem/classes/class.ilUploadFiles.php'; // check create permission if (!$rbacsystem->checkAccess("create", $_GET["ref_id"], "sahs")) { $this->ilias->raiseError($this->lng->txt("no_create_permission"), $this->ilias->error_obj->WARNING); } elseif ($_FILES["scormfile"]["name"]) { // check if file was uploaded $source = $_FILES["scormfile"]["tmp_name"]; if ($source == 'none' || !$source) { $this->ilias->raiseError($this->lng->txt("msg_no_file"), $this->ilias->error_obj->MESSAGE); } // get_cfg_var("upload_max_filesize"); // get the may filesize form t he php.ini switch ($__FILES["scormfile"]["error"]) { case UPLOAD_ERR_INI_SIZE: $this->ilias->raiseError($this->lng->txt("err_max_file_size_exceeds"), $this->ilias->error_obj->MESSAGE); break; case UPLOAD_ERR_FORM_SIZE: $this->ilias->raiseError($this->lng->txt("err_max_file_size_exceeds"), $this->ilias->error_obj->MESSAGE); break; case UPLOAD_ERR_PARTIAL: $this->ilias->raiseError($this->lng->txt("err_partial_file_upload"), $this->ilias->error_obj->MESSAGE); break; case UPLOAD_ERR_NO_FILE: $this->ilias->raiseError($this->lng->txt("err_no_file_uploaded"), $this->ilias->error_obj->MESSAGE); break; } $file = pathinfo($_FILES["scormfile"]["name"]); } elseif ($_POST["uploaded_file"]) { // check if the file is in the upload directory and readable if (!ilUploadFiles::_checkUploadFile($_POST["uploaded_file"])) { $this->ilias->raiseError($this->lng->txt("upload_error_file_not_found"), $this->ilias->error_obj->MESSAGE); } $file = pathinfo($_POST["uploaded_file"]); } else { $this->ilias->raiseError($this->lng->txt("msg_no_file"), $this->ilias->error_obj->MESSAGE); } $name = substr($file["basename"], 0, strlen($file["basename"]) - strlen($file["extension"]) - 1); if ($name == "") { $name = $this->lng->txt("no_title"); } // create and insert object in objecttree switch ($_POST["sub_type"]) { case "scorm2004": include_once "./Modules/Scorm2004/classes/class.ilObjSCORM2004LearningModule.php"; $newObj = new ilObjSCORM2004LearningModule(); $newObj->setEditable($_POST["editable"] == 'y'); $newObj->setImportSequencing($_POST["import_sequencing"]); $newObj->setSequencingExpertMode($_POST["import_sequencing"]); break; case "scorm": include_once "./Modules/ScormAicc/classes/class.ilObjSCORMLearningModule.php"; $newObj = new ilObjSCORMLearningModule(); break; case "aicc": include_once "./Modules/ScormAicc/classes/class.ilObjAICCLearningModule.php"; $newObj = new ilObjAICCLearningModule(); break; case "hacp": include_once "./Modules/ScormAicc/classes/class.ilObjHACPLearningModule.php"; $newObj = new ilObjHACPLearningModule(); break; } $newObj->setTitle($name); $newObj->setSubType($_POST["sub_type"]); $newObj->setDescription(""); $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()); // create data directory, copy file to directory $newObj->createDataDirectory(); if ($_FILES["scormfile"]["name"]) { // copy uploaded file to data directory $file_path = $newObj->getDataDirectory() . "/" . $_FILES["scormfile"]["name"]; ilUtil::moveUploadedFile($_FILES["scormfile"]["tmp_name"], $_FILES["scormfile"]["name"], $file_path); } else { // copy uploaded file to data directory $file_path = $newObj->getDataDirectory() . "/" . $_POST["uploaded_file"]; ilUploadFiles::_copyUploadFile($_POST["uploaded_file"], $file_path); } ilUtil::unzip($file_path); ilUtil::renameExecutables($newObj->getDataDirectory()); $title = $newObj->readObject(); if ($title != "") { ilObject::_writeTitle($newObj->getId(), $title); /*$md = new ilMD($newObj->getId(),0, $newObj->getType()); if(is_object($md_gen = $md->getGeneral())) { $md_gen->setTitle($title); $md_gen->update(); }*/ } //auto set learning progress settings switch ($_POST["sub_type"]) { case "scorm2004": case "scorm": $newObj->setLearningProgressSettingsAtUpload(); break; } ilUtil::sendInfo($this->lng->txt($newObj->getType() . "_added"), true); ilUtil::redirect("ilias.php?baseClass=ilSAHSEditGUI&ref_id=" . $newObj->getRefId()); }