/**
  * Build export file
  *
  * @param
  * @return
  */
 function buildExportFile()
 {
     global $ilias;
     // create export file
     include_once "./Services/Export/classes/class.ilExport.php";
     ilExport::_createExportDirectory($this->wiki->getId(), "html", "wiki");
     $exp_dir = ilExport::_getExportDirectory($this->wiki->getId(), "html", "wiki");
     $this->subdir = $this->wiki->getType() . "_" . $this->wiki->getId();
     $this->export_dir = $exp_dir . "/" . $this->subdir;
     // initialize temporary target directory
     ilUtil::delDir($this->export_dir);
     ilUtil::makeDir($this->export_dir);
     // system style html exporter
     include_once "./Services/Style/classes/class.ilSystemStyleHTMLExport.php";
     $this->sys_style_html_export = new ilSystemStyleHTMLExport($this->export_dir);
     $this->sys_style_html_export->addImage("icon_wiki.svg");
     $this->sys_style_html_export->export();
     // init co page html exporter
     include_once "./Services/COPage/classes/class.ilCOPageHTMLExport.php";
     $this->co_page_html_export = new ilCOPageHTMLExport($this->export_dir);
     $this->co_page_html_export->setContentStyleId($this->wiki->getStyleSheetId());
     $this->co_page_html_export->createDirectories();
     $this->co_page_html_export->exportStyles();
     $this->co_page_html_export->exportSupportScripts();
     // export pages
     $this->exportHTMLPages();
     // zip everything
     if (true) {
         // zip it all
         $date = time();
         $zip_file = ilExport::_getExportDirectory($this->wiki->getId(), "html", "wiki") . "/" . $date . "__" . IL_INST_ID . "__" . $this->wiki->getType() . "_" . $this->wiki->getId() . ".zip";
         ilUtil::zip($this->export_dir, $zip_file);
         ilUtil::delDir($this->export_dir);
     }
 }
    /**
     * delete SCORM learning module and all related data	
     *
     * this method has been tested on may 9th 2004
     * meta data, scorm lm data, scorm tree, scorm objects (organization(s),
     * manifest, resources and items), tracking data and data directory
     * have been deleted correctly as desired
     *
     * @access	public
     * @return	boolean	true if all object data were removed; false if only a references were removed
     */
    function delete()
    {
        global $ilDB, $ilLog;
        // always call parent delete function first!!
        if (!parent::delete()) {
            return false;
        }
        // delete meta data of scorm content object
        /*
        		$nested = new ilNestedSetXML();
        		$nested->init($this->getId(), $this->getType());
        		$nested->deleteAllDBData();
        */
        $this->deleteMetaData();
        // delete data directory
        ilUtil::delDir($this->getDataDirectory());
        // delete scorm learning module record
        $ilDB->manipulateF('DELETE FROM sahs_lm WHERE id = %s', array('integer'), array($this->getId()));
        // delete aicc data
        $res = $ilDB->queryF('
			SELECT * FROM aicc_object, aicc_units
			WHERE aicc_object.obj_id = aicc_units.obj_id
			AND aicc_object.slm_id = %s', array('integer'), array($this->getId()));
        while ($row = $ilDB->fetchAssoc($res)) {
            $obj_id = $row['obj_id'];
            $ilDB->manipulateF('
					DELETE FROM aicc_units WHERE obj_id = %s', array('integer'), array($obj_id));
        }
        $res = $ilDB->queryF('
			SELECT * FROM aicc_object, aicc_course
			WHERE aicc_object.obj_id = aicc_course.obj_id
			AND aicc_object.slm_id = %s', array('integer'), array($this->getId()));
        while ($row = $ilDB->fetchAssoc($res)) {
            $obj_id = $row['obj_id'];
            $ilDB->manipulateF('
				DELETE FROM aicc_course WHERE obj_id = %s', array('integer'), array($obj_id));
        }
        $ilDB->manipulateF('DELETE FROM scorm_tree WHERE slm_id = %s', array('integer'), array($this->getId()));
        $ilDB->manipulateF('DELETE FROM aicc_object WHERE slm_id = %s', array('integer'), array($this->getId()));
        $q_log = "DELETE FROM scorm_tracking WHERE obj_id = " . $ilDB->quote($this->getId());
        $ilLog->write("SAHS Delete (AICC LM): " . $q_log);
        $ilDB->manipulateF('DELETE FROM scorm_tracking WHERE obj_id = %s', array('integer'), array($this->getId()));
        $q_log = "DELETE FROM sahs_user WHERE obj_id = " . $ilDB->quote($this->getId());
        $ilLog->write("SAHS Delete (AICC LM): " . $q_log);
        $ilDB->manipulateF('DELETE FROM sahs_user WHERE obj_id = %s', array('integer'), array($this->getId()));
        // update learning progress status
        include_once "./Services/Tracking/classes/class.ilLPStatusWrapper.php";
        ilLPStatusWrapper::_refreshStatus($this->getId());
        // always call parent delete function at the end!!
        return true;
    }
 /**
  * Build export file
  *
  * @param
  * @return
  */
 function buildExportFile()
 {
     global $ilias;
     // create export file
     include_once "./Services/Export/classes/class.ilExport.php";
     ilExport::_createExportDirectory($this->object->getId(), "html", "prtf");
     $exp_dir = ilExport::_getExportDirectory($this->object->getId(), "html", "prtf");
     $this->subdir = $this->object->getType() . "_" . $this->object->getId();
     $this->export_dir = $exp_dir . "/" . $this->subdir;
     // initialize temporary target directory
     ilUtil::delDir($this->export_dir);
     ilUtil::makeDir($this->export_dir);
     // system style html exporter
     include_once "./Services/Style/classes/class.ilSystemStyleHTMLExport.php";
     $this->sys_style_html_export = new ilSystemStyleHTMLExport($this->export_dir);
     // $this->sys_style_html_export->addImage("icon_prtf_b.png");
     $this->sys_style_html_export->export();
     // init co page html exporter
     include_once "./Services/COPage/classes/class.ilCOPageHTMLExport.php";
     $this->co_page_html_export = new ilCOPageHTMLExport($this->export_dir);
     /* $this->co_page_html_export->setContentStyleId(
     			$this->object->getStyleSheetId()); */
     $this->co_page_html_export->createDirectories();
     $this->co_page_html_export->exportStyles();
     $this->co_page_html_export->exportSupportScripts();
     // banner / profile picture
     $prfa_set = new ilSetting("prfa");
     if ($prfa_set->get("banner")) {
         $banner = $this->object->getImageFullPath();
         copy($banner, $this->export_dir . "/" . basename($banner));
     }
     $ppic = ilObjUser::_getPersonalPicturePath($this->object->getOwner(), "big");
     if ($ppic) {
         $ppic = array_shift(explode("?", $ppic));
         copy($ppic, $this->export_dir . "/" . basename($ppic));
     }
     // export pages
     $this->exportHTMLPages();
     // zip everything
     if (true) {
         // zip it all
         $date = time();
         $zip_file = ilExport::_getExportDirectory($this->object->getId(), "html", "prtf") . "/" . $date . "__" . IL_INST_ID . "__" . $this->object->getType() . "_" . $this->object->getId() . ".zip";
         ilUtil::zip($this->export_dir, $zip_file);
         ilUtil::delDir($this->export_dir);
     }
     return $zip_file;
 }
 /**
  * Export a container
  * 
  * @param object $a_type
  * @param object $a_obj_id
  * @param object $a_target_release
  * @return 
  */
 public function exportObject($a_type, $a_id, $a_target_release)
 {
     // Create base export directory
     ilExport::_createExportDirectory($a_id, "xml", $a_type);
     $export_dir = ilExport::_getExportDirectory($a_id, "xml", $a_type);
     $ts = time();
     $sub_dir = $ts . "__" . IL_INST_ID . "__" . $a_type . "_" . $a_id;
     $this->cont_export_dir = $export_dir . DIRECTORY_SEPARATOR . $sub_dir;
     ilUtil::makeDirParents($this->cont_export_dir);
     $GLOBALS['ilLog']->write(__METHOD__ . ' using base directory: ' . $this->export_run_dir);
     $this->manifestWriterBegin($a_type, $a_id, $a_target_release);
     $this->addContainer();
     $this->addSubitems($a_id, $a_type, $a_target_release);
     $this->manifestWriterEnd($a_type, $a_id, $a_target_release);
     ilUtil::zip($this->cont_export_dir, $this->cont_export_dir . '.zip');
     ilUtil::delDir($this->cont_export_dir);
 }
 /**
  * delete object file
  */
 function deleteFile()
 {
     global $lng;
     if (!isset($_POST["file"])) {
         $this->ilias->raiseError($this->lng->txt("no_checkbox"), $this->ilias->error_obj->MESSAGE);
     }
     foreach ($_POST["file"] as $post_file) {
         if (ilUtil::stripSlashes($post_file) == "..") {
             $this->ilias->raiseError($this->lng->txt("no_checkbox"), $this->ilias->error_obj->MESSAGE);
             break;
         }
         $cur_subdir = str_replace(".", "", ilUtil::stripSlashes($_GET["cdir"]));
         $cur_dir = !empty($cur_subdir) ? $this->main_dir . "/" . $cur_subdir : $this->main_dir;
         $file = $cur_dir . "/" . ilUtil::stripSlashes($post_file);
         if (@is_file($file)) {
             unlink($file);
         }
         if (@is_dir($file)) {
             $is_dir = true;
             ilUtil::delDir($file);
         }
     }
     $this->ctrl->saveParameter($this, "cdir");
     if ($is_dir) {
         ilUtil::sendSuccess($lng->txt("cont_dir_deleted"), true);
         $this->setPerformedCommand("delete_dir", array("name" => ilUtil::stripSlashes($post_file)));
     } else {
         ilUtil::sendSuccess($lng->txt("cont_file_deleted"), true);
         $this->setPerformedCommand("delete_file", array("name" => ilUtil::stripSlashes($post_file)));
     }
     $this->ctrl->redirect($this, "listFiles");
 }
Exemple #6
0
 /**
  * Import repository object export file
  *
  * @param	string		absolute filename of temporary upload file
  */
 public final function importObject($a_new_obj, $a_tmp_file, $a_filename, $a_type, $a_comp = "", $a_copy_file = false)
 {
     // create temporary directory
     $tmpdir = ilUtil::ilTempnam();
     ilUtil::makeDir($tmpdir);
     if ($a_copy_file) {
         copy($a_tmp_file, $tmpdir . "/" . $a_filename);
     } else {
         ilUtil::moveUploadedFile($a_tmp_file, $a_filename, $tmpdir . "/" . $a_filename);
     }
     ilUtil::unzip($tmpdir . "/" . $a_filename);
     $dir = $tmpdir . "/" . substr($a_filename, 0, strlen($a_filename) - 4);
     $GLOBALS['ilLog']->write(__METHOD__ . ': do import with dir ' . $dir);
     $new_id = $this->doImportObject($dir, $a_type, $a_comp, $tmpdir);
     // delete temporary directory
     ilUtil::delDir($tmpdir);
     return $new_id;
 }
 function _deleteAll($a_obj_id)
 {
     ilUtil::delDir(CLIENT_DATA_DIR . '/' . GROUP_PATH . '/grp_' . $a_obj_id);
     return true;
 }
 function deleteQuestionpool()
 {
     $questions =& $this->getAllQuestions();
     if (count($questions)) {
         foreach ($questions as $question_id) {
             $this->deleteQuestion($question_id);
         }
     }
     // delete export files
     include_once "./Services/Utilities/classes/class.ilUtil.php";
     $qpl_data_dir = ilUtil::getDataDir() . "/qpl_data";
     $directory = $qpl_data_dir . "/qpl_" . $this->getId();
     if (is_dir($directory)) {
         include_once "./Services/Utilities/classes/class.ilUtil.php";
         ilUtil::delDir($directory);
     }
 }
 /**
  * build xml export file
  */
 function buildExportFileXML()
 {
     global $ilBench;
     $ilBench->start("SurveyExport", "buildExportFile");
     // create directories
     $this->survey_obj->createExportDirectory();
     include_once "./Services/Utilities/classes/class.ilUtil.php";
     ilUtil::makeDir($this->export_dir . "/" . $this->subdir);
     ilUtil::makeDir($this->export_dir . "/" . $this->subdir . "/objects");
     // get Log File
     $expDir = $this->survey_obj->getExportDirectory();
     include_once "./Services/Logging/classes/class.ilLog.php";
     $expLog = new ilLog($expDir, "export.log");
     $expLog->delete();
     $expLog->setLogFormat("");
     $expLog->write(date("[y-m-d H:i:s] ") . "Start Export");
     // write xml file
     $xmlFile = fopen($this->export_dir . "/" . $this->subdir . "/" . $this->filename, "w");
     fwrite($xmlFile, $this->survey_obj->toXML());
     fclose($xmlFile);
     // add media objects which were added with tiny mce
     $this->exportXHTMLMediaObjects($this->export_dir . "/" . $this->subdir);
     // zip the file
     $ilBench->start("SurveyExport", "buildExportFileXML_zipFile");
     ilUtil::zip($this->export_dir . "/" . $this->subdir, $this->export_dir . "/" . $this->subdir . ".zip");
     $ilBench->stop("SurveyExport", "buildExportFileXML_zipFile");
     if (@file_exists($this->export_dir . "/" . $this->subdir . ".zip")) {
         // remove export directory and contents
         if (@is_dir($this->export_dir . "/" . $this->subdir)) {
             ilUtil::delDir($this->export_dir . "/" . $this->subdir);
         }
     }
     $expLog->write(date("[y-m-d H:i:s] ") . "Finished Export");
     $ilBench->stop("SurveyExport", "buildExportFile");
     return $this->export_dir . "/" . $this->subdir . ".zip";
 }
 public function downloadFolder()
 {
     global $lng, $rbacsystem, $ilAccess;
     include_once "./Services/Utilities/classes/class.ilUtil.php";
     include_once 'Modules/File/classes/class.ilObjFile.php';
     include_once 'Modules/File/classes/class.ilFileException.php';
     if (!$ilAccess->checkAccess("read", "", $this->getRefId())) {
         $this->ilErr->raiseError(get_class($this) . "::downloadFolder(): missing read permission!", $this->ilErr->WARNING);
     }
     if (ilObject::_isInTrash($this->getRefId())) {
         $this->ilErr->raiseError(get_class($this) . "::downloadFolder(): object is trashed!", $this->ilErr->WARNING);
     }
     $zip = PATH_TO_ZIP;
     $tmpdir = ilUtil::ilTempnam();
     ilUtil::makeDir($tmpdir);
     $basename = ilUtil::getAsciiFilename($this->getTitle());
     $deliverFilename = $basename . ".zip";
     $zipbasedir = $tmpdir . DIRECTORY_SEPARATOR . $basename;
     $tmpzipfile = $tmpdir . DIRECTORY_SEPARATOR . $deliverFilename;
     try {
         ilObjFolder::recurseFolder($this->getRefId(), $this->getTitle(), $tmpdir);
         ilUtil::zip($zipbasedir, $tmpzipfile);
         rename($tmpzipfile, $zipfile = ilUtil::ilTempnam());
         ilUtil::delDir($tmpdir);
         ilUtil::deliverFile($zipfile, $deliverFilename, '', false, true);
     } catch (ilFileException $e) {
         ilUtil::sendInfo($e->getMessage(), true);
     }
 }
 /**
  * Delete files
  */
 public function delete()
 {
     /**
      * @var $lng ilLanguage
      * @var $ilCtrl ilCtrl
      */
     global $lng, $ilCtrl;
     $export_dir = $this->obj->getExportDirectory();
     foreach ($_POST['file'] as $file) {
         $exp_file = $export_dir . '/' . $file;
         $exp_dir = $export_dir . '/' . substr($file, 0, strlen($file) - 4);
         if (@is_file($exp_file)) {
             unlink($exp_file);
         }
         if (@is_dir($exp_dir)) {
             ilUtil::delDir($exp_dir);
         }
     }
     ilUtil::sendSuccess($lng->txt('msg_deleted_export_files'), true);
     $ilCtrl->redirect($this, 'listExportFiles');
 }
 /**
  * imports question(s) into the questionpool (after verification)
  */
 function importVerifiedFileObject()
 {
     if ($_POST["questions_only"] == 1) {
         $newObj =& $this->object;
     } else {
         include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
         // create new questionpool object
         $newObj = new ilObjQuestionPool(0, true);
         // set type of questionpool object
         $newObj->setType($_GET["new_type"]);
         // set title of questionpool object to "dummy"
         $newObj->setTitle("dummy");
         // set description of questionpool object
         $newObj->setDescription("questionpool import");
         // create the questionpool class in the ILIAS database (object_data table)
         $newObj->create(true);
         // create a reference for the questionpool object in the ILIAS database (object_reference table)
         $newObj->createReference();
         // put the questionpool object in the administration tree
         $newObj->putInTree($_GET["ref_id"]);
         // get default permissions and set the permissions for the questionpool object
         $newObj->setPermissions($_GET["ref_id"]);
         // notify the questionpool object and all its parent objects that a "new" object was created
         $newObj->notify("new", $_GET["ref_id"], $_GET["parent_non_rbac_id"], $_GET["ref_id"], $newObj->getRefId());
     }
     // start parsing of QTI files
     include_once "./Services/QTI/classes/class.ilQTIParser.php";
     $qtiParser = new ilQTIParser($_SESSION["qpl_import_qti_file"], IL_MO_PARSE_QTI, $newObj->getId(), $_POST["ident"]);
     $result = $qtiParser->startParsing();
     // import page data
     if (strlen($_SESSION["qpl_import_xml_file"])) {
         include_once "./Modules/LearningModule/classes/class.ilContObjParser.php";
         $contParser = new ilContObjParser($newObj, $_SESSION["qpl_import_xml_file"], $_SESSION["qpl_import_subdir"]);
         $contParser->setQuestionMapping($qtiParser->getImportMapping());
         $contParser->startParsing();
     }
     // set another question pool name (if possible)
     $qpl_name = $_POST["qpl_new"];
     if (strcmp($qpl_name, $newObj->getTitle()) != 0 && strlen($qpl_name) > 0) {
         $newObj->setTitle($qpl_name);
         $newObj->update();
     }
     // delete import directory
     include_once "./Services/Utilities/classes/class.ilUtil.php";
     ilUtil::delDir(dirname(ilObjQuestionPool::_getImportDirectory()));
     if ($_POST["questions_only"] == 1) {
         $this->ctrl->redirect($this, "questions");
     } else {
         ilUtil::sendSuccess($this->lng->txt("object_imported"), true);
         ilUtil::redirect("ilias.php?ref_id=" . $newObj->getRefId() . "&baseClass=ilObjQuestionPoolGUI");
     }
 }
 /**
  * delete media object
  */
 function delete()
 {
     if (!($this->getId() > 0)) {
         return;
     }
     $usages = $this->getUsages();
     if (count($usages) == 0) {
         // remove directory
         ilUtil::delDir(ilObjMediaObject::_getDirectory($this->getId()));
         // remove thumbnail directory
         ilUtil::delDir(ilObjMediaObject::_getThumbnailDirectory($this->getId()));
         // delete meta data of mob
         $this->deleteMetaData();
         // delete media items
         ilMediaItem::deleteAllItemsOfMob($this->getId());
         // this is just to make sure, there should be no entries left at
         // this point as they depend on the usage
         self::handleQuotaUpdate($this);
         // delete object
         parent::delete();
     }
 }
 /**
  * Imports a survey from XML into the ILIAS database
  *
  * @return boolean True, if the import succeeds, false otherwise
  * @access public
  */
 function importObject($file_info, $svy_qpl_id)
 {
     if ($svy_qpl_id < 1) {
         $svy_qpl_id = -1;
     }
     // check if file was uploaded
     $source = $file_info["tmp_name"];
     $error = "";
     if ($source == 'none' || !$source || $file_info["error"] > UPLOAD_ERR_OK) {
         $error = $this->lng->txt("import_no_file_selected");
     }
     // check correct file type
     $isXml = FALSE;
     $isZip = FALSE;
     if (strcmp($file_info["type"], "text/xml") == 0 || strcmp($file_info["type"], "application/xml") == 0) {
         $isXml = TRUE;
     }
     // too many different mime-types, so we use the suffix
     $suffix = pathinfo($file_info["name"]);
     if (strcmp(strtolower($suffix["extension"]), "zip") == 0) {
         $isZip = TRUE;
     }
     if (!$isXml && !$isZip) {
         $error = $this->lng->txt("import_wrong_file_type");
         global $ilLog;
         $ilLog->write("Survey: Import error. Filetype was \"" . $file_info["type"] . "\"");
     }
     if (strlen($error) == 0) {
         // import file as a survey
         $import_dir = $this->getImportDirectory();
         $import_subdir = "";
         $importfile = "";
         include_once "./Services/Utilities/classes/class.ilUtil.php";
         if ($isZip) {
             $importfile = $import_dir . "/" . $file_info["name"];
             ilUtil::moveUploadedFile($source, $file_info["name"], $importfile);
             ilUtil::unzip($importfile);
             $found = $this->locateImportFiles($import_dir);
             if (!(strlen($found["dir"]) > 0 && strlen($found["xml"]) > 0)) {
                 $error = $this->lng->txt("wrong_import_file_structure");
                 return $error;
             }
             $importfile = $found["xml"];
             $import_subdir = $found["dir"];
         } else {
             $importfile = tempnam($import_dir, "survey_import");
             ilUtil::moveUploadedFile($source, $file_info["name"], $importfile);
         }
         $fh = fopen($importfile, "r");
         if (!$fh) {
             $error = $this->lng->txt("import_error_opening_file");
             return $error;
         }
         $xml = fread($fh, filesize($importfile));
         $result = fclose($fh);
         if (!$result) {
             $error = $this->lng->txt("import_error_closing_file");
             return $error;
         }
         unset($_SESSION["import_mob_xhtml"]);
         if (strpos($xml, "questestinterop")) {
             include_once "./Services/Survey/classes/class.SurveyImportParserPre38.php";
             $import = new SurveyImportParserPre38($svy_qpl_id, "", TRUE);
             $import->setSurveyObject($this);
             $import->setXMLContent($xml);
             $import->startParsing();
         } else {
             include_once "./Services/Survey/classes/class.SurveyImportParser.php";
             $import = new SurveyImportParser($svy_qpl_id, "", TRUE);
             $import->setSurveyObject($this);
             $import->setXMLContent($xml);
             $import->startParsing();
         }
         if (is_array($_SESSION["import_mob_xhtml"])) {
             include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
             include_once "./Services/RTE/classes/class.ilRTE.php";
             include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
             foreach ($_SESSION["import_mob_xhtml"] as $mob) {
                 $importfile = $import_subdir . "/" . $mob["uri"];
                 if (file_exists($importfile)) {
                     $media_object =& ilObjMediaObject::_saveTempFileAsMediaObject(basename($importfile), $importfile, FALSE);
                     ilObjMediaObject::_saveUsage($media_object->getId(), "svy:html", $this->getId());
                     $this->setIntroduction(str_replace("src=\"" . $mob["mob"] . "\"", "src=\"" . "il_" . IL_INST_ID . "_mob_" . $media_object->getId() . "\"", $this->getIntroduction()));
                     $this->setOutro(str_replace("src=\"" . $mob["mob"] . "\"", "src=\"" . "il_" . IL_INST_ID . "_mob_" . $media_object->getId() . "\"", $this->getOutro()));
                 } else {
                     global $ilLog;
                     $ilLog->write("Error: Could not open XHTML mob file for test introduction during test import. File {$importfile} does not exist!");
                 }
             }
             $this->setIntroduction(ilRTE::_replaceMediaObjectImageSrc($this->getIntroduction(), 1));
             $this->setOutro(ilRTE::_replaceMediaObjectImageSrc($this->getOutro(), 1));
             $this->saveToDb();
         }
         // delete import directory
         ilUtil::delDir($this->getImportDirectory());
     }
     return $error;
 }
 /**
  * After xml record writing hook record
  *
  * @param
  * @return
  */
 function afterXmlRecordWriting($a_entity, $a_version, $a_set)
 {
     if ($a_entity == "usr_profile") {
         // cleanup temp dirs for pictures
         $tmp_dir = $this->temp_picture_dirs[$a_set["Id"]];
         if ($tmp_dir != "" && is_dir($tmp_dir)) {
             ilUtil::delDir($tmp_dir);
         }
     }
 }
 /**
  * Clear multi feedback directory
  *
  * @param array 
  * @return
  */
 function clearMultiFeedbackDirectory()
 {
     global $lng, $ilUser;
     include_once "./Modules/Exercise/classes/class.ilFSStorageExercise.php";
     $storage = new ilFSStorageExercise($this->getExerciseId(), $this->getId());
     $mfu = $storage->getMultiFeedbackUploadPath($ilUser->getId());
     ilUtil::delDir($mfu);
 }
 /**
  * create html package
  */
 function exportHTML()
 {
     $inst_id = IL_INST_ID;
     include_once "./Services/Export/classes/class.ilExport.php";
     ilExport::_createExportDirectory($this->object->getId(), "html", $this->object->getType());
     $export_dir = ilExport::_getExportDirectory($this->object->getId(), "html", $this->object->getType());
     $subdir = $this->object->getType() . "_" . $this->object->getId();
     $filename = $this->subdir . ".zip";
     $target_dir = $export_dir . "/" . $subdir;
     ilUtil::delDir($target_dir);
     ilUtil::makeDir($target_dir);
     $source_dir = $this->object->getDataDirectory();
     ilUtil::rCopy($source_dir, $target_dir);
     // zip it all
     $date = time();
     $zip_file = $export_dir . "/" . $date . "__" . IL_INST_ID . "__" . $this->object->getType() . "_" . $this->object->getId() . ".zip";
     ilUtil::zip($target_dir, $zip_file);
     ilUtil::delDir($target_dir);
 }
 /**
  * Download all submitted files of an assignment (all user)
  *
  * @param	$members		array of user names, key is user id
  */
 function downloadAllDeliveredFiles($a_eph_id, $a_ass_id, $members)
 {
     global $lng, $ilObjDataCache, $ilias;
     include_once "./Services/Utilities/classes/class.ilUtil.php";
     include_once "./Customizing/global/plugins/Services/Repository/RepositoryObject/Ephorus/classes/class.ilFSStorageEphorus.php";
     $storage = new ilFSStorageEphorus($a_eph_id, $a_ass_id);
     $storage->create();
     ksort($members);
     //$savepath = $this->getEphorusPath() . "/" . $this->obj_id . "/";
     $savepath = $storage->getAbsoluteSubmissionPath();
     $cdir = getcwd();
     // important check: if the directory does not exist
     // ILIAS stays in the current directory (echoing only a warning)
     // and the zip command below archives the whole ILIAS directory
     // (including the data directory) and sends a mega file to the user :-o
     if (!is_dir($savepath)) {
         return;
     }
     // Safe mode fix
     //		chdir($this->getEphorusPath());
     chdir($storage->getTempPath());
     $zip = PATH_TO_ZIP;
     // check first, if we have enough free disk space to copy all files to temporary directory
     $tmpdir = ilUtil::ilTempnam();
     ilUtil::makeDir($tmpdir);
     chdir($tmpdir);
     $dirsize = 0;
     foreach ($members as $id => $object) {
         $directory = $savepath . DIRECTORY_SEPARATOR . $id;
         $dirsize += ilUtil::dirsize($directory);
     }
     if ($dirsize > disk_free_space($tmpdir)) {
         return -1;
     }
     // copy all member directories to the temporary folder
     // switch from id to member name and append the login if the member name is double
     // ensure that no illegal filenames will be created
     // remove timestamp from filename
     $cache = array();
     foreach ($members as $id => $user) {
         $sourcedir = $savepath . DIRECTORY_SEPARATOR . $id;
         if (!is_dir($sourcedir)) {
             continue;
         }
         $userName = ilObjUser::_lookupName($id);
         $directory = ilUtil::getASCIIFilename(trim($userName["lastname"]) . "_" . trim($userName["firstname"]));
         if (array_key_exists($directory, $cache)) {
             // first try is to append the login;
             $directory = ilUtil::getASCIIFilename($directory . "_" . trim(ilObjUser::_lookupLogin($id)));
             if (array_key_exists($directory, $cache)) {
                 // second and secure: append the user id as well.
                 $directory .= "_" . $id;
             }
         }
         $cache[$directory] = $directory;
         ilUtil::makeDir($directory);
         $sourcefiles = scandir($sourcedir);
         foreach ($sourcefiles as $sourcefile) {
             if ($sourcefile == "." || $sourcefile == "..") {
                 continue;
             }
             $targetfile = trim(basename($sourcefile));
             $pos = strpos($targetfile, "_");
             if ($pos === false) {
             } else {
                 $targetfile = substr($targetfile, $pos + 1);
             }
             $targetfile = $directory . DIRECTORY_SEPARATOR . $targetfile;
             $sourcefile = $sourcedir . DIRECTORY_SEPARATOR . $sourcefile;
             if (!copy($sourcefile, $targetfile)) {
                 //echo 'Could not copy '.$sourcefile.' to '.$targetfile;
                 $ilias->raiseError('Could not copy ' . basename($sourcefile) . " to '" . $targetfile . "'.", $ilias->error_obj->MESSAGE);
             } else {
                 // preserve time stamp
                 touch($targetfile, filectime($sourcefile));
             }
         }
     }
     $tmpfile = ilUtil::ilTempnam();
     $tmpzipfile = $tmpfile . ".zip";
     // Safe mode fix
     $zipcmd = $zip . " -r " . ilUtil::escapeShellArg($tmpzipfile) . " .";
     exec($zipcmd);
     ilUtil::delDir($tmpdir);
     $assTitle = ilEphAssignment::lookupTitle($a_ass_id);
     chdir($cdir);
     ilUtil::deliverFile($tmpzipfile, (strlen($assTitle) == 0 ? strtolower($lng->txt("rep_robj_xeph_ephorus_assignment")) : $assTitle) . ".zip", "", false, true);
 }
 /**
  * import users
  */
 function importUsersObject()
 {
     global $rbacreview, $ilUser;
     // Blind out tabs for local user import
     if ($_GET["baseClass"] == 'ilRepositoryGUI') {
         $this->tabs_gui->clearTargets();
     }
     include_once './Services/AccessControl/classes/class.ilObjRole.php';
     include_once './Services/User/classes/class.ilUserImportParser.php';
     global $rbacreview, $rbacsystem, $tree, $lng;
     switch ($_POST["conflict_handling_choice"]) {
         case "update_on_conflict":
             $rule = IL_UPDATE_ON_CONFLICT;
             break;
         case "ignore_on_conflict":
         default:
             $rule = IL_IGNORE_ON_CONFLICT;
             break;
     }
     $importParser = new ilUserImportParser($_POST["xml_file"], IL_USER_IMPORT, $rule);
     $importParser->setFolderId($this->getUserOwnerId());
     $import_dir = $this->getImportDir();
     // Catch hack attempts
     // We check here again, if the role folders are in the tree, and if the
     // user has permission on the roles.
     if ($_POST["role_assign"]) {
         $global_roles = $rbacreview->getGlobalRoles();
         $roles_of_user = $rbacreview->assignedRoles($ilUser->getId());
         foreach ($_POST["role_assign"] as $role_id) {
             if ($role_id != "") {
                 if (in_array($role_id, $global_roles)) {
                     if (!in_array(SYSTEM_ROLE_ID, $roles_of_user)) {
                         if ($role_id == SYSTEM_ROLE_ID && !in_array(SYSTEM_ROLE_ID, $roles_of_user) || $this->object->getRefId() != USER_FOLDER_ID && !ilObjRole::_getAssignUsersStatus($role_id)) {
                             ilUtil::delDir($import_dir);
                             $this->ilias->raiseError($this->lng->txt("usrimport_with_specified_role_not_permitted"), $this->ilias->error_obj->MESSAGE);
                         }
                     }
                 } else {
                     $rolf = $rbacreview->getFoldersAssignedToRole($role_id, true);
                     if ($rbacreview->isDeleted($rolf[0]) || !$rbacsystem->checkAccess('write', $tree->getParentId($rolf[0]))) {
                         ilUtil::delDir($import_dir);
                         $this->ilias->raiseError($this->lng->txt("usrimport_with_specified_role_not_permitted"), $this->ilias->error_obj->MESSAGE);
                         return;
                     }
                 }
             }
         }
     }
     $importParser->setRoleAssignment($_POST["role_assign"]);
     $importParser->startParsing();
     // purge user import directory
     ilUtil::delDir($import_dir);
     switch ($importParser->getErrorLevel()) {
         case IL_IMPORT_SUCCESS:
             ilUtil::sendSuccess($this->lng->txt("user_imported"), true);
             break;
         case IL_IMPORT_WARNING:
             ilUtil::sendInfo($this->lng->txt("user_imported_with_warnings") . $importParser->getProtocolAsHTML($lng->txt("import_warning_log")), true);
             break;
         case IL_IMPORT_FAILURE:
             $this->ilias->raiseError($this->lng->txt("user_import_failed") . $importParser->getProtocolAsHTML($lng->txt("import_failure_log")), $this->ilias->error_obj->MESSAGE);
             break;
     }
     if (strtolower($_GET["baseClass"]) == "iladministrationgui") {
         $this->ctrl->redirect($this, "view");
         //ilUtil::redirect($this->ctrl->getLinkTarget($this));
     } else {
         $this->ctrl->redirectByClass('ilobjcategorygui', 'listUsers');
     }
 }
 /**
  * Clear export directory
  */
 function cleanExportDirectory()
 {
     $sty_data_dir = ilUtil::getDataDir() . "/sty";
     $style_dir = $sty_data_dir . "/sty_" . $this->getId();
     // create export subdirectory
     $ex_dir = $style_dir . "/export";
     if (is_dir($ex_dir)) {
         ilUtil::delDir($ex_dir, true);
     }
 }
    public function deassignFileFromPaymentObject()
    {
        $statement = $this->db->manipulateF('UPDATE payment_objects
			 SET
			 image = %s
			 WHERE pobject_id = %s', array('text', 'integer'), array(NULL, $this->pobject_id));
        if ($this->image_current != '') {
            $this->unlinkFile($this->image_current);
        }
        ilUtil::delDir($this->shop_path);
        $this->image_current = '';
        return true;
    }
 /**
  * delete export files
  */
 public function deleteExportFileObject()
 {
     $export_dir = $this->object->getExportDirectory();
     foreach ($_POST["file"] as $file) {
         $file = basename($file);
         $exp_file = $export_dir . "/" . $file;
         $exp_dir = $export_dir . "/" . substr($file, 0, strlen($file) - 4);
         if (@is_file($exp_file)) {
             unlink($exp_file);
         }
         if (@is_dir($exp_dir)) {
             include_once "./Services/Utilities/classes/class.ilUtil.php";
             ilUtil::delDir($exp_dir);
         }
     }
     ilUtil::sendSuccess($this->lng->txt('msg_deleted_export_files'), true);
     $this->ctrl->redirect($this, "export");
 }
Exemple #23
0
 /**
  * imports question(s) into the questionpool (after verification)
  */
 function importVerifiedFileObject()
 {
     include_once "./Modules/Test/classes/class.ilObjTest.php";
     // create new questionpool object
     $newObj = new ilObjTest(0, true);
     // set type of questionpool object
     $newObj->setType($_GET["new_type"]);
     // set title of questionpool object to "dummy"
     $newObj->setTitle("dummy");
     // set description of questionpool object
     $newObj->setDescription("test import");
     // create the questionpool class in the ILIAS database (object_data table)
     $newObj->create(true);
     // create a reference for the questionpool object in the ILIAS database (object_reference table)
     $newObj->createReference();
     // put the questionpool object in the administration tree
     $newObj->putInTree($_GET["ref_id"]);
     // get default permissions and set the permissions for the questionpool object
     $newObj->setPermissions($_GET["ref_id"]);
     // notify the questionpool object and all its parent objects that a "new" object was created
     $newObj->notify("new", $_GET["ref_id"], $_GET["parent_non_rbac_id"], $_GET["ref_id"], $newObj->getRefId());
     // empty mark schema
     $newObj->mark_schema->flush();
     // start parsing of QTI files
     include_once "./Services/QTI/classes/class.ilQTIParser.php";
     // Handle selection of "no questionpool" as qpl_id = -1 -> use test object id instead.
     // TODO: chek if empty strings in $_POST["qpl_id"] relates to a bug or not
     if ($_POST["qpl_id"] == "-1") {
         $qpl_id = $newObj->id;
     } else {
         $qpl_id = $_POST["qpl_id"];
     }
     $qtiParser = new ilQTIParser($_SESSION["tst_import_qti_file"], IL_MO_PARSE_QTI, $qpl_id, $_POST["ident"]);
     $qtiParser->setTestObject($newObj);
     $result = $qtiParser->startParsing();
     $newObj->saveToDb();
     // import page data
     include_once "./Modules/LearningModule/classes/class.ilContObjParser.php";
     $contParser = new ilContObjParser($newObj, $_SESSION["tst_import_xml_file"], $_SESSION["tst_import_subdir"]);
     $contParser->setQuestionMapping($qtiParser->getImportMapping());
     $contParser->startParsing();
     // import test results
     if (@file_exists($_SESSION["tst_import_results_file"])) {
         include_once "./Modules/Test/classes/class.ilTestResultsImportParser.php";
         $results = new ilTestResultsImportParser($_SESSION["tst_import_results_file"], $newObj);
         $results->startParsing();
     }
     // delete import directory
     ilUtil::delDir(ilObjTest::_getImportDirectory());
     ilUtil::sendSuccess($this->lng->txt("object_imported"), true);
     $newObj->updateMetaData();
     ilUtil::redirect("ilias.php?ref_id=" . $newObj->getRefId() . "&baseClass=ilObjTestGUI");
 }
 /**
  * Delete files
  */
 function delete()
 {
     global $ilCtrl;
     foreach ($_POST["file"] as $file) {
         $file = explode(":", $file);
         include_once "./Services/Export/classes/class.ilExport.php";
         $export_dir = ilExport::_getExportDirectory($this->obj->getId(), str_replace("..", "", $file[0]), $this->obj->getType());
         $exp_file = $export_dir . "/" . str_replace("..", "", $file[1]);
         $exp_dir = $export_dir . "/" . substr($file[1], 0, strlen($file[1]) - 4);
         if (@is_file($exp_file)) {
             unlink($exp_file);
         }
         if (@is_dir($exp_dir)) {
             ilUtil::delDir($exp_dir);
         }
         // delete entry in database
         include_once './Services/Export/classes/class.ilExportFileInfo.php';
         $info = new ilExportFileInfo($this->obj->getId(), $file[0], $file[1]);
         $info->delete();
     }
     $ilCtrl->redirect($this, "listExportFiles");
 }
Exemple #25
0
 function removeTestResultsForUser($user_id)
 {
     global $ilDB;
     $active_id = $this->getActiveIdOfUser($user_id);
     // remove the question from tst_solutions
     $affectedRows = $ilDB->manipulateF("DELETE FROM tst_solutions WHERE active_fi = %s", array('integer'), array($active_id));
     $affectedRows = $ilDB->manipulateF("DELETE FROM tst_qst_solved WHERE active_fi = %s", array('integer'), array($active_id));
     $affectedRows = $ilDB->manipulateF("DELETE FROM tst_test_result WHERE active_fi = %s", array('integer'), array($active_id));
     $affectedRows = $ilDB->manipulateF("DELETE FROM tst_pass_result WHERE active_fi = %s", array('integer'), array($active_id));
     if ($this->isRandomTest()) {
         $affectedRows = $ilDB->manipulateF("DELETE FROM tst_test_rnd_qst WHERE active_fi = %s", array('integer'), array($active_id));
     }
     include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
     if (ilObjAssessmentFolder::_enabledAssessmentLogging()) {
         $this->logAction(sprintf($this->lng->txtlng("assessment", "log_selected_user_data_removed", ilObjAssessmentFolder::_getLogLanguage()), $this->userLookupFullName($this->_getUserIdFromActiveId($active_id))));
     }
     $affectedRows = $ilDB->manipulateF("DELETE FROM tst_sequence WHERE active_fi = %s", array('integer'), array($active_id));
     // remove test_active entry
     $affectedRows = $ilDB->manipulateF("DELETE FROM tst_active WHERE active_id = %s", array('integer'), array($active_id));
     // remove saved user password
     if ($user_id > 0) {
         $affectedRows = $ilDB->manipulateF("DELETE FROM usr_pref WHERE usr_id = %s AND keyword = %s", array('integer', 'text'), array($user_id, "tst_password_" . $this->getTestId()));
     }
     // TODO: this shouldn't be here since it is question stuff and should be modular but there's no other solution yet
     // remove file uploads
     if (@is_dir(CLIENT_WEB_DIR . "/assessment/tst_" . $this->getTestId() . "/{$active_id}")) {
         ilUtil::delDir(CLIENT_WEB_DIR . "/assessment/tst_" . $this->getTestId() . "/{$active_id}");
     }
     require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionHintTracking.php';
     ilAssQuestionHintTracking::deleteRequestsByActiveIds(array($active_id));
 }
 /**
  * Imports survey questions into ILIAS
  *
  * @param string $source The filename of an XML import file
  * @access public
  */
 function importObject($source, $spl_exists = FALSE)
 {
     if (is_file($source)) {
         $isZip = strcmp(strtolower(substr($source, -3)), 'zip') == 0;
         if ($isZip) {
             // unzip file
             ilUtil::unzip($source);
             // determine filenames of xml files
             $subdir = basename($source, ".zip");
             $source = dirname($source) . "/" . $subdir . "/" . $subdir . ".xml";
         }
         $fh = fopen($source, "r") or die("");
         $xml = fread($fh, filesize($source));
         fclose($fh) or die("");
         if ($isZip) {
             $subdir = basename($source, ".zip");
             if (@is_dir(dirname($source) . "/" . $subdir)) {
                 ilUtil::delDir(dirname($source) . "/" . $subdir);
             }
         }
         if (strpos($xml, "questestinterop") > 0) {
             // survey questions for ILIAS < 3.8
             include_once "./Services/Survey/classes/class.SurveyImportParserPre38.php";
             $import = new SurveyImportParserPre38($this->getId(), "", $spl_exists);
             $import->setXMLContent($xml);
             $import->startParsing();
         } else {
             // survey questions for ILIAS >= 3.8
             include_once "./Services/Survey/classes/class.SurveyImportParser.php";
             $import = new SurveyImportParser($this->getId(), "", $spl_exists);
             $import->setXMLContent($xml);
             $import->startParsing();
         }
     }
 }
 /**
  * delete client
  * @param	boolean	remove ini if true
  * @param	boolean	remove db if true
  * @param	boolean remove files if true
  * @return	array	confirmation messages
  * 
  */
 function delete($a_ini = true, $a_db = false, $a_files = false)
 {
     if ($a_ini === true and file_exists(ILIAS_ABSOLUTE_PATH . "/" . ILIAS_WEB_DIR . "/" . $this->getId() . "/client.ini.php")) {
         unlink(CLIENT_WEB_DIR . "/client.ini.php");
         $msg[] = "ini_deleted";
     }
     if ($a_db === true and $this->db_exists) {
         $this->db->query("DROP DATABASE " . $this->getDbName());
         $msg[] = "db_deleted";
     }
     if ($a_files === true and file_exists(CLIENT_WEB_DIR) and is_dir(CLIENT_WEB_DIR)) {
         // rmdir();
         ilUtil::delDir(CLIENT_WEB_DIR);
         ilUtil::delDir(CLIENT_DATA_DIR);
         $msg[] = "files_deleted";
     }
     return $msg;
 }
 function buildExportFilePDF()
 {
     global $ilBench;
     /*include_once('./Services/WebServices/RPC/classes/class.ilRPCServerSettings.php');
     		$pp = ilRPCServerSettings::getInstance();
     		if(!$pp->isEnabled()||!$pp->pingServer())
     		{
     			$this->ilias->raiseError("Xml Rpc Server is not running. Check Administration/Webservices/Java-Server settings", $this->ilias->error_obj->MESSAGE);
     			return;
     		}*/
     $ilBench->start("ContentObjectExport", "buildExportFile");
     require_once "./Services/Xml/classes/class.ilXmlWriter.php";
     // create directories
     $this->createExportDirectory();
     ilUtil::makeDir($this->export_dir . "/" . $this->subdir);
     // get Log File
     $expDir = $this->export_dir;
     $expLog = new ilLog($expDir, "export.log");
     $expLog->delete();
     $expLog->setLogFormat("");
     $expLog->write(date("[y-m-d H:i:s] ") . "Start Export");
     $ilBench->start("ContentObjectExport", "buildExportFile_getXML");
     $fo_string = $this->cont_obj->exportPDF($this->inst_id, $this->export_dir . "/" . $this->subdir, $expLog);
     $ilBench->stop("ContentObjectExport", "buildExportFile_getXML");
     $ilBench->start("ContentObjectExport", "buildExportFile_pdfFile");
     fputs(fopen($this->export_dir . "/" . $this->subdir . '/temp.fo', 'w+'), $fo_string);
     global $ilLog;
     include_once './Services/WebServices/RPC/classes/class.ilRpcClientFactory.php';
     try {
         $pdf_base64 = ilRpcClientFactory::factory('RPCTransformationHandler')->ilFO2PDF($fo_string);
         //ilUtil::deliverData($pdf_base64->scalar,'learning_progress.pdf','application/pdf');
         fputs(fopen($this->export_dir . '/' . $this->subdir . '.pdf', 'w+'), $pdf_base64->scalar);
     } catch (XML_RPC2_FaultException $e) {
         ilUtil::sendFailure($e->getMessage(), true);
         return false;
     } catch (Exception $e) {
         ilUtil::sendFailure($e->getMessage(), true);
         return false;
     }
     $ilBench->stop("ContentObjectExport", "buildExportFile_pdfFile");
     ilUtil::delDir($this->export_dir . "/" . $this->subdir);
     $expLog->write(date("[y-m-d H:i:s] ") . "Finished Export");
     $ilBench->stop("ContentObjectExport", "buildExportFile");
     return $this->export_dir . "/" . $this->subdir . ".pdf";
 }
 /**
  * Sync images of a MC question on synchronisation with the original question
  **/
 protected function syncImages()
 {
     global $ilLog;
     $question_id = $this->getOriginalId();
     $imagepath = $this->getImagePath();
     $imagepath_original = str_replace("/{$this->id}/images", "/{$question_id}/images", $imagepath);
     ilUtil::delDir($imagepath_original);
     foreach ($this->answers as $answer) {
         $filename = $answer->getImage();
         if (strlen($filename)) {
             if (@file_exists($imagepath . $filename)) {
                 if (!file_exists($imagepath)) {
                     ilUtil::makeDirParents($imagepath);
                 }
                 if (!file_exists($imagepath_original)) {
                     ilUtil::makeDirParents($imagepath_original);
                 }
                 if (!@copy($imagepath . $filename, $imagepath_original . $filename)) {
                     $ilLog->write("image could not be duplicated!!!!", $ilLog->ERROR);
                     $ilLog->write("object: " . print_r($this, TRUE), $ilLog->ERROR);
                 }
             }
             if (@file_exists($imagepath . $this->getThumbPrefix() . $filename)) {
                 if (!@copy($imagepath . $this->getThumbPrefix() . $filename, $imagepath_original . $this->getThumbPrefix() . $filename)) {
                     $ilLog->write("image thumbnail could not be duplicated!!!!", $ilLog->ERROR);
                     $ilLog->write("object: " . print_r($this, TRUE), $ilLog->ERROR);
                 }
             }
         }
     }
 }
 /**
  * delete object and all related data
  *
  * this method has been tested on may 9th 2004
  * data directory, meta data, file based lm data and bib items
  * have been deleted correctly as desired
  *
  * @access	public
  * @return	boolean	true if all object data were removed; false if only a references were removed
  */
 function delete()
 {
     global $ilDB;
     // always call parent delete function first!!
     if (!parent::delete()) {
         return false;
     }
     // delete meta data of content object
     /*
     		$nested = new ilNestedSetXML();
     		$nested->init($this->getId(), $this->getType());
     		$nested->deleteAllDBData();
     */
     // Delete meta data
     $this->deleteMetaData();
     // delete bibliographical items of object
     include_once "./Services/Xml/classes/class.ilNestedSetXML.php";
     $nested = new ilNestedSetXML();
     $nested->init($this->getId(), "bib");
     $nested->deleteAllDBData();
     // delete file_based_lm record
     $ilDB->manipulate("DELETE FROM file_based_lm WHERE id = " . $ilDB->quote($this->getID(), "integer"));
     // delete data directory
     ilUtil::delDir($this->getDataDirectory());
     return true;
 }