Code Duplication    Length = 5-11 lines in 3 locations

main/forum/forumfunction.inc.php 3 locations

@@ 2708-2718 (lines=11) @@
2705
    }
2706
2707
    // Update attached files
2708
    if (!empty($_POST['file_ids']) && is_array($_POST['file_ids'])) {
2709
        foreach ($_POST['file_ids'] as $key => $id) {
2710
            editAttachedFile(
2711
                array(
2712
                    'comment' => $_POST['file_comments'][$key],
2713
                    'post_id' => $lastPostId
2714
                ),
2715
                $id
2716
            );
2717
        }
2718
    }
2719
2720
    // Now we have to update the thread table to fill the thread_last_post
2721
    // field (so that we know when the thread has been updated for the last time).
@@ 3402-3412 (lines=11) @@
3399
            $values['new_post_id'] = $new_post_id;
3400
            $message = get_lang('ReplyAdded');
3401
3402
            if (!empty($_POST['file_ids']) && is_array($_POST['file_ids'])) {
3403
                foreach ($_POST['file_ids'] as $key => $id) {
3404
                    editAttachedFile(
3405
                        array(
3406
                            'comment' => $_POST['file_comments'][$key],
3407
                            'post_id' => $new_post_id,
3408
                        ),
3409
                        $id
3410
                    );
3411
                }
3412
            }
3413
3414
            // Update the thread.
3415
            updateThreadInfo($values['thread_id'], $new_post_id, $post_date);
@@ 3692-3696 (lines=5) @@
3689
    Database::update($table_posts, $params, $where);
3690
3691
    // Update attached files
3692
    if (!empty($_POST['file_ids']) && is_array($_POST['file_ids'])) {
3693
        foreach ($_POST['file_ids'] as $key => $id) {
3694
            editAttachedFile(
3695
                array(
3696
                    'comment' => $_POST['file_comments'][$key],
3697
                    'post_id' => $values['post_id'],
3698
                ),
3699
                $id