MDL-48822 mod_forum: Add lastpost class to final post in discussion

Thanks to Lior Gil for the basis of the suggested fix.
This commit is contained in:
Andrew Nicols 2015-01-30 10:14:01 +08:00
parent 4c27f52d91
commit bfa7beceee

View File

@ -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;