/** * init directory * overwritten method * @access public * @static * @return string path */ function _initDirectory() { if (!@file_exists($this->import_path)) { ilUtil::makeDir($this->import_path); } return true; }
/** * Create webspace directory for the plugin * * @param string level ("plugin", "type" or "object") * @param integer type id or object id * * @return string webspace directory */ static function _createWebspaceDir($a_level = "plugin", $a_id = 0) { switch ($a_level) { case "plugin": $plugin_dir = self::_getWebspaceDir('plugin'); if (!is_dir($plugin_dir)) { ilUtil::makeDir($plugin_dir); } return $plugin_dir; case "type": $plugin_dir = self::_createWebspaceDir("plugin"); $type_dir = $plugin_dir . "/type_" . $a_id; if (!is_dir($type_dir)) { ilUtil::makeDir($type_dir); } return $type_dir; case "object": $plugin_dir = self::_createWebspaceDir("plugin"); $object_dir = $plugin_dir . "/object_" . $a_id; if (!is_dir($type_dir)) { ilUtil::makeDir($object_dir); } return $object_dir; } }
/** * 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); } }
/** * Create directories */ function createDirectories() { ilUtil::makeDir($this->style_dir); ilUtil::makeDir($this->style_img_dir); ilUtil::makeDir($this->img_dir); ilUtil::makeDir($this->img_browser_dir); }
/** * Create directory for the container. * It is <webspace_dir>/container_data. */ function createContainerDirectory() { $webspace_dir = ilUtil::getWebspaceDir(); $cont_dir = $webspace_dir . "/container_data"; if (!is_dir($cont_dir)) { ilUtil::makeDir($cont_dir); } $obj_dir = $cont_dir . "/obj_" . $this->getId(); if (!is_dir($obj_dir)) { ilUtil::makeDir($obj_dir); } }
/** * Get xml record * * @param * @return */ function getXmlRecord($a_entity, $a_version, $a_set) { global $ilLog; if ($a_entity == "usr_profile") { $tmp_dir = ilUtil::ilTempnam(); ilUtil::makeDir($tmp_dir); include_once "./Services/User/classes/class.ilObjUser.php"; ilObjUser::copyProfilePicturesToDirectory($a_set["Id"], $tmp_dir); $this->temp_picture_dirs[$a_set["Id"]] = $tmp_dir; $a_set["Picture"] = $tmp_dir; } return $a_set; }
/** * 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 lm content css to a directory */ static function exportContentCSS($a_slm_object, $a_target_dir) { ilUtil::makeDir($a_target_dir . "/css"); ilUtil::makeDir($a_target_dir . "/css/images"); include_once "./Services/Style/classes/class.ilObjStyleSheet.php"; $active_css = ilObjStyleSheet::getContentStylePath($a_slm_object->getStyleSheetId()); $active_css = split(@'\\?', $active_css, 2); $css = fread(fopen($active_css[0], 'r'), filesize($active_css[0])); preg_match_all("/url\\(([^\\)]*)\\)/", $css, $files); $currdir = getcwd(); chdir(dirname($active_css[0])); foreach (array_unique($files[1]) as $fileref) { if (is_file($fileref)) { copy($fileref, $a_target_dir . "/css/images/" . basename($fileref)); } $css = str_replace($fileref, "images/" . basename($fileref), $css); } chdir($currdir); fwrite(fopen($a_target_dir . '/css/style.css', 'w'), $css); }
/** * init directory * overwritten method * @access public * @return string path */ function __initDirectory() { if (is_writable($this->getPath())) { ilUtil::makeDir($this->getPath() . '/' . GROUP_PATH); $this->group_path = $this->getPath() . '/' . GROUP_PATH; return true; } return false; }
/** * display form for user import */ function importUserRoleAssignmentObject() { global $ilUser, $rbacreview, $tpl, $lng, $ilCtrl; // Blind out tabs for local user import if ($_GET["baseClass"] == 'ilRepositoryGUI') { $this->tabs_gui->clearTargets(); } $this->initUserImportForm(); if ($this->form->checkInput()) { include_once './Services/AccessControl/classes/class.ilObjRole.php'; include_once './Services/User/classes/class.ilUserImportParser.php'; global $rbacreview, $rbacsystem, $tree, $lng; $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.usr_import_roles.html", "Services/User"); $import_dir = $this->getImportDir(); // recreate user import directory if (@is_dir($import_dir)) { ilUtil::delDir($import_dir); } ilUtil::makeDir($import_dir); // move uploaded file to user import directory $file_name = $_FILES["importFile"]["name"]; $parts = pathinfo($file_name); $full_path = $import_dir . "/" . $file_name; // check if import file exists if (!is_file($_FILES["importFile"]["tmp_name"])) { ilUtil::delDir($import_dir); $this->ilias->raiseError($this->lng->txt("no_import_file_found"), $this->ilias->error_obj->MESSAGE); } ilUtil::moveUploadedFile($_FILES["importFile"]["tmp_name"], $_FILES["importFile"]["name"], $full_path); // handle zip file if (strtolower($parts["extension"]) == "zip") { // unzip file ilUtil::unzip($full_path); $xml_file = null; $file_list = ilUtil::getDir($import_dir); foreach ($file_list as $a_file) { if (substr($a_file['entry'], -4) == '.xml') { $xml_file = $import_dir . "/" . $a_file['entry']; break; } } if (is_null($xml_file)) { $subdir = basename($parts["basename"], "." . $parts["extension"]); $xml_file = $import_dir . "/" . $subdir . "/" . $subdir . ".xml"; } } else { $xml_file = $full_path; } // check xml file if (!is_file($xml_file)) { ilUtil::delDir($import_dir); $this->ilias->raiseError($this->lng->txt("no_xml_file_found_in_zip") . " " . $subdir . "/" . $subdir . ".xml", $this->ilias->error_obj->MESSAGE); } require_once "./Services/User/classes/class.ilUserImportParser.php"; // Verify the data // --------------- $importParser = new ilUserImportParser($xml_file, IL_VERIFY); $importParser->startParsing(); switch ($importParser->getErrorLevel()) { case IL_IMPORT_SUCCESS: break; case IL_IMPORT_WARNING: $this->tpl->setVariable("IMPORT_LOG", $importParser->getProtocolAsHTML($lng->txt("verification_warning_log"))); break; case IL_IMPORT_FAILURE: ilUtil::delDir($import_dir); $this->ilias->raiseError($lng->txt("verification_failed") . $importParser->getProtocolAsHTML($lng->txt("verification_failure_log")), $this->ilias->error_obj->MESSAGE); return; } // Create the role selection form // ------------------------------ $this->tpl->setCurrentBlock("role_selection_form"); $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this)); $this->tpl->setVariable("TXT_IMPORT_USERS", $this->lng->txt("import_users")); $this->tpl->setVariable("TXT_IMPORT_FILE", $this->lng->txt("import_file")); $this->tpl->setVariable("IMPORT_FILE", $file_name); $this->tpl->setVariable("TXT_USER_ELEMENT_COUNT", $this->lng->txt("num_users")); $this->tpl->setVariable("USER_ELEMENT_COUNT", $importParser->getUserCount()); $this->tpl->setVariable("TXT_ROLE_ASSIGNMENT", $this->lng->txt("role_assignment")); $this->tpl->setVariable("BTN_IMPORT", $this->lng->txt("import")); $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel")); $this->tpl->setVariable("XML_FILE_NAME", $xml_file); // Extract the roles $importParser = new ilUserImportParser($xml_file, IL_EXTRACT_ROLES); $importParser->startParsing(); $roles = $importParser->getCollectedRoles(); // get global roles $all_gl_roles = $rbacreview->getRoleListByObject(ROLE_FOLDER_ID); $gl_roles = array(); $roles_of_user = $rbacreview->assignedRoles($ilUser->getId()); foreach ($all_gl_roles as $obj_data) { // check assignment permission if called from local admin if ($this->object->getRefId() != USER_FOLDER_ID) { if (!in_array(SYSTEM_ROLE_ID, $roles_of_user) && !ilObjRole::_getAssignUsersStatus($obj_data['obj_id'])) { continue; } } // exclude anonymous role from list if ($obj_data["obj_id"] != ANONYMOUS_ROLE_ID) { // do not allow to assign users to administrator role if current user does not has SYSTEM_ROLE_ID if ($obj_data["obj_id"] != SYSTEM_ROLE_ID or in_array(SYSTEM_ROLE_ID, $roles_of_user)) { $gl_roles[$obj_data["obj_id"]] = $obj_data["title"]; } } } // global roles $got_globals = false; foreach ($roles as $role_id => $role) { if ($role["type"] == "Global") { if (!$got_globals) { $got_globals = true; $this->tpl->setCurrentBlock("global_role_section"); $this->tpl->setVariable("TXT_GLOBAL_ROLES_IMPORT", $this->lng->txt("roles_of_import_global")); $this->tpl->setVariable("TXT_GLOBAL_ROLES", $this->lng->txt("assign_global_role")); } // pre selection for role $pre_select = array_search($role[name], $gl_roles); if (!$pre_select) { switch ($role["name"]) { case "Administrator": // ILIAS 2/3 Administrator $pre_select = array_search("Administrator", $gl_roles); break; case "Autor": // ILIAS 2 Author $pre_select = array_search("User", $gl_roles); break; case "Lerner": // ILIAS 2 Learner $pre_select = array_search("User", $gl_roles); break; case "Gast": // ILIAS 2 Guest $pre_select = array_search("Guest", $gl_roles); break; default: $pre_select = array_search("User", $gl_roles); break; } } $this->tpl->setCurrentBlock("global_role"); $role_select = ilUtil::formSelect($pre_select, "role_assign[" . $role_id . "]", $gl_roles, false, true); $this->tpl->setVariable("TXT_IMPORT_GLOBAL_ROLE", $role["name"] . " [" . $role_id . "]"); $this->tpl->setVariable("SELECT_GLOBAL_ROLE", $role_select); $this->tpl->parseCurrentBlock(); } } // Check if local roles need to be assigned $got_locals = false; foreach ($roles as $role_id => $role) { if ($role["type"] == "Local") { $got_locals = true; break; } } if ($got_locals) { $this->tpl->setCurrentBlock("local_role_section"); $this->tpl->setVariable("TXT_LOCAL_ROLES_IMPORT", $this->lng->txt("roles_of_import_local")); $this->tpl->setVariable("TXT_LOCAL_ROLES", $this->lng->txt("assign_local_role")); // get local roles if ($this->object->getRefId() == USER_FOLDER_ID) { // The import function has been invoked from the user folder // object. In this case, we show only matching roles, // because the user folder object is considered the parent of all // local roles and may contains thousands of roles on large ILIAS // installations. $loc_roles = array(); foreach ($roles as $role_id => $role) { if ($role["type"] == "Local") { $searchName = substr($role['name'], 0, 1) == '#' ? $role['name'] : '#' . $role['name']; $matching_role_ids = $rbacreview->searchRolesByMailboxAddressList($searchName); foreach ($matching_role_ids as $mid) { if (!in_array($mid, $loc_roles)) { $loc_roles[] = array('obj_id' => $mid); } } } } } else { // The import function has been invoked from a locally // administrated category. In this case, we show all roles // contained in the subtree of the category. $loc_roles = $rbacreview->getAssignableRolesInSubtree($this->object->getRefId()); } $l_roles = array(); // create a search array with . $l_roles_mailbox_searcharray = array(); foreach ($loc_roles as $key => $loc_role) { // fetch context path of role $rolf = $rbacreview->getFoldersAssignedToRole($loc_role["obj_id"], true); // only process role folders that are not set to status "deleted" // and for which the user has write permissions. // We also don't show the roles which are in the ROLE_FOLDER_ID folder. // (The ROLE_FOLDER_ID folder contains the global roles). if (!$rbacreview->isDeleted($rolf[0]) && $rbacsystem->checkAccess('write', $tree->getParentId($rolf[0])) && $rolf[0] != ROLE_FOLDER_ID) { // A local role is only displayed, if it is contained in the subtree of // the localy administrated category. If the import function has been // invoked from the user folder object, we show all local roles, because // the user folder object is considered the parent of all local roles. // Thus, if we start from the user folder object, we initialize the // isInSubtree variable with true. In all other cases it is initialized // with false, and only set to true if we find the object id of the // locally administrated category in the tree path to the local role. $isInSubtree = $this->object->getRefId() == USER_FOLDER_ID; $path = ""; if ($this->tree->isInTree($rolf[0])) { // Create path. Paths which have more than 4 segments // are truncated in the middle. $tmpPath = $this->tree->getPathFull($rolf[0]); for ($i = 1, $n = count($tmpPath) - 1; $i < $n; $i++) { if ($i > 1) { $path = $path . ' > '; } if ($i < 3 || $i > $n - 3) { $path = $path . $tmpPath[$i]['title']; } else { if ($i == 3 || $i == $n - 3) { $path = $path . '...'; } } $isInSubtree |= $tmpPath[$i]['obj_id'] == $this->object->getId(); } } else { $path = "<b>Rolefolder " . $rolf[0] . " not found in tree! (Role " . $loc_role["obj_id"] . ")</b>"; } $roleMailboxAddress = $rbacreview->getRoleMailboxAddress($loc_role['obj_id']); $l_roles[$loc_role['obj_id']] = $roleMailboxAddress . ', ' . $path; } } //foreach role $l_roles[""] = ""; natcasesort($l_roles); $l_roles[""] = $this->lng->txt("usrimport_ignore_role"); foreach ($roles as $role_id => $role) { if ($role["type"] == "Local") { $this->tpl->setCurrentBlock("local_role"); $this->tpl->setVariable("TXT_IMPORT_LOCAL_ROLE", $role["name"]); $searchName = substr($role['name'], 0, 1) == '#' ? $role['name'] : '#' . $role['name']; $matching_role_ids = $rbacreview->searchRolesByMailboxAddressList($searchName); $pre_select = count($matching_role_ids) == 1 ? $matching_role_ids[0] : ""; if ($this->object->getRefId() == USER_FOLDER_ID) { // There are too many roles in a large ILIAS installation // that's why whe show only a choice with the the option "ignore", // and the matching roles. $selectable_roles = array(); $selectable_roles[""] = $this->lng->txt("usrimport_ignore_role"); foreach ($matching_role_ids as $id) { $selectable_roles[$id] = $l_roles[$id]; } $role_select = ilUtil::formSelect($pre_select, "role_assign[" . $role_id . "]", $selectable_roles, false, true); } else { $role_select = ilUtil::formSelect($pre_select, "role_assign[" . $role_id . "]", $l_roles, false, true); } $this->tpl->setVariable("SELECT_LOCAL_ROLE", $role_select); $this->tpl->parseCurrentBlock(); } } } // $this->tpl->setVariable("TXT_CONFLICT_HANDLING", $lng->txt("conflict_handling")); $handlers = array(IL_IGNORE_ON_CONFLICT => "ignore_on_conflict", IL_UPDATE_ON_CONFLICT => "update_on_conflict"); $this->tpl->setVariable("TXT_CONFLICT_HANDLING_INFO", str_replace('\\n', '<br>', $this->lng->txt("usrimport_conflict_handling_info"))); $this->tpl->setVariable("TXT_CONFLICT_CHOICE", $lng->txt("conflict_handling")); $this->tpl->setVariable("SELECT_CONFLICT", ilUtil::formSelect(IL_IGNORE_ON_CONFLICT, "conflict_handling_choice", $handlers, false, false)); // new account mail $this->lng->loadLanguageModule("mail"); include_once './Services/User/classes/class.ilObjUserFolder.php'; $amail = ilObjUserFolder::_lookupNewAccountMail($this->lng->getDefaultLanguage()); if (trim($amail["body"]) != "" && trim($amail["subject"]) != "") { $this->tpl->setCurrentBlock("inform_user"); $this->tpl->setVariable("TXT_ACCOUNT_MAIL", $lng->txt("mail_account_mail")); if (true) { $this->tpl->setVariable("SEND_MAIL", " checked=\"checked\""); } $this->tpl->setVariable("TXT_INFORM_USER_MAIL", $this->lng->txt("user_send_new_account_mail")); $this->tpl->parseCurrentBlock(); } } else { $this->form->setValuesByPost(); $tpl->setContent($this->form->getHtml()); } }
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); } }
/** * create directory */ function createDirectory() { global $lng; // determine directory $cur_subdir = str_replace(".", "", ilUtil::stripSlashes($_GET["cdir"])); $cur_dir = !empty($cur_subdir) ? $this->main_dir . "/" . $cur_subdir : $this->main_dir; $new_dir = str_replace(".", "", ilUtil::stripSlashes($_POST["new_dir"])); $new_dir = str_replace("/", "", $new_dir); if (!empty($new_dir)) { ilUtil::makeDir($cur_dir . "/" . $new_dir); if (is_dir($cur_dir . "/" . $new_dir)) { ilUtil::sendSuccess($lng->txt("cont_dir_created"), true); $this->setPerformedCommand("create_dir", array("name" => $new_dir)); } } else { ilUtil::sendFailure($lng->txt("cont_enter_a_dir_name"), true); } $this->ctrl->saveParameter($this, "cdir"); $this->ctrl->redirect($this, "listFiles"); }
/** * 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); }
/** * create a new client and its subdirectories * @return boolean true on success */ function create() { //var_dump($this->getDataDir());exit; // create base data dir if (!ilUtil::makeDir($this->getDataDir())) { $this->error = "could_not_create_base_data_dir :" . $this->getDataDir(); return false; } // create sub dirs in base data dir if (!ilUtil::makeDir($this->getDataDir() . "/mail")) { $this->error = "could_not_create_mail_data_dir :" . $this->getDataDir() . "/mail"; return false; } if (!ilUtil::makeDir($this->getDataDir() . "/lm_data")) { $this->error = "could_not_create_lm_data_dir :" . $this->getDataDir() . "/lm_data"; return false; } if (!ilUtil::makeDir($this->getDataDir() . "/forum")) { $this->error = "could_not_create_forum_data_dir :" . $this->getDataDir() . "/forum"; return false; } if (!ilUtil::makeDir($this->getDataDir() . "/files")) { $this->error = "could_not_create_files_data_dir :" . $this->getDataDir() . "/files"; return false; } // create base webspace dir if (!ilUtil::makeDir($this->getWebspaceDir())) { $this->error = "could_not_create_base_webspace_dir :" . $this->getWebspaceDir(); return false; } // create sub dirs in base webspace dir if (!ilUtil::makeDir($this->getWebspaceDir() . "/lm_data")) { $this->error = "could_not_create_lm_webspace_dir :" . $this->getWebspaceDir() . "/lm_data"; return false; } if (!ilUtil::makeDir($this->getWebspaceDir() . "/usr_images")) { $this->error = "could_not_create_usr_images_webspace_dir :" . $this->getWebspaceDir() . "/usr_images"; return false; } if (!ilUtil::makeDir($this->getWebspaceDir() . "/mobs")) { $this->error = "could_not_create_mobs_webspace_dir :" . $this->getWebspaceDir() . "/mobs"; return false; } if (!ilUtil::makeDir($this->getWebspaceDir() . "/css")) { $this->error = "could_not_create_css_webspace_dir :" . $this->getWebspaceDir() . "/css"; return false; } // write client ini if (!$this->ini->write()) { $this->error = get_class($this) . ": " . $this->ini->getError(); return false; } return true; }
/** * Create member status record for a new assignment for all participants */ function sendMultiFeedbackStructureFile() { global $ilDB; // send and delete the zip file $deliverFilename = trim(str_replace(" ", "_", $this->getTitle() . "_" . $this->getId())); $deliverFilename = ilUtil::getASCIIFilename($deliverFilename); $deliverFilename = "multi_feedback_" . $deliverFilename; $exc = new ilObjExercise($this->getExerciseId(), false); $cdir = getcwd(); // create temporary directoy $tmpdir = ilUtil::ilTempnam(); ilUtil::makeDir($tmpdir); $mfdir = $tmpdir . "/" . $deliverFilename; ilUtil::makeDir($mfdir); // create subfolders <lastname>_<firstname>_<id> for each participant include_once "./Modules/Exercise/classes/class.ilExerciseMembers.php"; $exmem = new ilExerciseMembers($exc); $mems = $exmem->getMembers(); foreach ($mems as $mem) { $name = ilObjUser::_lookupName($mem); $subdir = $name["lastname"] . "_" . $name["firstname"] . "_" . $name["login"] . "_" . $name["user_id"]; $subdir = ilUtil::getASCIIFilename($subdir); ilUtil::makeDir($mfdir . "/" . $subdir); } // create the zip file chdir($tmpdir); $tmpzipfile = $tmpdir . "/multi_feedback.zip"; ilUtil::zip($tmpdir, $tmpzipfile, true); chdir($cdir); ilUtil::deliverFile($tmpzipfile, $deliverFilename . ".zip", "", false, true); }
/** * 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"; }
/** * Export file from path */ function exportHTMLFileDirect($a_file_id, $a_source_file, $a_file_name) { $file_dir = $this->files_dir . "/file_" . $a_file_id; ilUtil::makeDir($file_dir); if (is_file($a_source_file)) { copy($a_source_file, $file_dir . "/" . ilUtil::getASCIIFilename($a_file_name)); } }
/** * Create import directory */ function createImportDirectory() { $sty_data_dir = ilUtil::getDataDir() . "/sty"; ilUtil::makeDir($sty_data_dir); if (!is_writable($sty_data_dir)) { $this->ilias->raiseError("Style data directory (" . $sty_data_dir . ") not writeable.", $this->ilias->error_obj->FATAL); } $style_dir = $sty_data_dir . "/sty_" . $this->getId(); ilUtil::makeDir($style_dir); if (!@is_dir($style_dir)) { $this->ilias->raiseError("Creation of style directory failed (" . $style_dir . ").", $this->ilias->error_obj->FATAL); } // create import subdirectory $im_dir = $style_dir . "/import"; ilUtil::makeDir($im_dir); if (!@is_dir($im_dir)) { $this->ilias->raiseError("Creation of Import Directory failed (" . $im_dir . ").", $this->ilias->error_obj->FATAL); } return $im_dir; }
/** * Export page layout template object */ function exportLayoutObject() { include_once "./Services/Export/classes/class.ilExport.php"; $exp = new ilExport(); $tmpdir = ilUtil::ilTempnam(); ilUtil::makeDir($tmpdir); $succ = $exp->exportEntity("pgtp", (int) $_GET["layout_id"], "4.2.0", "Services/COPage", "Title", $tmpdir); if ($succ["success"]) { ilUtil::deliverFile($succ["directory"] . "/" . $succ["file"], $succ["file"], "", false, false, false); } if (is_file($succ["directory"] . "/" . $succ["file"])) { unlink($succ["directory"] . "/" . $succ["file"]); } if (is_dir($succ["directory"])) { unlink($succ["directory"]); } }
private function logDirectory() { // $logDir=ilUtil::getDataDir()."/SCORMlogs"."/lm_".$this->packageId; // if (!file_exists($logDir)) ilUtil::makeDirParents($logDir); $logDir = $this->slm->getDataDirectory() . "/logs"; if (!file_exists($logDir)) { ilUtil::makeDir($logDir); } return $logDir; }
function exportMediaFullscreen($a_target_dir, $pg_obj) { $subdir = "il_" . IL_INST_ID . "_mob_" . $this->getId(); $a_target_dir = $a_target_dir . "/objects/" . $subdir; ilUtil::makeDir($a_target_dir); $tpl = new ilTemplate("tpl.fullscreen.html", true, true, "Modules/LearningModule"); $tpl->setCurrentBlock("ilMedia"); //$int_links = $page_object->getInternalLinks(); $med_links = ilMediaItem::_getMapAreasIntLinks($this->getId()); // @todo //$link_xml = $this->getLinkXML($med_links, $this->getLayoutLinkTargets()); require_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php"; //$media_obj = new ilObjMediaObject($_GET["mob_id"]); require_once "./Services/COPage/classes/class.ilPageObject.php"; $xml = "<dummy>"; // todo: we get always the first alias now (problem if mob is used multiple // times in page) $xml .= $pg_obj->getMediaAliasElement($this->getId()); $xml .= $this->getXML(IL_MODE_OUTPUT); //$xml.= $link_xml; $xml .= "</dummy>"; //die(htmlspecialchars($xml)); $xsl = file_get_contents("./Services/COPage/xsl/page.xsl"); $args = array('/_xml' => $xml, '/_xsl' => $xsl); $xh = xslt_create(); //echo "<b>XML:</b>".htmlentities($xml); // determine target frames for internal links $wb_path = ""; $enlarge_path = ""; $params = array('mode' => "fullscreen", 'enlarge_path' => $enlarge_path, 'link_params' => "ref_id=" . $_GET["ref_id"], 'fullscreen_link' => "", 'ref_id' => $_GET["ref_id"], 'webspace_path' => $wb_path); $output = xslt_process($xh, "arg:/_xml", "arg:/_xsl", NULL, $args, $params); //echo xslt_error($xh); xslt_free($xh); // unmask user html include_once "./Services/MediaObjects/classes/class.ilPlayerUtil.php"; $tpl->setVariable("LOCATION_CONTENT_STYLESHEET", "../../css/style.css"); $tpl->setVariable("LOCATION_STYLESHEET", "../../css/system.css"); $tpl->setVariable("MEDIA_CONTENT", $output); $output = $tpl->get(); //$output = preg_replace("/\/mobs\/mm_(\d+)\/([^\"]+)/i","$2",$output); $output = preg_replace("/mobs\\/mm_(\\d+)\\/([^\"]+)/i", "\$2", $output); $output = preg_replace("/\\.\\/Services\\/MediaObjects\\/flash_mp3_player/i", "../../players", $output); $output = preg_replace("/\\.\\/" . str_replace("/", "\\/", ilPlayerUtil::getFlashVideoPlayerDirectory()) . "/i", "../../players", $output); $output = preg_replace("/file=..\\/..\\/..\\//i", "file=../objects/" . $subdir . "/", $output); //die(htmlspecialchars($output)); fwrite(fopen($a_target_dir . '/fullscreen.html', 'w'), $output); }
/** * creates data directory for export files * (data_dir/usrf_data/export, depending on data * directory that is set in ILIAS setup/ini) */ function createExportDirectory() { if (!@is_dir($this->getExportDirectory())) { $usrf_data_dir = ilUtil::getDataDir() . "/usrf_data"; ilUtil::makeDir($usrf_data_dir); if (!is_writable($usrf_data_dir)) { $this->ilias->raiseError("Userfolder data directory (" . $usrf_data_dir . ") not writeable.", $this->ilias->error_obj->MESSAGE); } // create Export subdirectory (data_dir/lm_data/lm_<id>/Export) $export_dir = $usrf_data_dir . "/export"; ilUtil::makeDir($export_dir); if (!@is_dir($export_dir)) { $this->ilias->raiseError("Creation of Userfolder Export Directory failed.", $this->ilias->error_obj->MESSAGE); } } }
/** * creates data directory for import files * (data_dir/tst_data/tst_<id>/import, depending on data * directory that is set in ILIAS setup/ini) */ function _createImportDirectory() { global $ilias; include_once "./Services/Utilities/classes/class.ilUtil.php"; $tst_data_dir = ilUtil::getDataDir() . "/tst_data"; ilUtil::makeDir($tst_data_dir); if (!is_writable($tst_data_dir)) { $this->ilias->raiseError("Test Data Directory (" . $tst_data_dir . ") not writeable.", $this->ilias->error_obj->FATAL); } // create test directory (data_dir/tst_data/tst_import) $tst_dir = $tst_data_dir . "/tst_import"; ilUtil::makeDir($tst_dir); if (!@is_dir($tst_dir)) { $ilias->raiseError("Creation of test import directory failed.", $ilias->error_obj->FATAL); } return $tst_dir; }
/** * build xml export file */ function buildExportFileXML() { global $ilBench; $ilBench->start("TestExport", "buildExportFile"); include_once "./Services/Xml/classes/class.ilXmlWriter.php"; $this->xml = new ilXmlWriter(); // set dtd definition $this->xml->xmlSetDtdDef("<!DOCTYPE Test SYSTEM \"http://www.ilias.uni-koeln.de/download/dtd/ilias_co.dtd\">"); // set generated comment $this->xml->xmlSetGenCmt("Export of ILIAS Test " . $this->test_obj->getId() . " of installation " . $this->inst . "."); // set xml header $this->xml->xmlHeader(); // create directories $this->test_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->test_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 qti file $qti_file = fopen($this->export_dir . "/" . $this->subdir . "/" . $this->qti_filename, "w"); fwrite($qti_file, $this->test_obj->toXML()); fclose($qti_file); // get xml content $ilBench->start("TestExport", "buildExportFile_getXML"); $this->test_obj->exportPagesXML($this->xml, $this->inst_id, $this->export_dir . "/" . $this->subdir, $expLog); $ilBench->stop("TestExport", "buildExportFile_getXML"); // dump xml document to screen (only for debugging reasons) /* echo "<PRE>"; echo htmlentities($this->xml->xmlDumpMem($format)); echo "</PRE>"; */ // dump xml document to file $ilBench->start("TestExport", "buildExportFile_dumpToFile"); $this->xml->xmlDumpFile($this->export_dir . "/" . $this->subdir . "/" . $this->filename, false); $ilBench->stop("TestExport", "buildExportFile_dumpToFile"); if (@file_exists("./Modules/Test/classes/class.ilTestResultsToXML.php")) { // dump results xml document to file include_once "./Modules/Test/classes/class.ilTestResultsToXML.php"; $resultwriter = new ilTestResultsToXML($this->test_obj->getTestId(), $this->test_obj->getAnonymity()); $ilBench->start("TestExport", "buildExportFile_results"); $resultwriter->xmlDumpFile($this->export_dir . "/" . $this->subdir . "/" . $this->resultsfile, false); $ilBench->stop("TestExport", "buildExportFile_results"); } // add media objects which were added with tiny mce $ilBench->start("QuestionpoolExport", "buildExportFile_saveAdditionalMobs"); $this->exportXHTMLMediaObjects($this->export_dir . "/" . $this->subdir); $ilBench->stop("QuestionpoolExport", "buildExportFile_saveAdditionalMobs"); // zip the file $ilBench->start("TestExport", "buildExportFile_zipFile"); ilUtil::zip($this->export_dir . "/" . $this->subdir, $this->export_dir . "/" . $this->subdir . ".zip"); $ilBench->stop("TestExport", "buildExportFile_zipFile"); // destroy writer object $this->xml->_XmlWriter; $expLog->write(date("[y-m-d H:i:s] ") . "Finished Export"); $ilBench->stop("TestExport", "buildExportFile"); return $this->export_dir . "/" . $this->subdir . ".zip"; }
/** * creates data directory for import files * (data_dir/qpl_data/qpl_<id>/import, depending on data * directory that is set in ILIAS setup/ini) */ static function _createImportDirectory() { global $ilias; include_once "./Services/Utilities/classes/class.ilUtil.php"; $qpl_data_dir = ilUtil::getDataDir() . "/qpl_data"; ilUtil::makeDir($qpl_data_dir); if (!is_writable($qpl_data_dir)) { $ilias->raiseError("Questionpool Data Directory (" . $qpl_data_dir . ") not writeable.", $ilias->error_obj->FATAL); } // create questionpool directory (data_dir/qpl_data/qpl_import) $qpl_dir = $qpl_data_dir . "/qpl_import"; ilUtil::makeDir($qpl_dir); if (!@is_dir($qpl_dir)) { $ilias->raiseError("Creation of Questionpool Directory failed.", $ilias->error_obj->FATAL); } return $qpl_dir; }
/** * 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; }
/** * creates data directory for import files * (data_dir/spl_data/spl_<id>/import, depending on data * directory that is set in ILIAS setup/ini) */ function createImportDirectory() { include_once "./Services/Utilities/classes/class.ilUtil.php"; $spl_data_dir = ilUtil::getDataDir() . "/spl_data"; ilUtil::makeDir($spl_data_dir); if (!is_writable($spl_data_dir)) { $this->ilias->raiseError("Survey Questionpool Data Directory (" . $spl_data_dir . ") not writeable.", $this->ilias->error_obj->FATAL); } // create test directory (data_dir/spl_data/spl_<id>) $spl_dir = $spl_data_dir . "/spl_" . $this->getId(); ilUtil::makeDir($spl_dir); if (!@is_dir($spl_dir)) { $this->ilias->raiseError("Creation of Survey Questionpool Directory failed.", $this->ilias->error_obj->FATAL); } // create import subdirectory (data_dir/spl_data/spl_<id>/import) $import_dir = $spl_dir . "/import"; ilUtil::makeDir($import_dir); if (!@is_dir($import_dir)) { $this->ilias->raiseError("Creation of Import Directory failed.", $this->ilias->error_obj->FATAL); } }
/** * 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); }
$se_db = (int) $setting->get("se_db"); if ($se_db <= 58) { $set = $ilDB->query("SELECT * FROM object_data WHERE type = 'sty'"); while ($rec = $ilDB->fetchAssoc($set)) { $imgs = array("accordion_arrow.gif", "haccordion_arrow.gif"); $a_style_id = $rec["obj_id"]; $sty_data_dir = CLIENT_WEB_DIR . "/sty"; ilUtil::makeDir($sty_data_dir); $style_dir = $sty_data_dir . "/sty_" . $a_style_id; ilUtil::makeDir($style_dir); // create images subdirectory $im_dir = $style_dir . "/images"; ilUtil::makeDir($im_dir); // create thumbnails directory $thumb_dir = $style_dir . "/images/thumbnails"; ilUtil::makeDir($thumb_dir); // ilObjStyleSheet::_createImagesDirectory($rec["obj_id"]); $imdir = CLIENT_WEB_DIR . "/sty/sty_" . $a_style_id . "/images"; foreach ($imgs as $cim) { if (!is_file($imdir . "/" . $cim)) { copy("./Services/Style/basic_style/images/" . $cim, $imdir . "/" . $cim); } } } } ?> <#2405> <?php if (!$ilDB->tableExists("style_setting")) { $fields = array('style_id' => array('type' => 'integer', 'length' => 4, 'notnull' => true), 'name' => array('type' => 'text', 'length' => 30, 'fixed' => false, 'notnull' => true), 'value' => array('type' => 'text', 'length' => 30, 'fixed' => false, 'notnull' => false));
function createDataDirectory() { ilUtil::makeDir($this->getDataDirectory()); }