Code Duplication    Length = 7-8 lines in 2 locations

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

@@ 4543-4549 (lines=7) @@
4540
                            // Only one coach is added.
4541
                            if ($onlyAddFirstCoachOrTeacher == true) {
4542
4543
                                foreach ($course_coaches as $course_coach) {
4544
                                    $coach_id = UserManager::get_user_id_from_username($course_coach);
4545
                                    if ($coach_id !== false) {
4546
                                        $teacherToAdd = $coach_id;
4547
                                        break;
4548
                                    }
4549
                                }
4550
4551
                                // Un subscribe everyone that's not in the list.
4552
                                $teacherList = CourseManager::get_teacher_list_from_course_code($course_code);
@@ 4648-4655 (lines=8) @@
4645
                            // All coaches are added.
4646
                            if ($removeAllTeachersFromCourse) {
4647
                                $teacherToAdd = null;
4648
                                foreach ($course_coaches as $course_coach) {
4649
                                    $coach_id = UserManager::get_user_id_from_username(
4650
                                        $course_coach
4651
                                    );
4652
                                    if ($coach_id !== false) {
4653
                                        $teacherToAdd[] = $coach_id;
4654
                                    }
4655
                                }
4656
4657
                                if (!empty($teacherToAdd)) {
4658
                                    // Deleting all course teachers and adding the only coach as teacher.