mirror of
https://github.com/moodle/moodle.git
synced 2025-02-01 13:28:17 +01:00
Fix for forums to behave slightly in a more friendly manner for reporting stuff about file uploads.
Also told upload class to not complain if there isn't a file selected. 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-81 2004-09-19 23:48:54 GMT Penny Leach <penny@catalyst.net.nz> fix for forum to print out messages including virus stuff and increase in time before redirect as there is more to read Full logs: Revision: moodle--eduforge--1.3.3--patch-81 Archive: arch-eduforge@catalyst.net.nz--2004 Creator: Penny Leach <penny@catalyst.net.nz> Date: Mon Sep 20 11:48:54 NZST 2004 Standard-date: 2004-09-19 23:48:54 GMT Modified-files: mod/forum/lib.php mod/forum/post.php New-patches: arch-eduforge@catalyst.net.nz--2004/moodle--eduforge--1.3.3--patch-81 Summary: fix for forum to print out messages including virus stuff and increase in time before redirect as there is more to read Keywords:
This commit is contained in:
parent
02ce384808
commit
db290a6efc
@ -1984,11 +1984,14 @@ function forum_print_attachments($post, $return=NULL) {
|
||||
|
||||
return $imagereturn;
|
||||
}
|
||||
/**
|
||||
* If successful, this function returns the name of the file
|
||||
* @param $post is a full post record, including course and forum
|
||||
* @param $newfile is a full upload array from $_FILES
|
||||
* @param $message is a string to hold the messages.
|
||||
*/
|
||||
|
||||
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
|
||||
function forum_add_attachment($post, $inputname,&$message) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
@ -2001,15 +2004,16 @@ function forum_add_attachment($post, $inputname) {
|
||||
}
|
||||
|
||||
require_once($CFG->dirroot.'/lib/uploadlib.php');
|
||||
$um = new upload_manager($inputname,true,false,$course,false,$forum->maxbytes);
|
||||
$um = new upload_manager($inputname,true,false,$course,false,$forum->maxbytes,true,true);
|
||||
$dir = forum_file_area_name($post);
|
||||
if ($um->process_file_uploads($dir)) {
|
||||
$message .= $um->get_errors();
|
||||
return $um->get_new_filename();
|
||||
}
|
||||
// upload manager will print any errors.
|
||||
$message .= $um->get_errors();
|
||||
}
|
||||
|
||||
function forum_add_new_post($post) {
|
||||
function forum_add_new_post($post,&$message) {
|
||||
|
||||
$post->created = $post->modified = time();
|
||||
$post->mailed = "0";
|
||||
@ -2020,7 +2024,7 @@ function forum_add_new_post($post) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($post->attachment = forum_add_attachment($post, 'attachment')) {
|
||||
if ($post->attachment = forum_add_attachment($post, 'attachment',$message)) {
|
||||
set_field("forum_posts", "attachment", $post->attachment, "id", $post->id);
|
||||
}
|
||||
|
||||
@ -2031,7 +2035,7 @@ function forum_add_new_post($post) {
|
||||
return $post->id;
|
||||
}
|
||||
|
||||
function forum_update_post($post) {
|
||||
function forum_update_post($post,&$message) {
|
||||
|
||||
$post->modified = time();
|
||||
|
||||
@ -2039,7 +2043,7 @@ function forum_update_post($post) {
|
||||
set_field("forum_discussions", "name", $post->subject, "id", $post->discussion);
|
||||
}
|
||||
|
||||
if ($newfilename = forum_add_attachment($post, 'attachment')) {
|
||||
if ($newfilename = forum_add_attachment($post, 'attachment',$message)) {
|
||||
$post->attachment = $newfilename;
|
||||
} else {
|
||||
unset($post->attachment);
|
||||
@ -2052,7 +2056,7 @@ function forum_update_post($post) {
|
||||
return update_record("forum_posts", $post);
|
||||
}
|
||||
|
||||
function forum_add_discussion($discussion) {
|
||||
function forum_add_discussion($discussion,&$message) {
|
||||
// Given an object containing all the necessary data,
|
||||
// create a new discussion and return the id
|
||||
|
||||
@ -2080,7 +2084,7 @@ function forum_add_discussion($discussion) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ($post->attachment = forum_add_attachment($post, 'attachment')) {
|
||||
if ($post->attachment = forum_add_attachment($post, 'attachment',$message)) {
|
||||
set_field("forum_posts", "attachment", $post->attachment, "id", $post->id); //ignore errors
|
||||
}
|
||||
|
||||
|
@ -43,16 +43,20 @@
|
||||
|
||||
} else if ($post->edit) { // Updating a post
|
||||
$post->id = $post->edit;
|
||||
if (forum_update_post($post)) {
|
||||
|
||||
$message = '';
|
||||
if (forum_update_post($post,$message)) {
|
||||
|
||||
add_to_log($post->course, "forum", "update post",
|
||||
"discuss.php?d=$post->discussion&parent=$post->id", "$post->id", $cm->id);
|
||||
|
||||
$message = get_string("postupdated", "forum");
|
||||
$timemessage = 1;
|
||||
|
||||
$timemessage = 2;
|
||||
if (!empty($message)) { // if we're printing stuff about the file upload
|
||||
$timemessage = 4;
|
||||
}
|
||||
$message .= '<br />'.get_string("postupdated", "forum");
|
||||
|
||||
if ($subscribemessage = forum_post_subscription($post)) {
|
||||
$timemessage = 2;
|
||||
$timemessage = 4;
|
||||
}
|
||||
redirect(forum_go_back_to("discuss.php?d=$post->discussion#$post->id"), $message.$subscribemessage, $timemessage);
|
||||
|
||||
@ -62,13 +66,17 @@
|
||||
exit;
|
||||
|
||||
} else if ($post->discussion) { // Adding a new post to an existing discussion
|
||||
if ($post->id = forum_add_new_post($post)) {
|
||||
$message = '';
|
||||
if ($post->id = forum_add_new_post($post,$message)) {
|
||||
|
||||
add_to_log($post->course, "forum", "add post",
|
||||
"discuss.php?d=$post->discussion&parent=$post->id", "$post->id", $cm->id);
|
||||
|
||||
$message = get_string("postadded", "forum", format_time($CFG->maxeditingtime));
|
||||
$timemessage = 2;
|
||||
if (!empty($message)) { // if we're printing stuff about the file upload
|
||||
$timemessage = 4;
|
||||
}
|
||||
$message .= '<br />'.get_string("postadded", "forum", format_time($CFG->maxeditingtime));
|
||||
|
||||
if ($subscribemessage = forum_post_subscription($post)) {
|
||||
$timemessage = 4;
|
||||
@ -85,14 +93,18 @@
|
||||
$discussion = $post;
|
||||
$discussion->name = $post->subject;
|
||||
$discussion->intro = $post->message;
|
||||
if ($discussion->id = forum_add_discussion($discussion)) {
|
||||
$message = '';
|
||||
if ($discussion->id = forum_add_discussion($discussion,$message)) {
|
||||
|
||||
add_to_log($post->course, "forum", "add discussion",
|
||||
"discuss.php?d=$discussion->id", "$discussion->id", $cm->id);
|
||||
|
||||
$message = get_string("postadded", "forum", format_time($CFG->maxeditingtime));
|
||||
$timemessage = 2;
|
||||
|
||||
if (!empty($message)) { // if we're printing stuff about the file upload
|
||||
$timemessage = 4;
|
||||
}
|
||||
$message .= '<br />'.get_string("postadded", "forum", format_time($CFG->maxeditingtime));
|
||||
|
||||
if ($subscribemessage = forum_post_subscription($discussion)) {
|
||||
$timemessage = 4;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user