From: gustav_delius Date: Fri, 17 Sep 2004 10:28:08 +0000 (+0000) Subject: resolved a conflict ith previous commit X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=5ddaa2e2371073138406ab3658179b5144d12fb4;p=moodle.git resolved a conflict ith previous commit --- diff --git a/mod/forum/lib.php b/mod/forum/lib.php index 22986e8677..573a63db72 100644 --- a/mod/forum/lib.php +++ b/mod/forum/lib.php @@ -1985,17 +1985,13 @@ function forum_print_attachments($post, $return=NULL) { return $imagereturn; } -function forum_add_attachment($post, $newfile) { +function forum_add_attachment($post, $inputname) { // $post is a full post record, including course and forum // $newfile is a full upload array from $_FILES // If successful, this function returns the name of the file global $CFG; - if (empty($newfile['name'])) { - return ""; - } - if (!$forum = get_record("forum", "id", $post->forum)) { return ""; } @@ -2004,35 +2000,13 @@ function forum_add_attachment($post, $newfile) { return ""; } - $maxbytes = get_max_upload_file_size($CFG->maxbytes, $course->maxbytes, $forum->maxbytes); - - $newfile_name = clean_filename($newfile['name']); - - if (valid_uploaded_file($newfile)) { - if ($maxbytes and $newfile['size'] > $maxbytes) { - return ""; - } - if (! $newfile_name) { - notify("This file had a wierd filename and couldn't be uploaded"); - - } else if (! $dir = forum_file_area($post)) { - notify("Attachment could not be stored"); - $newfile_name = ""; - - } else { - if (move_uploaded_file($newfile['tmp_name'], "$dir/$newfile_name")) { - chmod("$dir/$newfile_name", $CFG->directorypermissions); - forum_delete_old_attachments($post, $newfile_name); - } else { - notify("An error happened while saving the file on the server"); - $newfile_name = ""; - } - } - } else { - $newfile_name = ""; + require_once($CFG->dirroot.'/lib/uploadlib.php'); + $um = new upload_manager($inputname,true,false,$course,false,$forum->maxbytes); + $dir = forum_file_area_name($post); + if ($um->process_file_uploads($dir)) { + return $um->get_new_filename(); } - - return $newfile_name; + // upload manager will print any errors. } function forum_add_new_post($post) { @@ -2665,7 +2639,6 @@ function forum_print_posts_threaded($parent, $course, $depth, $ratings, $reply) echo "