';
api_plugin('mycourses_main');
echo '
';
/* System Announcements */
/*
$announcement = isset($_GET['announcement']) ? $_GET['announcement'] : -1;
$visibility = api_is_allowed_to_create_course() ? VISIBLE_TEACHER : VISIBLE_STUDENT;
SystemAnnouncementManager :: display_announcements($visibility, $announcement);*/
if (!empty ($_GET['include']) && preg_match('/^[a-zA-Z0-9_-]*\.html$/',$_GET['include'])) {
include './home/'.$_GET['include'];
$pageIncluded = true;
} else {
/* DISPLAY COURSES */
// Compose a structured array of session categories, sessions and courses
// for the current user.
if (isset($_GET['history']) && intval($_GET['history']) == 1) {
$courses_tree = UserManager::get_sessions_by_category(api_get_user_id(), true, true, true);
if (empty($courses_tree[0]) && count($courses_tree) == 1) {
$courses_tree = null;
}
} else {
$courses_tree = UserManager::get_sessions_by_category(api_get_user_id(), true, false, true);
}
if (!empty($courses_tree)) {
foreach ($courses_tree as $cat => $sessions) {
$courses_tree[$cat]['details'] = SessionManager::get_session_category($cat);
if ($cat == 0) {
$courses_tree[$cat]['courses'] = CourseManager::get_courses_list_by_user_id(api_get_user_id(), false);
}
$courses_tree[$cat]['sessions'] = array_flip(array_flip($sessions));
if (count($courses_tree[$cat]['sessions']) > 0) {
foreach ($courses_tree[$cat]['sessions'] as $k => $s_id) {
$courses_tree[$cat]['sessions'][$k] = array('details' => SessionManager::fetch($s_id));
$courses_tree[$cat]['sessions'][$k]['courses'] = UserManager::get_courses_list_by_session(api_get_user_id(), $s_id);
}
}
}
}
$list = '';
foreach ($personal_course_list as $my_course) {
$thisCourseDbName = $my_course['db'];
$thisCourseSysCode = $my_course['k'];
$thisCoursePublicCode = $my_course['c'];
$thisCoursePath = $my_course['d'];
$sys_course_path = api_get_path(SYS_COURSE_PATH);
$dbname = $my_course['k'];
$status = array();
$status[$dbname] = $my_course['s'];
$nbDigestEntries = 0; // Number of entries already collected.
if ($maxCourse < $maxValvas) {
$maxValvas = $maxCourse;
}
if ($maxCourse > 0) {
$courses[$thisCourseSysCode]['coursePath'] = $thisCoursePath;
$courses[$thisCourseSysCode]['courseCode'] = $thisCoursePublicCode;
}
/* Announcements */
$course_database = $my_course['db'];
$course_tool_table = Database::get_course_table(TABLE_TOOL_LIST, $course_database);
$query = "SELECT visibility FROM $course_tool_table WHERE link = 'announcements/announcements.php' AND visibility = 1";
$result = Database::query($query);
// Collect from announcements, but only if tool is visible for the course.
if ($result && $maxValvas > 0 && Database::num_rows($result) > 0) {
// Search announcements table.
// Take the entries listed at the top of advalvas/announcements tool.
$course_announcement_table = Database::get_course_table(TABLE_ANNOUNCEMENT);
$sqlGetLastAnnouncements = "SELECT end_date publicationDate, content
FROM ".$course_announcement_table;
switch (CONFVAL_limitPreviewTo) {
case SCRIPTVAL_NewEntriesOfTheDay :
$sqlGetLastAnnouncements .= "WHERE DATE_FORMAT(end_date,'%Y %m %d') >= '".date('Y m d')."'";
break;
case SCRIPTVAL_NoTimeLimit :
break;
case SCRIPTVAL_NewEntriesOfTheDayOfLastLogin :
// take care mysql -> DATE_FORMAT(time,format) php -> date(format,date)
$sqlGetLastAnnouncements .= "WHERE DATE_FORMAT(end_date,'%Y %m %d') >= '".date('Y m d', $_user['lastLogin'])."'";
}
$sqlGetLastAnnouncements .= "ORDER BY end_date DESC LIMIT ".$maxValvas;
$resGetLastAnnouncements = Database::query($sqlGetLastAnnouncements);
if ($resGetLastAnnouncements) {
while ($annoncement = Database::fetch_array($resGetLastAnnouncements)) {
$keyTools = 'valvas';
$keyTime = $annoncement['publicationDate'];
$keyCourse = $thisCourseSysCode;
$digest[$$orderKey[0]][$$orderKey[1]][$$orderKey[2]][] = @htmlspecialchars(api_substr(strip_tags($annoncement['content']), 0, CONFVAL_NB_CHAR_FROM_CONTENT), ENT_QUOTES, $charset);
$nbDigestEntries ++; // summary has same order as advalvas
}
}
}
/* Agenda */
$course_database = $my_course['db'];
$course_tool_table = Database :: get_course_table(TABLE_TOOL_LIST, $course_database);
$query = "SELECT visibility FROM $course_tool_table WHERE link = 'calendar/agenda.php' AND visibility = 1";
$result = Database::query($query);
$thisAgenda = $maxCourse - $nbDigestEntries; // New max entries for agenda.
if ($maxAgenda < $thisAgenda) {
$thisAgenda = $maxAgenda;
}
// Collect from agenda, but only if tool is visible for the course.
if ($result && $thisAgenda > 0 && Database::num_rows($result) > 0) {
$tableCal = $courseTablePrefix.$thisCourseDbName.$_configuration['db_glue'].'calendar_event';
$sqlGetNextAgendaEvent = "SELECT start_date, title content, start_time
FROM $tableCal
WHERE start_date >= CURDATE()
ORDER BY start_date, start_time
LIMIT $maxAgenda";
$resGetNextAgendaEvent = Database::query($sqlGetNextAgendaEvent);
if ($resGetNextAgendaEvent) {
while ($agendaEvent = Database::fetch_array($resGetNextAgendaEvent)) {
$keyTools = 'agenda';
$keyTime = $agendaEvent['start_date'];
$keyCourse = $thisCourseSysCode;
$digest[$$orderKey[0]][$$orderKey[1]][$$orderKey[2]][] = @htmlspecialchars(api_substr(strip_tags($agendaEvent['content']), 0, CONFVAL_NB_CHAR_FROM_CONTENT), ENT_QUOTES, $charset);
$nbDigestEntries ++; // Summary has same order as advalvas.
}
}
}
/*
Digest Display
Take collected data and display it.
*/
} // End while mycourse...
}
if (isset($_GET['history']) && intval($_GET['history']) == 1) {
echo Display::tag('h2', get_lang('HistoryTrainingSession'));
//if (empty($courses_tree[0]['sessions'])){
if (empty($courses_tree)){
echo get_lang('YouDoNotHaveAnySessionInItsHistory');
}
}
if (is_array($courses_tree)) {
foreach ($courses_tree as $key => $category) {
if ($key == 0) {
// Sessions and courses that are not in a session category.
if (!isset($_GET['history'])) {
// If we're not in the history view...
CourseManager :: display_special_courses(api_get_user_id(), $load_dirs);
CourseManager :: display_courses(api_get_user_id(), $load_dirs);
}
// Independent sessions.
foreach ($category['sessions'] as $session) {
// Don't show empty sessions.
if (count($session['courses']) < 1) { continue; }
// Courses inside the current session.
$date_session_start = $session['details']['date_start'];
$days_access_before_beginning = $session['details']['nb_days_access_before_beginning'] * 24 * 3600;
$session_now = time();
$html_courses_session = '';
$count_courses_session = 0;
foreach ($session['courses'] as $course) {
$is_coach_course = api_is_coach($session['details']['id'], $course['code']);
$allowed_time = 0;
if ($date_session_start != '0000-00-00') {
if ($is_coach_course) {
$allowed_time = api_strtotime($date_session_start) - $days_access_before_beginning;
} else {
$allowed_time = api_strtotime($date_session_start);
}
}
if ($session_now > $allowed_time) { //read only and accesible
if (api_get_setting('hide_courses_in_sessions') == 'false') {
$c = CourseManager :: get_logged_user_course_html($course, $session['details']['id'], 'session_course_item', true, $load_dirs);
//$c = CourseManager :: get_logged_user_course_html($course, $session['details']['id'], 'session_course_item',($session['details']['visibility']==3?false:true));
$html_courses_session .= $c[1];
}
$count_courses_session++;
}
}
if ($count_courses_session > 0) {
echo '- ';
echo '
- '; echo Display::return_icon('window_list.png', get_lang('Expand').'/'.get_lang('Hide'), array('width' => '48px', 'align' => 'absmiddle', 'id' => 'session_img_'.$session['details']['id'])) . ' '; $s = Display :: get_session_title_box($session['details']['id']); $extra_info = (!empty($s['coach']) ? $s['coach'].' | ' : '').$s['dates']; /*if ($session['details']['visibility'] == 3) { $session_link = $s['title']; } else {*/ $session_link = Display::tag('a',$s['title'], array('href'=>api_get_path(WEB_CODE_PATH).'session/?session_id='.$session['details']['id'])); //} echo Display::tag('span',$session_link. ' '.$extra_info); if (api_is_platform_admin()) { echo ''; } echo ' '; if (api_get_setting('hide_courses_in_sessions') == 'false') { echo $html_courses_session; } echo '
- ';
$html_sessions .= '
- '; //$html_sessions .= Display::return_icon('div_hide.gif', get_lang('Expand').'/'.get_lang('Hide'), array('align' => 'absmiddle', 'id' => 'session_img_'.$session['details']['id'])) . ' '; $html_sessions .= Display::return_icon('window_list.png', get_lang('Expand').'/'.get_lang('Hide'), array('width' => '48px', 'align' => 'absmiddle', 'id' => 'session_img_'.$session['details']['id'])) . ' '; $session_link = Display::tag('a',$s['title'], array('href'=>api_get_path(WEB_CODE_PATH).'session/?session_id='.$session['details']['id'])); $html_sessions .= '' . $session_link. ' '; $html_sessions .= ''; $html_sessions .= (!empty($s['coach']) ? $s['coach'].' | ' : '').$s['dates']; $html_sessions .= ''; if (api_is_platform_admin()) { $html_sessions .= ''; } $html_sessions .= ' '; $html_sessions .= $html_courses_session; $html_sessions .= '
';
echo '
';
}
}
}
}
}
echo '';
echo Display::return_icon('folder_blue.png', get_lang('SessionCategory'), array('width'=>'48px', 'align' => 'absmiddle'));
if (api_is_platform_admin()) {
echo'';
}
echo '';
echo $category['details']['name'];
echo '';
echo '';
if ($category['details']['date_end'] != '0000-00-00') {
printf(get_lang('FromDateXToDateY'),$category['details']['date_start'],$category['details']['date_end']);
}
echo '
';
echo $html_sessions;
echo '