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 = 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 = 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 */ public function logout($redirect = true) { 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 */ 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 * @return string */ public function return_home_page() { $userId = api_get_user_id(); // 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($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 = ''; 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 = '