Code Duplication    Length = 11-15 lines in 2 locations

main/forum/forumfunction.inc.php 2 locations

@@ 1622-1636 (lines=15) @@
1619
    (last_post_id, last_poster_id, last_post_date, last_poster_name, last_poster_lastname, last_poster_firstname)*/
1620
    if ($id == '') {
1621
        if (is_array($forum_list)) {
1622
            foreach ($forum_list as $key => $value) {
1623
                $last_post_info_of_forum = get_last_post_information(
1624
                    $key,
1625
                    api_is_allowed_to_edit(),
1626
                    $course_id
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();
1639
        }
@@ 5150-5160 (lines=11) @@
5147
5148
    // Finding the last post information (last_post_id, last_poster_id, last_post_date, last_poster_name, last_poster_lastname, last_poster_firstname).
5149
    if (!empty($forum_list)) {
5150
        foreach ($forum_list as $key => $value) {
5151
            $last_post_info_of_forum = get_last_post_information($key, api_is_allowed_to_edit());
5152
            if ($last_post_info_of_forum) {
5153
                $forum_list[$key]['last_post_id'] = $last_post_info_of_forum['last_post_id'];
5154
                $forum_list[$key]['last_poster_id'] = $last_post_info_of_forum['last_poster_id'];
5155
                $forum_list[$key]['last_post_date'] = $last_post_info_of_forum['last_post_date'];
5156
                $forum_list[$key]['last_poster_name'] = $last_post_info_of_forum['last_poster_name'];
5157
                $forum_list[$key]['last_poster_lastname'] = $last_post_info_of_forum['last_poster_lastname'];
5158
                $forum_list[$key]['last_poster_firstname'] = $last_post_info_of_forum['last_poster_firstname'];
5159
            }
5160
        }
5161
    }
5162
5163
    return $forum_list;