Code Duplication    Length = 5-11 lines in 3 locations

main/forum/forumfunction.inc.php 3 locations

@@ 2525-2535 (lines=11) @@
2522
        }
2523
2524
        // Update attached files
2525
        if (!empty($_POST['file_ids']) && is_array($_POST['file_ids'])) {
2526
            foreach ($_POST['file_ids'] as $key => $id) {
2527
                editAttachedFile(
2528
                    array(
2529
                        'comment' => $_POST['file_comments'][$key],
2530
                        'post_id' => $last_post_id,
2531
                    ),
2532
                    $id
2533
                );
2534
            }
2535
        }
2536
2537
        // Now we have to update the thread table to fill the thread_last_post
2538
        // field (so that we know when the thread has been updated for the last time).
@@ 3302-3312 (lines=11) @@
3299
            $values['new_post_id'] = $new_post_id;
3300
            $message = get_lang('ReplyAdded');
3301
3302
            if (!empty($_POST['file_ids']) && is_array($_POST['file_ids'])) {
3303
                foreach ($_POST['file_ids'] as $key => $id) {
3304
                    editAttachedFile(
3305
                        array(
3306
                            'comment' => $_POST['file_comments'][$key],
3307
                            'post_id' => $new_post_id,
3308
                        ),
3309
                        $id
3310
                    );
3311
                }
3312
            }
3313
3314
            // Update the thread.
3315
            updateThreadInfo($values['thread_id'], $new_post_id, $post_date);
@@ 3622-3626 (lines=5) @@
3619
    Database::update($table_posts, $params, $where);
3620
3621
    // Update attached files
3622
    if (!empty($_POST['file_ids']) && is_array($_POST['file_ids'])) {
3623
        foreach ($_POST['file_ids'] as $key => $id) {
3624
            editAttachedFile(array('comment' => $_POST['file_comments'][$key], 'post_id' => $values['post_id']), $id);
3625
        }
3626
    }
3627
3628
    if (!empty($values['remove_attach'])) {
3629
        delete_attachment($values['post_id']);