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();
@@ 5046-5056 (lines=11) @@
5043
    // Finding the last post information
5044
    // (last_post_id, last_poster_id, last_post_date, last_poster_name, last_poster_lastname, last_poster_firstname).
5045
    if (!empty($forum_list)) {
5046
        foreach ($forum_list as $key => $value) {
5047
            $last_post_info_of_forum = get_last_post_information($key, api_is_allowed_to_edit());
5048
            if ($last_post_info_of_forum) {
5049
                $forum_list[$key]['last_post_id'] = $last_post_info_of_forum['last_post_id'];
5050
                $forum_list[$key]['last_poster_id'] = $last_post_info_of_forum['last_poster_id'];
5051
                $forum_list[$key]['last_post_date'] = $last_post_info_of_forum['last_post_date'];
5052
                $forum_list[$key]['last_poster_name'] = $last_post_info_of_forum['last_poster_name'];
5053
                $forum_list[$key]['last_poster_lastname'] = $last_post_info_of_forum['last_poster_lastname'];
5054
                $forum_list[$key]['last_poster_firstname'] = $last_post_info_of_forum['last_poster_firstname'];
5055
            }
5056
        }
5057
    }
5058
5059
    return $forum_list;