Code Duplication    Length = 17-18 lines in 4 locations

main/inc/lib/fileUpload.lib.php 4 locations

@@ 437-454 (lines=18) @@
434
                                    $sessionId
435
                                );
436
437
                                if ($documentId) {
438
                                    // Put the document in item_property update
439
                                    api_item_property_update(
440
                                        $courseInfo,
441
                                        TOOL_DOCUMENT,
442
                                        $documentId,
443
                                        'DocumentAdded',
444
                                        $userId,
445
                                        $groupId,
446
                                        $toUserId,
447
                                        null,
448
                                        null,
449
                                        $sessionId
450
                                    );
451
452
                                    // Redo visibility
453
                                    api_set_default_visibility($documentId, TOOL_DOCUMENT, null, $courseInfo);
454
                                }
455
                            }
456
457
                            // If the file is in a folder, we need to update all parent folders
@@ 487-504 (lines=18) @@
484
                                $sessionId
485
                            );
486
487
                            if ($documentId) {
488
                                // Put the document in item_property update
489
                                api_item_property_update(
490
                                    $courseInfo,
491
                                    TOOL_DOCUMENT,
492
                                    $documentId,
493
                                    'DocumentAdded',
494
                                    $userId,
495
                                    $groupId,
496
                                    $toUserId,
497
                                    null,
498
                                    null,
499
                                    $sessionId
500
                                );
501
502
                                // Redo visibility
503
                                api_set_default_visibility($documentId, TOOL_DOCUMENT, null, $courseInfo);
504
                            }
505
                            // If the file is in a folder, we need to update all parent folders
506
                            item_property_update_on_folder($courseInfo, $uploadPath, $userId);
507
                            // Display success message to user
@@ 576-593 (lines=18) @@
573
                            $sessionId
574
                        );
575
576
                        if ($documentId) {
577
                            // Update document item_property
578
                            api_item_property_update(
579
                                $courseInfo,
580
                                TOOL_DOCUMENT,
581
                                $documentId,
582
                                'DocumentAdded',
583
                                $userId,
584
                                $groupId,
585
                                $toUserId,
586
                                null,
587
                                null,
588
                                $sessionId
589
                            );
590
591
                            // Redo visibility
592
                            api_set_default_visibility($documentId, TOOL_DOCUMENT, null, $courseInfo);
593
                        }
594
595
                        // If the file is in a folder, we need to update all parent folders
596
                        item_property_update_on_folder($courseInfo, $uploadPath, $userId);
@@ 655-671 (lines=17) @@
652
                                $sessionId
653
                            );
654
655
                            if ($documentId) {
656
                                // Update document item_property
657
                                api_item_property_update(
658
                                    $courseInfo,
659
                                    TOOL_DOCUMENT,
660
                                    $documentId,
661
                                    'DocumentAdded',
662
                                    $userId,
663
                                    $groupId,
664
                                    $toUserId,
665
                                    null,
666
                                    null,
667
                                    $sessionId
668
                                );
669
                                // Redo visibility
670
                                api_set_default_visibility($documentId, TOOL_DOCUMENT, null, $courseInfo);
671
                            }
672
673
                            // If the file is in a folder, we need to update all parent folders
674
                            item_property_update_on_folder(