Code Duplication    Length = 11-15 lines in 2 locations

main/forum/forumfunction.inc.php 2 locations

@@ 1616-1630 (lines=15) @@
1613
    (last_post_id, last_poster_id, last_post_date, last_poster_name, last_poster_lastname, last_poster_firstname)*/
1614
    if ($id == '') {
1615
        if (is_array($forum_list)) {
1616
            foreach ($forum_list as $key => $value) {
1617
                $last_post_info_of_forum = get_last_post_information(
1618
                    $key,
1619
                    api_is_allowed_to_edit(),
1620
                    $course_id
1621
                );
1622
1623
                if ($last_post_info_of_forum) {
1624
                    $forum_list[$key]['last_post_id'] = $last_post_info_of_forum['last_post_id'];
1625
                    $forum_list[$key]['last_poster_id'] = $last_post_info_of_forum['last_poster_id'];
1626
                    $forum_list[$key]['last_post_date'] = $last_post_info_of_forum['last_post_date'];
1627
                    $forum_list[$key]['last_poster_name'] = $last_post_info_of_forum['last_poster_name'];
1628
                    $forum_list[$key]['last_poster_lastname'] = $last_post_info_of_forum['last_poster_lastname'];
1629
                    $forum_list[$key]['last_poster_firstname'] = $last_post_info_of_forum['last_poster_firstname'];
1630
                }
1631
            }
1632
        } else {
1633
            $forum_list = array();
@@ 5157-5167 (lines=11) @@
5154
    // Finding the last post information
5155
    // (last_post_id, last_poster_id, last_post_date, last_poster_name, last_poster_lastname, last_poster_firstname).
5156
    if (!empty($forum_list)) {
5157
        foreach ($forum_list as $key => $value) {
5158
            $last_post_info_of_forum = get_last_post_information($key, api_is_allowed_to_edit());
5159
            if ($last_post_info_of_forum) {
5160
                $forum_list[$key]['last_post_id'] = $last_post_info_of_forum['last_post_id'];
5161
                $forum_list[$key]['last_poster_id'] = $last_post_info_of_forum['last_poster_id'];
5162
                $forum_list[$key]['last_post_date'] = $last_post_info_of_forum['last_post_date'];
5163
                $forum_list[$key]['last_poster_name'] = $last_post_info_of_forum['last_poster_name'];
5164
                $forum_list[$key]['last_poster_lastname'] = $last_post_info_of_forum['last_poster_lastname'];
5165
                $forum_list[$key]['last_poster_firstname'] = $last_post_info_of_forum['last_poster_firstname'];
5166
            }
5167
        }
5168
    }
5169
5170
    return $forum_list;