Code Duplication    Length = 5-11 lines in 3 locations

main/forum/forumfunction.inc.php 3 locations

@@ 2663-2673 (lines=11) @@
2660
    }
2661
2662
    // Update attached files
2663
    if (!empty($_POST['file_ids']) && is_array($_POST['file_ids'])) {
2664
        foreach ($_POST['file_ids'] as $key => $id) {
2665
            editAttachedFile(
2666
                array(
2667
                    'comment' => $_POST['file_comments'][$key],
2668
                    'post_id' => $last_post_id
2669
                ),
2670
                $id
2671
            );
2672
        }
2673
    }
2674
2675
    // Now we have to update the thread table to fill the thread_last_post
2676
    // field (so that we know when the thread has been updated for the last time).
@@ 3474-3484 (lines=11) @@
3471
            $values['new_post_id'] = $new_post_id;
3472
            $message = get_lang('ReplyAdded');
3473
3474
            if (!empty($_POST['file_ids']) && is_array($_POST['file_ids'])) {
3475
                foreach ($_POST['file_ids'] as $key => $id) {
3476
                    editAttachedFile(
3477
                        array(
3478
                            'comment' => $_POST['file_comments'][$key],
3479
                            'post_id' => $new_post_id,
3480
                        ),
3481
                        $id
3482
                    );
3483
                }
3484
            }
3485
3486
            // Update the thread.
3487
            updateThreadInfo($values['thread_id'], $new_post_id, $post_date);
@@ 3823-3827 (lines=5) @@
3820
    Database::update($table_posts, $params, $where);
3821
3822
    // Update attached files
3823
    if (!empty($_POST['file_ids']) && is_array($_POST['file_ids'])) {
3824
        foreach ($_POST['file_ids'] as $key => $id) {
3825
            editAttachedFile(
3826
                array(
3827
                    'comment' => $_POST['file_comments'][$key],
3828
                    'post_id' => $values['post_id'],
3829
                ),
3830
                $id