Code Duplication    Length = 11-15 lines in 2 locations

main/forum/forumfunction.inc.php 2 locations

@@ 1621-1635 (lines=15) @@
1618
    (last_post_id, last_poster_id, last_post_date, last_poster_name, last_poster_lastname, last_poster_firstname)*/
1619
    if ($id == '') {
1620
        if (is_array($forum_list)) {
1621
            foreach ($forum_list as $key => $value) {
1622
                $last_post_info_of_forum = get_last_post_information(
1623
                    $key,
1624
                    api_is_allowed_to_edit(),
1625
                    $course_id
1626
                );
1627
1628
                if ($last_post_info_of_forum) {
1629
                    $forum_list[$key]['last_post_id'] = $last_post_info_of_forum['last_post_id'];
1630
                    $forum_list[$key]['last_poster_id'] = $last_post_info_of_forum['last_poster_id'];
1631
                    $forum_list[$key]['last_post_date'] = $last_post_info_of_forum['last_post_date'];
1632
                    $forum_list[$key]['last_poster_name'] = $last_post_info_of_forum['last_poster_name'];
1633
                    $forum_list[$key]['last_poster_lastname'] = $last_post_info_of_forum['last_poster_lastname'];
1634
                    $forum_list[$key]['last_poster_firstname'] = $last_post_info_of_forum['last_poster_firstname'];
1635
                }
1636
            }
1637
        } else {
1638
            $forum_list = array();
@@ 5022-5032 (lines=11) @@
5019
    // Finding the last post information
5020
    // (last_post_id, last_poster_id, last_post_date, last_poster_name, last_poster_lastname, last_poster_firstname).
5021
    if (!empty($forum_list)) {
5022
        foreach ($forum_list as $key => $value) {
5023
            $last_post_info_of_forum = get_last_post_information($key, api_is_allowed_to_edit());
5024
            if ($last_post_info_of_forum) {
5025
                $forum_list[$key]['last_post_id'] = $last_post_info_of_forum['last_post_id'];
5026
                $forum_list[$key]['last_poster_id'] = $last_post_info_of_forum['last_poster_id'];
5027
                $forum_list[$key]['last_post_date'] = $last_post_info_of_forum['last_post_date'];
5028
                $forum_list[$key]['last_poster_name'] = $last_post_info_of_forum['last_poster_name'];
5029
                $forum_list[$key]['last_poster_lastname'] = $last_post_info_of_forum['last_poster_lastname'];
5030
                $forum_list[$key]['last_poster_firstname'] = $last_post_info_of_forum['last_poster_firstname'];
5031
            }
5032
        }
5033
    }
5034
5035
    return $forum_list;