Code Duplication    Length = 5-11 lines in 3 locations

main/forum/forumfunction.inc.php 3 locations

@@ 3816-3820 (lines=5) @@
3813
    Database::update($table_posts, $params, $where);
3814
3815
    // Update attached files
3816
    if (!empty($_POST['file_ids']) && is_array($_POST['file_ids'])) {
3817
        foreach ($_POST['file_ids'] as $key => $id) {
3818
            editAttachedFile(
3819
                array(
3820
                    'comment' => $_POST['file_comments'][$key],
3821
                    'post_id' => $values['post_id'],
3822
                ),
3823
                $id
@@ 2649-2659 (lines=11) @@
2646
    }
2647
2648
    // Update attached files
2649
    if (!empty($_POST['file_ids']) && is_array($_POST['file_ids'])) {
2650
        foreach ($_POST['file_ids'] as $key => $id) {
2651
            editAttachedFile(
2652
                array(
2653
                    'comment' => $_POST['file_comments'][$key],
2654
                    'post_id' => $last_post_id
2655
                ),
2656
                $id
2657
            );
2658
        }
2659
    }
2660
2661
    // Now we have to update the thread table to fill the thread_last_post
2662
    // field (so that we know when the thread has been updated for the last time).
@@ 3466-3476 (lines=11) @@
3463
            $values['new_post_id'] = $new_post_id;
3464
            $message = get_lang('ReplyAdded');
3465
3466
            if (!empty($_POST['file_ids']) && is_array($_POST['file_ids'])) {
3467
                foreach ($_POST['file_ids'] as $key => $id) {
3468
                    editAttachedFile(
3469
                        array(
3470
                            'comment' => $_POST['file_comments'][$key],
3471
                            'post_id' => $new_post_id,
3472
                        ),
3473
                        $id
3474
                    );
3475
                }
3476
            }
3477
3478
            // Update the thread.
3479
            updateThreadInfo($values['thread_id'], $new_post_id, $post_date);