예제 #1
0
     eF_redirect("" . basename($_SERVER['PHP_SELF']) . "?ctg=control_panel&message=" . urlencode(_UNAUTHORIZEDACCESS) . "&message_type=failure");
 }
 /* Import part */
 $form = new HTML_QuickForm("import_course_form", "post", basename($_SERVER['PHP_SELF']) . '?' . $baseUrl . '&op=import_course', "", null, true);
 $form->addElement('file', 'file_upload', null, 'class = "inputText"');
 //Lesson file
 $form->setMaxFileSize(FileSystemTree::getUploadMaxSize() * 1024);
 //getUploadMaxSize returns size in KB
 $form->addElement('submit', 'submit_import_course', _SUBMIT, 'class = "flatButton"');
 $smarty->assign("T_MAX_FILESIZE", FileSystemTree::getUploadMaxSize());
 if ($form->isSubmitted() && $form->validate()) {
     try {
         $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);
         } else {
             $userTempDir = new EfrontDirectory($userTempDir);
         }
         $filesystem = new FileSystemTree($userTempDir);
         $uploadedFile = $filesystem->uploadFile('file_upload', $userTempDir);
         $currentCourse->import($uploadedFile);
         $message = _COURSEIMPORTEDSUCCESFULLY;
         $message_type = 'success';
     } catch (Exception $e) {
         $smarty->assign("T_EXCEPTION_TRACE", $e->getTraceAsString());
         $message = _PROBLEMIMPORTINGFILE . ': ' . $e->getMessage() . ' (' . $e->getCode() . ') &nbsp;<a href = "javascript:void(0)" onclick = "eF_js_showDivPopup(event, \'' . _ERRORDETAILS . '\', 2, \'error_details\')">' . _MOREINFO . '</a>';
         $message_type = 'failure';
     }
 }
 $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty);
예제 #2
0
 private function createUserTempDirectory()
 {
     $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);
     } else {
         $userTempDir = new EfrontDirectory($userTempDir);
     }
     return $userTempDir;
 }
예제 #3
0
 /**
  * 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('&quot;', '&gt;', '&lt;', '&#42;', '&#63;', '&#58;'), $this->lesson['name']);
         $file->rename($userTempDir . '/' . EfrontFile::encode($newName) . '.zip', true);
     }
     unlink($this->directory . '/' . "data.dat");
     //Delete database dump file
     return $file;
 }
예제 #4
0
 /**
  * Create The MS Word Document from given HTML
  *
  * @param String $html :: HTML Content or HTML File Name like path/to/html/file.html
  * @param String $file :: Document File Name
  * @param Boolean $download :: Wheather to download the file or save the file
  * @return boolean 
  */
 function createDoc($html, $file, $download = false)
 {
     if (is_file($html)) {
         $html = @file_get_contents($html);
     }
     $this->_parseHtml($html);
     $this->setDocFileName($file);
     $doc = $this->getHeader();
     $doc .= $this->htmlBody;
     $doc .= $this->getFotter();
     if ($download) {
         if (!empty($this->localimgs)) {
             if (file_exists($this->lessonDirectory . $file)) {
                 $tmpDir = new EfrontDirectory($this->lessonDirectory . $file);
             } else {
                 $tmpDir = EfrontDirectory::createDirectory($this->lessonDirectory . $file);
             }
             $array_cp = $tmpDir->getArrayCopy();
             foreach ($this->localimgs as $img) {
                 $file = new EfrontFile($img['path'] . $img['src']);
                 $file->copy($array_cp['path'] . "/" . $img['src']);
             }
             $this->write_file($array_cp['path'] . "/" . $this->docFile, $doc);
             $zipfile = $tmpDir->compress();
             $tmpDir->delete();
             $zipfile->sendFile();
             exit;
         } else {
             @header("Cache-Control: ");
             // leave blank to avoid IE errors
             @header("Pragma: ");
             // leave blank to avoid IE errors
             @header("Content-type: application/octet-stream");
             @header("Content-Disposition: attachment; filename=\"{$this->docFile}\"");
             echo $doc;
         }
         return true;
     } else {
         return $this->write_file($this->docFile, $doc);
     }
 }
예제 #5
0
파일: projects.php 프로젝트: bqq1986/efront
     $file = $form->addElement('file', 'filename', _FILE);
     $maxFileSize = FileSystemTree::getUploadMaxSize();
     $form->addRule('filename', _THEFIELD . ' "' . _FILE . '" ' . _ISMANDATORY, 'required', null, 'client');
     $form->setMaxFileSize($maxFileSize * 1024);
     $form->addElement('submit', 'submit_upload_project', _SENDPROJECT, 'class = "flatButton"');
 }
 $smarty->assign("T_MAX_FILE_SIZE", $maxFileSize);
 if ($form->isSubmitted() && $form->validate() && !$currentProject->expired) {
     try {
         $projectDirectory = G_UPLOADPATH . $currentUser->user['login'] . '/projects';
         if (!is_dir($projectDirectory)) {
             EfrontDirectory::createDirectory($projectDirectory);
         }
         $projectDirectory = G_UPLOADPATH . $currentUser->user['login'] . '/projects/' . $currentProject->project['id'];
         if (!is_dir($projectDirectory)) {
             EfrontDirectory::createDirectory($projectDirectory);
         }
         $filesystem = new FileSystemTree($projectDirectory);
         $uploadedFile = $filesystem->uploadFile('filename', $projectDirectory);
         //$uploadedFile -> rename($uploadedFile['directory'].'/project_'.$currentProject -> project['id'].'.'.$uploadedFile['extension']);
         $fields_update = array("filename" => $uploadedFile['id'], "upload_timestamp" => time());
         eF_updateTableData("users_to_projects", $fields_update, "users_LOGIN='******'login'] . "' AND projects_ID=" . $_GET['view_project']);
         EfrontEvent::triggerEvent(array("type" => EfrontEvent::PROJECT_SUBMISSION, "users_LOGIN" => $currentUser->user['login'], "lessons_ID" => $currentLesson->lesson['id'], "lessons_name" => $currentLesson->lesson['name'], "entity_ID" => $currentProject->project['id'], "entity_name" => $currentProject->project['title']));
         eF_redirect("" . basename($_SERVER['PHP_SELF']) . "?ctg=projects&view_project=" . $_GET['view_project'] . "&message=" . urlencode(_FILEUPLOADED) . "&message_type=success");
     } catch (EfrontFileException $e) {
         $smarty->assign("T_EXCEPTION_TRACE", $e->getTraceAsString());
         $message = _SOMEPROBLEMOCCURED . ': ' . $e->getMessage() . ' (' . $e->getCode() . ') &nbsp;<a href = "javascript:void(0)" onclick = "eF_js_showDivPopup(event, \'' . _ERRORDETAILS . '\', 2, \'error_details\')">' . _MOREINFO . '</a>';
         $message_type = 'failure';
     }
 } elseif ($currentProject->expired) {
     $message = _PROJECTEXPIRED;
예제 #6
0
 /**
  * Handle upload form
  *
  * This function is used to perform all the actions necessary for when creating a directory
  * from within the file manager
  * <br/>Example:
  * <code>
  *   $createFolderForm   = new HTML_QuickForm("create_folder_form", "post", $url, "", null, true);
  *   if ($createFolderForm -> isSubmitted() && $createFolderForm -> validate()) {
  *       $this -> handleCreateDirectoryForm($createFolderForm);
  *   }
  *
  * </code>
  *
  * @param HTML_QuickForm $form The form used to create the directory
  * @return EfrontDirectory The created directory
  * @since 3.5.0
  * @access public
  */
 protected function handleCreateDirectoryForm(&$form)
 {
     $newDir = basename(EfrontDirectory::normalize($form->exportValue('create_directory')));
     if ($form->exportValue('current_directory')) {
         $curDir = EfrontDirectory::normalize($form->exportValue('current_directory'));
     } else {
         $curDir = $this->dir['path'];
     }
     if (strpos($curDir, $this->dir['path']) !== false) {
         $createdDirectory = EfrontDirectory::createDirectory($curDir . '/' . $newDir);
         $this->reset();
     }
     return $createdDirectory;
 }