Code Duplication    Length = 7-8 lines in 2 locations

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

@@ 4534-4540 (lines=7) @@
4531
                            // Only one coach is added.
4532
                            if ($onlyAddFirstCoachOrTeacher == true) {
4533
4534
                                foreach ($course_coaches as $course_coach) {
4535
                                    $coach_id = UserManager::get_user_id_from_username($course_coach);
4536
                                    if ($coach_id !== false) {
4537
                                        $teacherToAdd = $coach_id;
4538
                                        break;
4539
                                    }
4540
                                }
4541
4542
                                // Un subscribe everyone that's not in the list.
4543
                                $teacherList = CourseManager::get_teacher_list_from_course_code($course_code);
@@ 4639-4646 (lines=8) @@
4636
                            // All coaches are added.
4637
                            if ($removeAllTeachersFromCourse) {
4638
                                $teacherToAdd = null;
4639
                                foreach ($course_coaches as $course_coach) {
4640
                                    $coach_id = UserManager::get_user_id_from_username(
4641
                                        $course_coach
4642
                                    );
4643
                                    if ($coach_id !== false) {
4644
                                        $teacherToAdd[] = $coach_id;
4645
                                    }
4646
                                }
4647
4648
                                if (!empty($teacherToAdd)) {
4649
                                    // Deleting all course teachers and adding the only coach as teacher.