tpl = new Template($title); $this->home = api_get_home_path(); $this->user_id = api_get_user_id(); $this->load_directories_preview = false; if (api_get_setting('show_documents_preview') == 'true') { $this->load_directories_preview = true; } } /** * @param bool $setLoginForm */ function set_login_form($setLoginForm = true) { global $loginFailed; $login_form = ''; if (!($this->user_id) || api_is_anonymous($this->user_id)) { // Only display if the user isn't logged in. $this->tpl->assign('login_language_form', api_display_language_form(true)); if ($setLoginForm) { $this->tpl->assign('login_form', self::display_login_form()); if ($loginFailed) { $this->tpl->assign('login_failed', self::handle_login_failed()); } if (api_get_setting('allow_lostpassword') == 'true' || api_get_setting('allow_registration') == 'true') { $login_form .= '
'; } $this->tpl->assign('login_options', $login_form); } } } function return_exercise_block($personal_course_list) { require_once api_get_path(SYS_CODE_PATH).'exercice/exercise.lib.php'; $exercise_list = array(); if (!empty($personal_course_list)) { foreach($personal_course_list as $course_item) { $course_code = $course_item['c']; $session_id = $course_item['id_session']; $exercises = 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).'exercice/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)); } } } function return_announcements($show_slide = true) { // Display System announcements $announcement = isset($_GET['announcement']) ? $_GET['announcement'] : null; $announcement = intval($announcement); if (!api_is_anonymous() && $this->user_id) { $visibility = api_is_allowed_to_create_course() ? SystemAnnouncementManager::VISIBLE_TEACHER : SystemAnnouncementManager::VISIBLE_STUDENT; if ($show_slide) { $announcements = SystemAnnouncementManager :: display_announcements_slider($visibility, $announcement); } else { $announcements = SystemAnnouncementManager :: display_all_announcements($visibility, $announcement); } } else { if ($show_slide) { $announcements = SystemAnnouncementManager :: display_announcements_slider(SystemAnnouncementManager::VISIBLE_GUEST, $announcement); } else { $announcements = SystemAnnouncementManager :: display_all_announcements(SystemAnnouncementManager::VISIBLE_GUEST, $announcement); } } return $announcements; } /** * Alias for the online_logout() function */ function logout() { online_logout($this->user_id, true); } /** * This function checks if there are courses that are open to the world in the platform course categories (=faculties) * * @param string $category * @return boolean */ 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; } /** * Displays the right-hand menu for anonymous users: * login form, useful links, help section * Warning: function defines globals * @version 1.0.1 * @todo does $_plugins need to be global? */ function display_anonymous_right_menu() { global $loginFailed, $_user; $display_add_course_link = api_is_allowed_to_create_course() && ($_SESSION['studentview'] != 'studentenview'); $current_user_id = api_get_user_id(); echo self::set_login_form(false); echo self::return_teacher_link(); echo self::return_notice(); } function return_teacher_link() { $html = ''; 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_platform_admin() || api_is_course_admin() || 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 ($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'); } return $html; } /** * Includes a created page * @return string */ public function return_home_page() { $userId = api_get_user_id(); global $_configuration; // Including the page for the news $html = ''; if (!empty($_GET['include']) && preg_match('/^[a-zA-Z0-9_-]*\.html$/', $_GET['include'])) { $open = @(string)file_get_contents(api_get_path(SYS_PATH).$this->home.$_GET['include']); $html = api_to_system_encoding($open, api_detect_encoding(strip_tags($open))); } else { // Hiding home top when user not connected. if (isset($_configuration['hide_home_top_when_connected']) && $_configuration['hide_home_top_when_connected'] && !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'); } // 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 = ''; 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'.$tabParams['teachers'].'
'; } $rightActions = ''; // notification if (!empty($tabParams['right_actions'])) { $rightActions = '