Code Duplication    Length = 5-11 lines in 3 locations

main/forum/forumfunction.inc.php 3 locations

@@ 2671-2681 (lines=11) @@
2668
    }
2669
2670
    // Update attached files
2671
    if (!empty($_POST['file_ids']) && is_array($_POST['file_ids'])) {
2672
        foreach ($_POST['file_ids'] as $key => $id) {
2673
            editAttachedFile(
2674
                array(
2675
                    'comment' => $_POST['file_comments'][$key],
2676
                    'post_id' => $last_post_id
2677
                ),
2678
                $id
2679
            );
2680
        }
2681
    }
2682
2683
    // Now we have to update the thread table to fill the thread_last_post
2684
    // field (so that we know when the thread has been updated for the last time).
@@ 3355-3365 (lines=11) @@
3352
            $values['new_post_id'] = $new_post_id;
3353
            $message = get_lang('ReplyAdded');
3354
3355
            if (!empty($_POST['file_ids']) && is_array($_POST['file_ids'])) {
3356
                foreach ($_POST['file_ids'] as $key => $id) {
3357
                    editAttachedFile(
3358
                        array(
3359
                            'comment' => $_POST['file_comments'][$key],
3360
                            'post_id' => $new_post_id,
3361
                        ),
3362
                        $id
3363
                    );
3364
                }
3365
            }
3366
3367
            // Update the thread.
3368
            updateThreadInfo($values['thread_id'], $new_post_id, $post_date);
@@ 3712-3716 (lines=5) @@
3709
    Database::update($table_posts, $params, $where);
3710
3711
    // Update attached files
3712
    if (!empty($_POST['file_ids']) && is_array($_POST['file_ids'])) {
3713
        foreach ($_POST['file_ids'] as $key => $id) {
3714
            editAttachedFile(
3715
                array(
3716
                    'comment' => $_POST['file_comments'][$key],
3717
                    'post_id' => $values['post_id'],
3718
                ),
3719
                $id