diff --git a/mod/forum/lib.php b/mod/forum/lib.php index d400f474805..e2b0f59e981 100644 --- a/mod/forum/lib.php +++ b/mod/forum/lib.php @@ -1950,6 +1950,20 @@ function forum_get_all_discussion_posts($discussionid, $sort, $tracking=false) { $posts[$p->parent]->children[$pid] =& $posts[$pid]; } + // Start with the last child of the first post. + $post = &$posts[reset($posts)->id]; + + $lastpost = false; + while (!$lastpost) { + if (!isset($post->children)) { + $post->lastpost = true; + $lastpost = true; + } else { + // Go to the last child of this post. + $post = &$posts[end($post->children)->id]; + } + } + return $posts; } @@ -3377,6 +3391,10 @@ function forum_print_post($post, $discussion, $forum, &$cm, $course, $ownpost=fa $topicclass = ' firstpost starter'; } + if (!empty($post->lastpost)) { + $forumpostclass = ' lastpost'; + } + $postbyuser = new stdClass; $postbyuser->post = $post->subject; $postbyuser->user = $postuser->fullname;