Code Duplication    Length = 7-8 lines in 2 locations

main/inc/lib/sessionmanager.lib.php 2 locations

@@ 4764-4770 (lines=7) @@
4761
                            // Only one coach is added.
4762
                            if ($onlyAddFirstCoachOrTeacher == true) {
4763
4764
                                foreach ($course_coaches as $course_coach) {
4765
                                    $coach_id = UserManager::get_user_id_from_username($course_coach);
4766
                                    if ($coach_id !== false) {
4767
                                        $teacherToAdd = $coach_id;
4768
                                        break;
4769
                                    }
4770
                                }
4771
4772
                                // Un subscribe everyone that's not in the list.
4773
                                $teacherList = CourseManager::get_teacher_list_from_course_code($course_code);
@@ 4869-4876 (lines=8) @@
4866
                            // All coaches are added.
4867
                            if ($removeAllTeachersFromCourse) {
4868
                                $teacherToAdd = null;
4869
                                foreach ($course_coaches as $course_coach) {
4870
                                    $coach_id = UserManager::get_user_id_from_username(
4871
                                        $course_coach
4872
                                    );
4873
                                    if ($coach_id !== false) {
4874
                                        $teacherToAdd[] = $coach_id;
4875
                                    }
4876
                                }
4877
4878
                                if (!empty($teacherToAdd)) {
4879
                                    // Deleting all course teachers and adding the only coach as teacher.