From 9946f57258c355129e20fa63d4cee290ef932c56 Mon Sep 17 00:00:00 2001 From: Yannick Warnier Date: Thu, 27 Sep 2012 00:19:16 -0500 Subject: [PATCH] Course copy: Only copy first forum post in any thread to avoid inconsistency when restoring in another course - refs #5462 --- main/coursecopy/classes/CourseBuilder.class.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/main/coursecopy/classes/CourseBuilder.class.php b/main/coursecopy/classes/CourseBuilder.class.php index 4b8e4c24f2..048b2ec733 100644 --- a/main/coursecopy/classes/CourseBuilder.class.php +++ b/main/coursecopy/classes/CourseBuilder.class.php @@ -309,7 +309,7 @@ class CourseBuilder { while ($obj = Database::fetch_object($db_result)) { $forum_topic = new ForumTopic($obj); $this->course->add_resource($forum_topic); - $this->build_forum_posts($obj->thread_id, $obj->forum_id); + $this->build_forum_posts($obj->thread_id, $obj->forum_id, true); } } @@ -317,7 +317,7 @@ class CourseBuilder { * Build the forum-posts * TODO: All tree structure of posts should be built, attachments for example. */ - function build_forum_posts($thread_id = null, $forum_id = null) { + function build_forum_posts($thread_id = null, $forum_id = null, $only_first_post = false) { $table = Database :: get_course_table(TABLE_FORUM_POST); $course_id = api_get_course_int_id(); $sql = "SELECT * FROM $table WHERE c_id = $course_id "; @@ -325,7 +325,8 @@ class CourseBuilder { $forum_id = intval($forum_id); $thread_id = intval($thread_id); $sql .= " AND thread_id = $thread_id AND forum_id = $forum_id "; - } + } + $sql .= " ORDER BY post_id ASC LIMIT 1"; $db_result = Database::query($sql); while ($obj = Database::fetch_object($db_result)) { $forum_post = new ForumPost($obj);