addElement('header', get_lang('CourseLegalAgreement')); $form->addElement('label', null, $course_legal); $form->addElement('hidden', 'course_code', $course_code); $form->addElement('hidden', 'session_id', $session_id); $form->addElement('checkbox', 'accept_legal', null, get_lang('AcceptLegal')); $form->addElement('style_submit_button', null, get_lang('Accept'), 'class="save"'); $variable = 'accept_legal_'.$user_id.'_'.$course_info['real_id'].'_'.$session_id; if ($form->validate()) { $accept_legal = $form->exportValue('accept_legal'); if ($accept_legal == 1) { CourseManager::save_user_legal($user_id, $course_info, $session_id); if (api_check_user_access_to_legal($course_info['visibility'])) { Session::write($variable, true); } } } $user_pass_open_course = false; if (api_check_user_access_to_legal($course_info['visibility']) && Session::read($variable)) { $user_pass_open_course = true; } $url = api_get_course_url($course_code, $session_id); if (empty($session_id)) { if (CourseManager::is_user_subscribed_in_course($user_id, $courseId) || api_check_user_access_to_legal($course_info['visibility'])) { $user_accepted_legal = CourseManager::is_user_accepted_legal($user_id, $course_info); if ($user_accepted_legal || $user_pass_open_course) { //Redirect to course home header('Location: '.$url); exit; } } else { api_not_allowed(); } } else { if (api_is_platform_admin()) { header('Location: '.$url); } $user_session_status = SessionManager::get_user_status_in_course_session($user_id, $courseId, $session_id); if (isset($user_session_status) || api_check_user_access_to_legal($course_info['visibility'])) { $user_accepted_legal = CourseManager::is_user_accepted_legal($user_id, $course_info, $session_id); if ($user_accepted_legal || $user_pass_open_course) { //Redirect to course session home header('Location: '.$url); exit; } } else { api_not_allowed(); } } Display :: display_header($nameTools); $form->display(); Display :: display_footer();