Code Duplication    Length = 13-13 lines in 3 locations

main/inc/lib/AnnouncementManager.php 3 locations

@@ 651-663 (lines=13) @@
648
                // when no user is selected we send it to everyone
649
                $send_to = CourseManager::separateUsersGroups($to);
650
                // storing the selected groups
651
                if (is_array($send_to['groups'])) {
652
                    foreach ($send_to['groups'] as $group) {
653
                        $groupInfo = GroupManager::get_group_properties($group);
654
                        api_item_property_update(
655
                            $_course,
656
                            TOOL_ANNOUNCEMENT,
657
                            $last_id,
658
                            'AnnouncementAdded',
659
                            api_get_user_id(),
660
                            $groupInfo
661
                        );
662
                    }
663
                }
664
            } else {
665
                $send_to_groups = CourseManager::separateUsersGroups($to);
666
                $send_to_users = CourseManager::separateUsersGroups($to_users);
@@ 766-778 (lines=13) @@
763
            $send_to = CourseManager::separateUsersGroups($to);
764
765
            // storing the selected groups
766
            if (is_array($send_to['groups'])) {
767
                foreach ($send_to['groups'] as $group) {
768
                    $groupInfo = GroupManager::get_group_properties($group);
769
                    api_item_property_update(
770
                        $_course,
771
                        TOOL_ANNOUNCEMENT,
772
                        $id,
773
                        'AnnouncementUpdated',
774
                        api_get_user_id(),
775
                        $groupInfo
776
                    );
777
                }
778
            }
779
780
            // storing the selected users
781
            if (is_array($send_to['users'])) {
@@ 781-793 (lines=13) @@
778
            }
779
780
            // storing the selected users
781
            if (is_array($send_to['users'])) {
782
                foreach ($send_to['users'] as $user) {
783
                    api_item_property_update(
784
                        $_course,
785
                        TOOL_ANNOUNCEMENT,
786
                        $id,
787
                        'AnnouncementUpdated',
788
                        api_get_user_id(),
789
                        0,
790
                        $user
791
                    );
792
                }
793
            }
794
795
            // Send to everyone
796
            if (isset($to[0]) && $to[0] === 'everyone') {