Code Duplication    Length = 7-8 lines in 2 locations

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

@@ 4755-4761 (lines=7) @@
4752
                            // Only one coach is added.
4753
                            if ($onlyAddFirstCoachOrTeacher == true) {
4754
4755
                                foreach ($course_coaches as $course_coach) {
4756
                                    $coach_id = UserManager::get_user_id_from_username($course_coach);
4757
                                    if ($coach_id !== false) {
4758
                                        $teacherToAdd = $coach_id;
4759
                                        break;
4760
                                    }
4761
                                }
4762
4763
                                // Un subscribe everyone that's not in the list.
4764
                                $teacherList = CourseManager::get_teacher_list_from_course_code($course_code);
@@ 4860-4867 (lines=8) @@
4857
                            // All coaches are added.
4858
                            if ($removeAllTeachersFromCourse) {
4859
                                $teacherToAdd = null;
4860
                                foreach ($course_coaches as $course_coach) {
4861
                                    $coach_id = UserManager::get_user_id_from_username(
4862
                                        $course_coach
4863
                                    );
4864
                                    if ($coach_id !== false) {
4865
                                        $teacherToAdd[] = $coach_id;
4866
                                    }
4867
                                }
4868
4869
                                if (!empty($teacherToAdd)) {
4870
                                    // Deleting all course teachers and adding the only coach as teacher.