if (!is_dir($certificateDirectory)) { mkdir($certificateDirectory, 0755); } $logoid = 0; try { if ($_FILES['file_upload']['size'] > 0) { $filesystem = new FileSystemTree($certificateDirectory); $uploadedFile = $filesystem->uploadFile('file_upload', $certificateDirectory); $certificateid = $uploadedFile['id']; } else { $selectedCertificate = $form->exportValue('existing_certificate'); $certificateFile = new EfrontFile(G_CERTIFICATETEMPLATEPATH . $selectedCertificate); if ($certificateFile['id'] < 0) { //if the file doesn't exist, then import it $selectedCertificate = $certificateFileSystemTree->seekNode(G_CERTIFICATETEMPLATEPATH . $selectedCertificate); $newList = FileSystemTree::importFiles($selectedCertificate['path']); $certificateid = key($newList); } else { $certificateid = $certificateFile['id']; } } if (G_VERSIONTYPE != 'standard') { #cpp#ifndef STANDARD $duration = $_POST['days'] * 24 * 60 * 60 + $_POST['months'] * 30 * 24 * 60 * 60; $currentCourse->course['certificate_expiration'] = $duration; $duration_reset = $form->exportValue('days_reset') * 24 * 60 * 60 + $form->exportValue('months_reset') * 30 * 24 * 60 * 60; $currentCourse->course['reset_interval'] = $duration_reset; if ($_POST['months'] != 0 || $_POST['days'] != 0) { $currentCourse->course['reset'] = $_POST['reset']; } else { $currentCourse->course['reset'] = 0;
private function createCourseExportFile($courseTempDir) { $userTempDir = new EfrontDirectory($GLOBALS['currentUser']->user['directory'] . '/temp'); $file = $courseTempDir->compress($this->course['id'] . '_exported.zip', false); //Compress the lesson files $newList = FileSystemTree::importFiles($file['path']); //Import the file to the database, so we can download it $file = new EfrontFile(current($newList)); $newFileName = EfrontFile::encode($this->course['name']) . '.zip'; if (!eF_checkParameter($newFileName, 'file')) { $newFileName = $file['name']; } $newFileName = str_replace(array('"', '>', '<', '*', '?', ':'), array('"', '>', '<', '*', '?', ':'), $newFileName); //$file -> rename($userTempDir['path'].'/'.$newFileName, true); //changed because of checkFile in rename if (is_file($userTempDir['path'] . '/' . $newFileName)) { $newfile = new EfrontFile($userTempDir['path'] . '/' . $newFileName); $newfile->delete(); } rename($file['path'], $userTempDir['path'] . '/' . $newFileName); //FileSystemTree :: importFiles($userTempDir['path'].'/'.$newFileName); eF_updateTableData("files", array("path" => str_replace(G_ROOTPATH, '', $userTempDir['path'] . '/' . $newFileName)), "id=" . $file['id']); $returnFile = new EfrontFile($file['id']); //$file -> rename($userTempDir['path'].'/'.EfrontFile :: encode($this -> course['name']).'.zip', true); $courseTempDir->delete(); return $returnFile; }
/** * Export lesson * * This function is used to export the current lesson's data to * a file, which can then be imported to other systems. Apart from * the lesson content, the user may optinally specify additional * information to export, using the $exportEntities array. If * $exportEntities is 'all', everything that can be exported, is * exported * * <br/>Example: * <code> * $exportedFile = $lesson -> export('all'); * </code> * * @param array $exportEntities The additional data to export * @param boolean $rename Whether to rename the exported file with the same name as the lesson * @param boolean $exportFiles Whether to export files as well * @return EfrontFile The object of the exported data file * @since 3.5.0 * @access public */ public function export($exportEntities, $rename = true, $exportFiles = true) { if (!$exportEntities) { $exportEntities = array('export_surveys' => 1, 'export_announcements' => 1, 'export_glossary' => 1, 'export_calendar' => 1, 'export_comments' => 1, 'export_rules' => 1); } $data['lessons'] = $this->lesson; unset($data['lessons']['share_folder']); unset($data['lessons']['instance_source']); unset($data['lessons']['originating_course']); $content = eF_getTableData("content", "*", "lessons_ID=" . $this->lesson['id']); if (sizeof($content) > 0) { $contentIds = array(); for ($i = 0; $i < sizeof($content); $i++) { $content[$i]['data'] = str_replace(G_SERVERNAME, "##SERVERNAME##", $content[$i]['data']); $content[$i]['data'] = str_replace("content/lessons/" . ($this->lesson['share_folder'] ? $this->lesson['share_folder'] : $this->lesson['id']), "##LESSONSLINK##", $content[$i]['data']); $contentIds[] = $content[$i]['id']; } $content_list = implode(",", array_values($contentIds)); $data['content'] = $content; $questions = eF_getTableData("questions", "*", "lessons_ID=" . $this->lesson['id']); if (sizeof($questions) > 0) { for ($i = 0; $i < sizeof($questions); $i++) { $questions[$i]['text'] = str_replace(G_SERVERNAME, "##SERVERNAME##", $questions[$i]['text']); $questions[$i]['text'] = str_replace("content/lessons/" . ($this->lesson['share_folder'] ? $this->lesson['share_folder'] : $this->lesson['id']), "##LESSONSLINK##", $questions[$i]['text']); } $data['questions'] = $questions; } $tests = eF_getTableData("tests", "*", "lessons_ID=" . $this->lesson['id']); if (sizeof($tests)) { $testsIds = array(); foreach ($tests as $key => $value) { $testsIds[] = $value['id']; } $tests_list = implode(",", array_values($testsIds)); $tests_to_questions = eF_getTableData("tests_to_questions", "*", "tests_ID IN ({$tests_list})"); for ($i = 0; $i < sizeof($tests); $i++) { $tests[$i]['description'] = str_replace(G_SERVERNAME, "##SERVERNAME##", $tests[$i]['description']); $tests[$i]['description'] = str_replace("content/lessons/" . ($this->lesson['share_folder'] ? $this->lesson['share_folder'] : $this->lesson['id']), "##LESSONSLINK##", $tests[$i]['description']); } $data['tests'] = $tests; $data['tests_to_questions'] = $tests_to_questions; } if (isset($exportEntities['export_rules'])) { $rules = eF_getTableData("rules", "*", "lessons_ID=" . $this->lesson['id']); if (sizeof($rules) > 0) { $data['rules'] = $rules; } } if (isset($exportEntities['export_comments'])) { $comments = eF_getTableData("comments", "*", "content_ID IN ({$content_list})"); if (sizeof($comments) > 0) { $data['comments'] = $comments; } } } if (isset($exportEntities['export_calendar'])) { $calendar = calendar::getLessonCalendarEvents($this); $calendar = array_values($calendar); if (sizeof($calendar) > 0) { $data['calendar'] = $calendar; } } if (isset($exportEntities['export_glossary'])) { $glossary = eF_getTableData("glossary", "*", "lessons_ID = " . $this->lesson['id']); if (sizeof($glossary) > 0) { $data['glossary'] = $glossary; } } if (isset($exportEntities['export_announcements'])) { $news = eF_getTableData("news", "*", "lessons_ID=" . $this->lesson['id']); if (sizeof($news) > 0) { $data['news'] = $news; } } if (isset($exportEntities['export_surveys'])) { $surveys = eF_getTableData("surveys", "*", "lessons_ID=" . $this->lesson['id']); //prepei na ginei to lesson_ID -> lessons_ID sti basi (ayto isos to parampsoyme eykola) if (sizeof($surveys) > 0) { $data['surveys'] = $surveys; $surveys_ = array(); foreach ($surveys as $key => $value) { $surveys_[$value['id']] = $value; } $surveys_list = implode(",", array_keys($surveys_)); $questions_to_surveys = eF_getTableData("questions_to_surveys", "*", "surveys_ID IN ({$surveys_list})"); // oposipote omos to survey_ID -> surveys_ID sti basi if (sizeof($questions_to_surveys) > 0) { $data['questions_to_surveys'] = $questions_to_surveys; } } } $lesson_conditions = eF_getTableData("lesson_conditions", "*", "lessons_ID=" . $this->lesson['id']); if (sizeof($lesson_conditions) > 0) { $data['lesson_conditions'] = $lesson_conditions; } $projects = eF_getTableData("projects", "*", "lessons_ID=" . $this->lesson['id']); if (sizeof($projects) > 0) { $data['projects'] = $projects; } $lesson_files = eF_getTableData("files", "*", "path like '" . str_replace(G_ROOTPATH, '', EfrontDirectory::normalize($this->getDirectory())) . "%'"); if (sizeof($lesson_files) > 0) { $data['files'] = $lesson_files; } if (G_VERSIONTYPE != 'community') { #cpp#ifndef COMMUNITY if (G_VERSIONTYPE != 'standard') { #cpp#ifndef STANDARD //Export scorm tables from here over $scormLessonTables = array('scorm_sequencing_adlseq_map_info', 'scorm_sequencing_content_to_organization', 'scorm_sequencing_maps_info', 'scorm_sequencing_organizations'); foreach ($scormLessonTables as $table) { $scorm_data = eF_getTableData($table, "*", "lessons_ID=" . $this->lesson['id']); if (sizeof($scorm_data) > 0) { $data[$table] = $scorm_data; } } $scormContentTables = array('scorm_sequencing_completion_threshold', 'scorm_sequencing_constrained_choice', 'scorm_sequencing_control_mode', 'scorm_sequencing_delivery_controls', 'scorm_sequencing_hide_lms_ui', 'scorm_sequencing_limit_conditions', 'scorm_sequencing_maps', 'scorm_sequencing_map_info', 'scorm_sequencing_objectives', 'scorm_sequencing_rollup_considerations', 'scorm_sequencing_rollup_controls', 'scorm_sequencing_rollup_rules', 'scorm_sequencing_rules'); if ($content_list) { foreach ($scormContentTables as $table) { $scorm_data = eF_getTableData($table, "*", "content_ID IN ({$content_list})"); if (sizeof($scorm_data) > 0) { $data[$table] = $scorm_data; } if ($table == 'scorm_sequencing_rollup_rules' && sizeof($scorm_data) > 0) { $ids = array(); foreach ($scorm_data as $value) { $ids[] = $value['id']; } $result = eF_getTableData('scorm_sequencing_rollup_rule', "*", "scorm_sequencing_rollup_rules_ID IN (" . implode(",", $ids) . ")"); $data['scorm_sequencing_rollup_rule'] = $result; } if ($table == 'scorm_sequencing_rules' && sizeof($scorm_data) > 0) { $ids = array(); foreach ($scorm_data as $value) { $ids[] = $value['id']; } $result = eF_getTableData('scorm_sequencing_rule', "*", "scorm_sequencing_rules_ID IN (" . implode(",", $ids) . ")"); $data['scorm_sequencing_rule'] = $result; } } } } #cpp#endif } #cpp#endif //'scorm_sequencing_rollup_rule', 'scorm_sequencing_rule', // MODULES - Export module data // Get all modules (NOT only the ones that have to do with the user type) $modules = eF_loadAllModules(); foreach ($modules as $module) { if ($moduleData = $module->onExportLesson($this->lesson['id'])) { $data[$module->className] = $moduleData; } } file_put_contents($this->directory . '/' . "data.dat", serialize($data)); //Create database dump file if ($exportFiles) { $lessonDirectory = new EfrontDirectory($this->directory); $file = $lessonDirectory->compress($this->lesson['id'] . '_exported.zip', false); //Compress the lesson files } else { $dataFile = new EfrontFile($this->directory . '/' . "data.dat"); $file = $dataFile->compress($this->lesson['id'] . '_exported.zip'); } $newList = FileSystemTree::importFiles($file['path']); //Import the file to the database, so we can download it $file = new EfrontFile(current($newList)); if (empty($GLOBALS['currentUser'])) { if ($_SESSION['s_login']) { $GLOBALS['currentUser'] = EfrontUserFactory::factory($_SESSION['s_login']); $userTempDir = $GLOBALS['currentUser']->user['directory'] . '/temp'; } else { $userTempDir = sys_get_temp_dir(); } } else { $userTempDir = $GLOBALS['currentUser']->user['directory'] . '/temp'; } if (!is_dir($userTempDir)) { //If the user's temp directory does not exist, create it $userTempDir = EfrontDirectory::createDirectory($userTempDir, false); $userTempDir = $userTempDir['path']; } try { $existingFile = new EfrontFile($userTempDir . '/' . EfrontFile::encode($this->lesson['name']) . '.zip'); //Delete any previous exported files $existingFile->delete(); } catch (Exception $e) { } if ($rename) { $newName = str_replace(array('"', '>', '<', '*', '?', ':'), array('"', '>', '<', '*', '?', ':'), $this->lesson['name']); $file->rename($userTempDir . '/' . EfrontFile::encode($newName) . '.zip', true); } unlink($this->directory . '/' . "data.dat"); //Delete database dump file return $file; }
<?php if (str_replace(DIRECTORY_SEPARATOR, "/", __FILE__) == $_SERVER['SCRIPT_FILENAME']) { exit; } $GLOBALS['loadScripts'][] = 'includes/filemanager'; if (isset($currentUser->coreAccess['files']) && $currentUser->coreAccess['files'] == 'hidden') { eF_redirect(basename($_SERVER['PHP_SELF']) . "?ctg=control_panel&message=" . urlencode(_UNAUTHORIZEDACCESS) . "&message_type=failure"); } try { if (isset($_GET['display_metadata']) && (eF_checkParameter($_GET['display_metadata'], 'id') || strpos($_GET['display_metadata'], $currentLesson->getDirectory()) !== false)) { $form = new HTML_QuickForm("empty_form", "post", null, null, null, true); $file = new EfrontFile(urldecode($_GET['display_metadata'])); if ($file['id'] == -1) { $imported = FileSystemTree::importFiles($file['path']); $file = new EfrontFile(key($imported)); } $fileMetadata = unserialize($file['metadata']); $metadata = new DublinCoreMetadata($fileMetadata); $smarty->assign("T_FILE_METADATA", $file); if (!isset($currentUser->coreAccess['files']) || $currentUser->coreAccess['files'] == 'change') { $smarty->assign("T_FILE_METADATA_HTML", $metadata->toHTML($form)); } else { $smarty->assign("T_FILE_METADATA_HTML", $metadata->toHTML($form, true, false)); } if (isset($_POST['postAjaxRequest'])) { if (in_array($_POST['dc'], array_keys($metadata->metadataAttributes))) { $_POST['value'] = htmlspecialchars(urldecode($_POST['value'])); if ($_POST['value']) { $fileMetadata[$_POST['dc']] = $_POST['value']; } else {
if ($e->getCode() == EfrontFileException::NOT_APPROPRIATE_TYPE) { $uploadedFile->delete(); } if ($e->getCode() != UPLOAD_ERR_NO_FILE) { throw $e; } if ($form->exportValue('system_avatar') == "none") { $selectedAvatar = 'unknown_small.png'; } else { if ($form->exportValue('system_avatar') != "") { $selectedAvatar = $form->exportValue('system_avatar'); } } if (isset($selectedAvatar)) { $selectedAvatar = $avatarsFileSystemTree->seekNode(G_SYSTEMAVATARSPATH . $selectedAvatar); $newList = FileSystemTree::importFiles($selectedAvatar['path']); //Import the file to the database, so we can access it with view_file $editedUser->user['avatar'] = key($newList); } } EfrontEvent::triggerEvent(array("type" => EfrontEvent::AVATAR_CHANGE, "users_LOGIN" => $editedUser->user['login'], "users_name" => $editedUser->user['name'], "users_surname" => $editedUser->user['surname'], "lessons_ID" => 0, "lessons_name" => "", "entity_ID" => $editedUser->user['avatar'])); } $editedUser->persist(); if (G_VERSIONTYPE == 'enterprise') { #cpp#ifdef ENTERPRISE if (isset($_GET['add_user'])) { $editedEmployee = EfrontHcdUser::createUser(array('users_login' => $editedUser->user['login'])); if ($currentEmployee->isSupervisor() && !EfrontUser::isOptionVisible('show_unassigned_users_to_supervisors')) { //if supervisors can't see unassigned users, then attach this new user to the supervisor's firts branch and job $branch = new EfrontBranch(current($currentEmployee->getSupervisedBranchesRecursive())); $nospecific = false;
/** * Share file * * This function is used to make the current file available to the lesson's * students. A file can be made available to a single lesson only. * <br/>Example: * <code> * $file = new EfrontFile(43); * $file -> share(); //The file is now visible to the shared files list * $file -> unshare(); //The file was made hidden again * </code> * * @param int $lessonId A specific lesson to share this file for * @since 3.5.0 * @access public */ public function share($lessonId = false) { if (!$lessonId) { $result = eF_getTableData("lessons", "share_folder", "id=" . $_SESSION['s_lessons_ID']); $lessonId = !$result[0]['share_folder'] ? $_SESSION['s_lessons_ID'] : $result[0]['share_folder']; } if ($lessonId) { if ($this['id'] == -1) { //If the file does not have a database representation, create one for it $newList = FileSystemTree::importFiles($this['path']); $this['id'] = key($newList); $this->refresh(); } $this['shared'] = $lessonId; $this->persist(); } else { throw new EfrontFileException(_CANNOTSHAREFILE . ': ' . $this['path'], EfrontFileException::NOT_LESSON_FILE); } }