MDL-13559 discussion moving; merged from MOODLE_19_STABLE

This commit is contained in:
skodak 2008-02-21 10:31:55 +00:00
parent df612c4203
commit b9973acc4e
2 changed files with 22 additions and 13 deletions

View File

@ -64,7 +64,7 @@
error('Forum not visible', $return);
}
if (!forum_move_attachments($discussion, $forumto)) {
if (!forum_move_attachments($discussion, $forumto->id)) {
notify("Errors occurred while moving attachment directories - check your file permissions");
}
set_field('forum_discussions', 'forum', $forumto->id, 'id', $discussion->id);
@ -76,7 +76,7 @@
// Delete the RSS files for the 2 forums because we want to force
// the regeneration of the feeds since the discussions have been
// moved.
if (!forum_rss_delete_file($forum) || !forum_rss_delete_file($sourceforum)) {
if (!forum_rss_delete_file($forum) || !forum_rss_delete_file($forumto)) {
error('Could not purge the cached RSS feeds for the source and/or'.
'destination forum(s) - check your file permissionsforums', $return);
}

View File

@ -3185,20 +3185,22 @@ function forum_go_back_to($default) {
function forum_file_area_name($post) {
global $CFG;
if (!isset($post->forum)) {
debugging('missing forum', DEBUG_DEVELOPER);
if (!isset($post->forum) or !isset($post->course)) {
debugging('missing forum or course', DEBUG_DEVELOPER);
if (!$discussion = get_record('forum_discussions', 'id', $post->discussion)) {
return false;
}
if (!$forum = get_record('forum', 'id', $discussion->forum)) {
return false;
}
$forumid = $forum->id;
$forumid = $forum->id;
$courseid = $forum->course;
} else {
$forumid = $post->forum;
$forumid = $post->forum;
$courseid = $post->course;
}
return "$post->course/$CFG->moddata/forum/$forumid/$post->id";
return "$courseid/$CFG->moddata/forum/$forumid/$post->id";
}
/**
@ -3364,10 +3366,15 @@ function forum_add_new_post($post,&$message) {
global $USER, $CFG;
$post->created = $post->modified = time();
$post->mailed = "0";
$post->userid = $USER->id;
$discussion = get_record('forum_discussions', 'id', $post->discussion);
$forum = get_record('forum', 'id', $discussion->forum);
$post->created = $post->modified = time();
$post->mailed = "0";
$post->userid = $USER->id;
$post->attachment = "";
$post->forum = $forum->id; // speedup
$post->course = $forum->course; // speedup
if (! $post->id = insert_record("forum_posts", $post)) {
return false;
@ -3431,13 +3438,15 @@ function forum_update_post($post,&$message) {
*/
function forum_add_discussion($discussion,&$message) {
GLOBAL $USER, $CFG;
global $USER, $CFG;
$timenow = time();
// The first post is stored as a real post, and linked
// to from the discuss entry.
$forum = get_record('forum', 'id', $discussion->forum);
$post = new object();
$post->discussion = 0;
$post->parent = 0;
@ -3448,8 +3457,8 @@ function forum_add_discussion($discussion,&$message) {
$post->subject = $discussion->name;
$post->message = $discussion->intro;
$post->attachment = "";
$post->forum = $discussion->forum;
$post->course = $discussion->course;
$post->forum = $forum->id; // speedup
$post->course = $forum->course; // speedup
$post->format = $discussion->format;
$post->mailnow = $discussion->mailnow;