tpl = new Template($title); $this->home = api_get_home_path(); $this->user_id = api_get_user_id(); $this->load_directories_preview = false; // Load footer plugins systematically /*$config = api_get_settings_params(array('subkey = ? ' => 'customfooter', ' AND category = ? ' => 'Plugins')); if (!empty($config)) { foreach ($config as $fooid => $configrecord) { $canonic = preg_replace('/^customfooter_/', '', $configrecord['variable']); $footerconfig->$canonic = $configrecord['selected_value']; } if (!empty($footerconfig->footer_left)) { $this->tpl->assign('plugin_footer_left', $footerconfig->footer_left); } if (!empty($footerconfig->footer_right)) { $this->tpl->assign('plugin_footer_right', $footerconfig->footer_right); } }*/ if (api_get_setting('show_documents_preview') === 'true') { $this->load_directories_preview = true; } } /** * @param bool $setLoginForm */ public function set_login_form($setLoginForm = true) { global $loginFailed; $this->tpl->setLoginForm($setLoginForm); } /** * @param array $personal_course_list */ public function return_exercise_block($personal_course_list) { $exercise_list = []; if (!empty($personal_course_list)) { foreach ($personal_course_list as $course_item) { $course_code = $course_item['c']; $session_id = $course_item['id_session']; $exercises = ExerciseLib::get_exercises_to_be_taken( $course_code, $session_id ); foreach ($exercises as $exercise_item) { $exercise_item['course_code'] = $course_code; $exercise_item['session_id'] = $session_id; $exercise_item['tms'] = api_strtotime($exercise_item['end_time'], 'UTC'); $exercise_list[] = $exercise_item; } } if (!empty($exercise_list)) { $exercise_list = msort($exercise_list, 'tms'); $my_exercise = $exercise_list[0]; $url = Display::url( $my_exercise['title'], api_get_path(WEB_CODE_PATH).'exercise/overview.php?exerciseId='.$my_exercise['id'].'&cidReq='.$my_exercise['course_code'].'&id_session='.$my_exercise['session_id'] ); $this->tpl->assign('exercise_url', $url); $this->tpl->assign( 'exercise_end_date', api_convert_and_format_date($my_exercise['end_time'], DATE_FORMAT_SHORT) ); } } } /** * @param bool $show_slide * * @return null|string */ public function return_announcements($show_slide = true) { $hideAnnouncements = api_get_setting('hide_global_announcements_when_not_connected'); $currentUserId = api_get_user_id(); if ($hideAnnouncements == 'true' && empty($currentUserId)) { return null; } $announcement = isset($_GET['announcement']) ? $_GET['announcement'] : null; $announcement = intval($announcement); if (!api_is_anonymous() && $this->user_id) { $visibility = SystemAnnouncementManager::getCurrentUserVisibility(); if ($show_slide) { $announcements = SystemAnnouncementManager::displayAnnouncementsSlider( $visibility, $announcement ); } else { $announcements = SystemAnnouncementManager::displayAllAnnouncements( $visibility, $announcement ); } } else { if ($show_slide) { $announcements = SystemAnnouncementManager::displayAnnouncementsSlider( SystemAnnouncementManager::VISIBLE_GUEST, $announcement ); } else { $announcements = SystemAnnouncementManager::displayAllAnnouncements( SystemAnnouncementManager::VISIBLE_GUEST, $announcement ); } } return $announcements; } /** * Alias for the online_logout() function. * * @param bool $redirect Whether to ask online_logout to redirect to index.php or not * @param array $logoutInfo Information stored by local.inc.php before new context ['uid'=> x, 'cid'=>y, 'sid'=>z] */ public function logout($redirect = true, $logoutInfo = []) { online_logout($this->user_id, true); Event::courseLogout($logoutInfo); } /** * This function checks if there are courses that are open to the world in the platform course categories (=faculties). * * @param string $category * * @return bool */ public function category_has_open_courses($category) { $setting_show_also_closed_courses = api_get_setting('show_closed_courses') == 'true'; $main_course_table = Database::get_main_table(TABLE_MAIN_COURSE); $category = Database::escape_string($category); $sql_query = "SELECT * FROM $main_course_table WHERE category_code='$category'"; $sql_result = Database::query($sql_query); while ($course = Database::fetch_array($sql_result)) { if (!$setting_show_also_closed_courses) { if ((api_get_user_id() > 0 && $course['visibility'] == COURSE_VISIBILITY_OPEN_PLATFORM) || ($course['visibility'] == COURSE_VISIBILITY_OPEN_WORLD) ) { return true; //at least one open course } } else { if (isset($course['visibility'])) { return true; // At least one course (it does not matter weither it's open or not because $setting_show_also_closed_courses = true). } } } return false; } /** * @return null|string */ public function return_teacher_link() { $html = ''; $show_menu = false; if (!empty($this->user_id)) { // tabs that are deactivated are added here $show_menu = false; $show_create_link = false; $show_course_link = false; if (api_is_allowed_to_create_course()) { $show_menu = true; $show_course_link = true; $show_create_link = true; } else { if (api_get_setting('allow_students_to_browse_courses') === 'true') { $show_menu = true; $show_course_link = true; } if (api_is_allowed_to_create_course()) { $show_create_link = true; } } if ($show_menu && ($show_create_link || $show_course_link)) { $show_menu = true; } else { $show_menu = false; } } // My Account section if ($show_menu) { $html .= '
'; } if (!empty($html)) { $html = self::show_right_block( get_lang('Courses'), $html, 'teacher_block', null, 'teachers', 'teachersCollapse' ); } return $html; } /** * Includes a created page. * * @param bool $getIncludedFile Whether to include a file as provided in URL GET or simply the homepage * * @return string */ public function return_home_page($getIncludedFile = false) { $userId = api_get_user_id(); // Including the page for the news $html = ''; if ($getIncludedFile === true) { if (!empty($_GET['include']) && preg_match('/^[a-zA-Z0-9_-]*\.html$/', $_GET['include'])) { $open = @(string) file_get_contents($this->home.$_GET['include']); $html = api_to_system_encoding($open, api_detect_encoding(strip_tags($open))); } } else { // Hiding home top when user not connected. $hideTop = api_get_setting('hide_home_top_when_connected'); if ($hideTop == 'true' && !empty($userId)) { return $html; } if (!empty($_SESSION['user_language_choice'])) { $user_selected_language = $_SESSION['user_language_choice']; } elseif (!empty($_SESSION['_user']['language'])) { $user_selected_language = $_SESSION['_user']['language']; } else { $user_selected_language = api_get_setting('platformLanguage'); } $home_top_temp = ''; // Try language specific home if (file_exists($this->home.'home_top_'.$user_selected_language.'.html')) { $home_top_temp = file_get_contents($this->home.'home_top_'.$user_selected_language.'.html'); } // Try default language home if (empty($home_top_temp)) { if (file_exists($this->home.'home_top.html')) { $home_top_temp = file_get_contents($this->home.'home_top.html'); } else { if (file_exists($this->default_home.'home_top.html')) { $home_top_temp = file_get_contents($this->default_home.'home_top.html'); } } } if (trim($home_top_temp) == '' && api_is_platform_admin()) { $home_top_temp = get_lang('PortalHomepageDefaultIntroduction'); } else { $home_top_temp; } $open = str_replace('{rel_path}', api_get_path(REL_PATH), $home_top_temp); $html = api_to_system_encoding($open, api_detect_encoding(strip_tags($open))); } return $html; } /** * @return string */ public function return_notice() { $user_selected_language = api_get_interface_language(); // Notice $home_notice = @(string) file_get_contents($this->home.'home_notice_'.$user_selected_language.'.html'); if (empty($home_notice)) { $home_notice = @(string) file_get_contents($this->home.'home_notice.html'); } if (!empty($home_notice)) { $home_notice = api_to_system_encoding($home_notice, api_detect_encoding(strip_tags($home_notice))); } return $home_notice; } /** * @return string */ public function return_help() { $user_selected_language = api_get_interface_language(); $platformLanguage = api_get_setting('platformLanguage'); // Help section. /* Hide right menu "general" and other parts on anonymous right menu. */ if (!isset($user_selected_language)) { $user_selected_language = $platformLanguage; } $html = ''; $home_menu = @(string) file_get_contents($this->home.'home_menu_'.$user_selected_language.'.html'); if (!empty($home_menu)) { $html = api_to_system_encoding($home_menu, api_detect_encoding(strip_tags($home_menu))); } return $html; } /** * Generate the block for show a panel with links to My Certificates and Certificates Search pages. * * @return array The HTML code for the panel */ public function returnSkillLinks() { $items = []; if (!api_is_anonymous() && api_get_configuration_value('hide_my_certificate_link') === false ) { $items[] = [ 'icon' => Display::return_icon('graduation.png', get_lang('MyCertificates')), 'link' => api_get_path(WEB_CODE_PATH).'gradebook/my_certificates.php', 'title' => get_lang('MyCertificates'), ]; } if (api_get_setting('allow_public_certificates') == 'true') { $items[] = [ 'icon' => Display::return_icon('search_graduation.png', get_lang('Search')), 'link' => api_get_path(WEB_CODE_PATH).'gradebook/search.php', 'title' => get_lang('Search'), ]; } $myCertificate = GradebookUtils::get_certificate_by_user_id( +0, $this->user_id ); if ($myCertificate) { $items[] = [ 'icon' => Display::return_icon( 'skill-badges.png', get_lang('MyGeneralCertificate'), null, ICON_SIZE_SMALL ), 'link' => api_get_path(WEB_CODE_PATH).'social/my_skills_report.php?a=generate_custom_skill', 'title' => get_lang('MyGeneralCertificate'), ]; } if (Skill::isAllowed(api_get_user_id(), false)) { $items[] = [ 'icon' => Display::return_icon('skill-badges.png', get_lang('MySkills')), 'link' => api_get_path(WEB_CODE_PATH).'social/my_skills_report.php', 'title' => get_lang('MySkills'), ]; $allowSkillsManagement = api_get_setting('allow_hr_skills_management') == 'true'; if (($allowSkillsManagement && api_is_drh()) || api_is_platform_admin()) { $items[] = [ 'icon' => Display::return_icon('edit-skill.png', get_lang('MySkills')), 'link' => api_get_path(WEB_CODE_PATH).'admin/skills_wheel.php', 'title' => get_lang('ManageSkills'), ]; } } return $items; } /** * Reacts on a failed login: * Displays an explanation with a link to the registration form. * * @version 1.0.1 */ public function handle_login_failed() { return $this->tpl->handleLoginFailed(); } /** * Display list of courses in a category. * (for anonymous users). * * @version 1.1 * * @author Patrick Cool'; if (api_get_setting('show_back_link_on_top_of_tree') == 'true') { $htmlTitre .= '<< '.get_lang('BackToHomePage').''; } $htmlTitre .= "
"; } } $htmlListCat .= "' .Display:: return_icon('back.png', get_lang('BackToHomePage')) .get_lang('BackToHomePage').'
'; } return $result; } /** * retrieves all the courses that the user has already subscribed to. * * @author Patrick Cool'.$courseParams['teachers'].'
'; } // notification if (!empty($courseParams['right_actions'])) { $rightActions = '