From 3dc2cd2deef01066ef43d2f66eba3d6190d6388e Mon Sep 17 00:00:00 2001 From: mjollnir_ Date: Thu, 16 Sep 2004 04:25:55 +0000 Subject: [PATCH] Integration of upload code with lesson. These patches are maintained in an publicly accessible Arch repository, see: http://lists.eduforge.org/cgi-bin/archzoom.cgi/arch-eduforge@catalyst.net.nz--2004-MIRROR/moodle--eduforge--1.3.3 Index of arch patches in this commit: arch-eduforge@catalyst.net.nz--2004/moodle--eduforge--1.3.3--patch-68 2004-09-16 04:22:37 GMT Penny Leach upload class integration with lesson Full logs: Revision: moodle--eduforge--1.3.3--patch-68 Archive: arch-eduforge@catalyst.net.nz--2004 Creator: Penny Leach Date: Thu Sep 16 16:22:37 NZST 2004 Standard-date: 2004-09-16 04:22:37 GMT Modified-files: mod/lesson/import.php New-patches: arch-eduforge@catalyst.net.nz--2004/moodle--eduforge--1.3.3--patch-68 Summary: upload class integration with lesson Keywords: --- mod/lesson/import.php | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/mod/lesson/import.php b/mod/lesson/import.php index 0752a76582..6646d312ae 100644 --- a/mod/lesson/import.php +++ b/mod/lesson/import.php @@ -34,22 +34,20 @@ "id>$strlessons -> id\">$lesson->name-> $strimportquestions"); if ($form = data_submitted()) { /// Filename - + if (isset($form->filename)) { // file already on server $newfile['tmp_name'] = $form->filename; $newfile['size'] = filesize($form->filename); } else if (!empty($_FILES['newfile'])) { // file was just uploaded - $newfile = $_FILES['newfile']; + require_once($CFG->dirroot.'/lib/uploadlib.php'); + $um = new upload_manager('newfile',false,false,$course,false,0,false); + if ($um->preprocess_files()) { // validate and virus check! + $newfile = $_FILES['newfile']; + } } - if (empty($newfile)) { - notify(get_string("uploadproblem") ); - - } else if (!isset($filename) and (!is_uploaded_file($newfile['tmp_name']) or $newfile['size'] == 0)) { - notify(get_string("uploadnofilefound") ); - - } else { // Valid file is found + if (is_array($newfile)) { // either for file already on server or just uploaded file. if (! is_readable("../quiz/format/$form->format/format.php")) { error("Format not known ($form->format)"); -- 2.39.5