From 966620586efabe310c83e6519c4bc47eaa13401b Mon Sep 17 00:00:00 2001 From: moodler Date: Thu, 14 Sep 2006 07:13:08 +0000 Subject: [PATCH] Better handling of forum id/object --- mod/forum/post.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/mod/forum/post.php b/mod/forum/post.php index 987c197d60..4b3ee5ab2c 100644 --- a/mod/forum/post.php +++ b/mod/forum/post.php @@ -72,6 +72,12 @@ if (!$course = get_record('course', 'id', $post->course)) { error('Could not find specified course!'); } + + if (!empty($forum)) { // Check the forum id and change it to a full object + if (! $forum = get_record('forum', 'id', $forum)) { + error('The forum number was incorrect'); + } + } if (!empty($course->lang)) { // Override current language $CFG->courselang = $course->lang; @@ -113,7 +119,7 @@ error("You can not update this post"); } - if (get_field('forum', 'type', 'id', $forum->id) == 'news' && !$post->parent) { + if ($forum->type == 'news' && !$post->parent) { $updatediscussion = new object; $updatediscussion->id = $post->discussion; if (empty($post->timestartdisabled)) { @@ -193,7 +199,7 @@ $discussion->intro = $post->message; $newstopic = false; - if (get_field('forum', 'type', 'id', $forum->id) == 'news' && !$post->parent) { + if ($forum->type == 'news' && !$post->parent) { $newstopic = true; } if ($newstopic && empty($post->timestartdisabled)) { @@ -739,4 +745,4 @@ print_footer($course); -?> \ No newline at end of file +?> -- 2.39.5