diff --git a/main/tracking/courseLog.php b/main/tracking/courseLog.php index bb48059ad2..2200f0ee11 100755 --- a/main/tracking/courseLog.php +++ b/main/tracking/courseLog.php @@ -50,21 +50,28 @@ if (api_is_drh()) { if (api_drh_can_access_all_session_content()) { // If the drh has been configured to be allowed to see all session content, give him access to the session courses $coursesFromSession = SessionManager::getAllCoursesFollowedByUser(api_get_user_id(), null); + + $coursesFromSessionCodeList = array(); if (!empty($coursesFromSession)) { - $coursesFromSession = array_keys($coursesFromSession); + foreach ($coursesFromSession as $course) { + $coursesFromSessionCodeList[$course['code']] = $course['code']; + } } $coursesFollowedList = CourseManager::get_courses_followed_by_drh(api_get_user_id()); + if (!empty($coursesFollowedList)) { $coursesFollowedList = array_keys($coursesFollowedList); } + if (!in_array($courseCode, $coursesFollowedList)) { - if (!in_array($courseCode, $coursesFromSession)) { + if (!in_array($courseCode, $coursesFromSessionCodeList)) { api_not_allowed(); } } } else { - // If the drh has *not* been configured to be allowed to see all session content, then check if he has also been given access to the corresponding courses + // If the drh has *not* been configured to be allowed to see all session content, + // then check if he has also been given access to the corresponding courses $coursesFollowedList = CourseManager::get_courses_followed_by_drh(api_get_user_id()); $coursesFollowedList = array_keys($coursesFollowedList); if (!in_array(api_get_course_id(), $coursesFollowedList)) {