Code Duplication    Length = 5-11 lines in 3 locations

main/forum/forumfunction.inc.php 3 locations

@@ 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).
@@ 3460-3470 (lines=11) @@
3457
            $values['new_post_id'] = $new_post_id;
3458
            $message = get_lang('ReplyAdded');
3459
3460
            if (!empty($_POST['file_ids']) && is_array($_POST['file_ids'])) {
3461
                foreach ($_POST['file_ids'] as $key => $id) {
3462
                    editAttachedFile(
3463
                        array(
3464
                            'comment' => $_POST['file_comments'][$key],
3465
                            'post_id' => $new_post_id,
3466
                        ),
3467
                        $id
3468
                    );
3469
                }
3470
            }
3471
3472
            // Update the thread.
3473
            updateThreadInfo($values['thread_id'], $new_post_id, $post_date);
@@ 3809-3813 (lines=5) @@
3806
    Database::update($table_posts, $params, $where);
3807
3808
    // Update attached files
3809
    if (!empty($_POST['file_ids']) && is_array($_POST['file_ids'])) {
3810
        foreach ($_POST['file_ids'] as $key => $id) {
3811
            editAttachedFile(
3812
                array(
3813
                    'comment' => $_POST['file_comments'][$key],
3814
                    'post_id' => $values['post_id'],
3815
                ),
3816
                $id