Code Duplication    Length = 5-11 lines in 3 locations

main/forum/forumfunction.inc.php 3 locations

@@ 2517-2527 (lines=11) @@
2514
        }
2515
2516
        // Update attached files
2517
        if (!empty($_POST['file_ids']) && is_array($_POST['file_ids'])) {
2518
            foreach ($_POST['file_ids'] as $key => $id) {
2519
                editAttachedFile(
2520
                    array(
2521
                        'comment' => $_POST['file_comments'][$key],
2522
                        'post_id' => $last_post_id,
2523
                    ),
2524
                    $id
2525
                );
2526
            }
2527
        }
2528
2529
        // Now we have to update the thread table to fill the thread_last_post
2530
        // field (so that we know when the thread has been updated for the last time).
@@ 3290-3300 (lines=11) @@
3287
            $values['new_post_id'] = $new_post_id;
3288
            $message = get_lang('ReplyAdded');
3289
3290
            if (!empty($_POST['file_ids']) && is_array($_POST['file_ids'])) {
3291
                foreach ($_POST['file_ids'] as $key => $id) {
3292
                    editAttachedFile(
3293
                        array(
3294
                            'comment' => $_POST['file_comments'][$key],
3295
                            'post_id' => $new_post_id,
3296
                        ),
3297
                        $id
3298
                    );
3299
                }
3300
            }
3301
3302
            // Update the thread.
3303
            updateThreadInfo($values['thread_id'], $new_post_id, $post_date);
@@ 3610-3614 (lines=5) @@
3607
    Database::update($table_posts, $params, $where);
3608
3609
    // Update attached files
3610
    if (!empty($_POST['file_ids']) && is_array($_POST['file_ids'])) {
3611
        foreach ($_POST['file_ids'] as $key => $id) {
3612
            editAttachedFile(array('comment' => $_POST['file_comments'][$key], 'post_id' => $values['post_id']), $id);
3613
        }
3614
    }
3615
3616
    if (!empty($values['remove_attach'])) {
3617
        delete_attachment($values['post_id']);