/** * form for new survey object import */ function importFileObject() { global $tpl, $ilErr; $parent_id = $_GET["ref_id"]; $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()) { include_once "./Modules/Survey/classes/class.ilObjSurvey.php"; $newObj = new ilObjSurvey(); $newObj->setType($new_type); $newObj->setTitle("dummy"); $newObj->setDescription("dummy"); $newObj->create(true); $this->putObjectInTree($newObj); // copy uploaded file to import directory $error = $newObj->importObject($_FILES["importfile"], $form->getInput("spl")); if (strlen($error)) { $newObj->delete(); $this->ilias->raiseError($error, $this->ilias->error_obj->MESSAGE); return; } ilUtil::sendSuccess($this->lng->txt("object_imported"), true); ilUtil::redirect("ilias.php?ref_id=" . $newObj->getRefId() . "&baseClass=ilObjSurveyGUI"); // using template? include_once "Services/Administration/classes/class.ilSettingsTemplate.php"; $templates = ilSettingsTemplate::getAllSettingsTemplates("svy"); if ($templates) { global $tpl; $tpl->addJavaScript("./Modules/Scorm2004/scripts/questions/jquery.js"); // $tpl->addJavaScript("./Modules/Scorm2004/scripts/questions/jquery-ui-min.js"); $this->tpl->setCurrentBlock("template_option"); $this->tpl->setVariable("VAL_TEMPLATE_OPTION", ""); $this->tpl->setVariable("TXT_TEMPLATE_OPTION", $this->lng->txt("none")); $this->tpl->parseCurrentBlock(); foreach ($templates as $item) { $this->tpl->setCurrentBlock("template_option"); $this->tpl->setVariable("VAL_TEMPLATE_OPTION", $item["id"]); $this->tpl->setVariable("TXT_TEMPLATE_OPTION", $item["title"]); $this->tpl->parseCurrentBlock(); $desc = str_replace("\n", "", nl2br($item["description"])); $desc = str_replace("\r", "", $desc); $this->tpl->setCurrentBlock("js_data"); $this->tpl->setVariable("JS_DATA_ID", $item["id"]); $this->tpl->setVariable("JS_DATA_TEXT", $desc); $this->tpl->parseCurrentBlock(); } $this->tpl->setCurrentBlock("templates"); $this->tpl->setVariable("TXT_TEMPLATE", $this->lng->txt("svy_settings_template")); $this->tpl->parseCurrentBlock(); } } // display form to correct errors $form->setValuesByPost(); $tpl->setContent($form->getHtml()); }