'; // start of content for logged in users
// Plugins for the my courses main area
api_plugin('mycourses_main');
/*
-----------------------------------------------------------------------------
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($_user['user_id'],true,true);
} else {
$courses_tree = UserManager::get_sessions_by_category($_user['user_id'],true);
}
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($_user['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($_user['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[$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, __FILE__, __LINE__);
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, __FILE__, __LINE__);
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
-----------------------------------------------------------
*/
//$list[] = get_logged_user_course_html($my_course);
} //end while mycourse...
}
if (isset($_GET['history']) && intval($_GET['history']) == 1) {
echo '
'.get_lang('HistoryTrainingSession').'
';
if (count($courses_tree)==1){
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'])) { // check if it's not history trainnign session list
// independent courses
if(count($category['courses']) > 0) {
echo '
';
}
foreach ($category['courses'] as $course) {
$c = get_logged_user_course_html($course, 0, 'independent_course_item');
echo $c[1];
}
if(count($category['courses']) > 0) {
echo '
';
}
}
//independent sessions
foreach ($category['sessions'] as $session) {
//don't show empty sessions
if (count($session['courses'])<1) { continue; }
echo '
';
echo '- ';
echo Display::return_icon('div_hide.gif', get_lang('Expand').'/'.get_lang('Hide'), array('align' => 'absmiddle', 'id' => 'session_img_'.$session['details']['id'])) . ' ';
$s = get_session_title_box($session['details']['id']);
echo get_lang('SessionName') . ': ' . $s['title']. ' - '.(!empty($s['coach'])?$s['coach'].' - ':'').$s['dates'];
echo '
';
//courses inside the current session
foreach ($session['courses'] as $course) {
$c = get_logged_user_course_html($course, $session['details']['id'], 'session_course_item');
echo $c[1];
}
echo '
';
}
} else {
// all sessions included in
if (!empty($category['details'])) {
echo '
';
echo '
'. Display::return_icon('div_hide.gif', get_lang('Expand').'/'.get_lang('Hide'), array('align' => 'absmiddle', 'id' => 'category_img_'.$category['details']['id'])) . ' ' . get_lang('SessionCategory') . ': ' . $category['details']['name'].' - '.get_lang('From').' '.$category['details']['date_start'].' '.get_lang('Until').' '.$category['details']['date_end'].'
';
foreach ($category['sessions'] as $session) {
//don't show empty sessions
if (count($session['courses'])<1) { continue; }
echo '
';
echo '- ';
echo Display::return_icon('div_hide.gif', get_lang('Expand').'/'.get_lang('Hide'), array('align' => 'absmiddle', 'id' => 'session_img_'.$session['details']['id'])) . ' ';
$s = get_session_title_box($session['details']['id']);
echo get_lang('SessionName') . ': ' . $s['title']. ' - '.(!empty($s['coach'])?$s['coach'].' - ':'').$s['dates'];
echo '
';
foreach ($session['courses'] as $course) {
//echo '- ';
$c = get_logged_user_course_html($course, $session['details']['id'], 'session_course_item');
echo $c[1];
//echo $course['code'];
//echo '
';
}
echo '
';
}
echo '
';
}
}
}
}
/*
if ( is_array($list) ) {
//Courses whithout sessions
$old_user_category = 0;
foreach ($list as $key => $value) {
if (empty($value[2])) { //if out of any session
$userdefined_categories = get_user_course_categories();
echo '
';
if ($old_user_category<>$value[0]) {
if ($key <> 0 || $value[0] <> 0) {// there are courses in the previous category
echo "\n
";
}
echo "\n\n\t
- ".$userdefined_categories[$value[0]]."
\n";
if ($key<>0 OR $value[0]<>0){ // there are courses in the previous category
echo "
";
}
$old_user_category = $value[0];
}
echo $value[1];
echo "
\n";
}
}
$listActives = $listInactives = $listCourses = array();
foreach ($list as $key => $value) {
if ($value['active']) { //if the session is still active (as told by get_logged_user_course_html())
$listActives[] = $value;
} else if (!empty($value[2])) { //if there is a session but it is not active
$listInactives[] = $value;
}
}
$old_user_category = 0;
$userdefined_categories = get_user_course_categories();
if (count($listActives) > 0 && $display_actives) {
echo "
\n";
$name_category = array();
$i = 0;
$j=0;
foreach ($listActives as $key => $value) {
$session_category_id=$value['session_category_id'];
if (!empty($value[3]['category'])) {
if (!in_array($value[3]['category'], $name_category)) {
if ($key != 0) {
echo '
';
}
//Category
$name_category['name'] = $value[3]['category'];
echo '
' .
'- '.$name_category['name'].'
';
echo "
\n";
}
}
if (!empty($value[2])) {
if ((isset($old_session) && $old_session != $value[2]) or ((!isset($old_session)) && isset($value[2]))) {
$old_session = $value[2];
if ($key != 0) {
echo '';
}
//Session
echo '
' .
'- '.$value[3]['title'].' '.$value[3]['dates'].'
';
if ( !empty($value[3]['coach']) ) {
echo '- '.$value[3]['coach'].'
';
}
echo "
\n";
echo '
';
}
}
//Courses
echo $value[1];
$i++;
}
echo "\n
\n";
}
if (count($listInactives) > 0 && !$display_actives) {
echo '
';
foreach ($listInactives as $key => $value) {
if (!empty($value[2])) {
if ($old_session != $value[2]) {
$old_session = $value[2];
if ($key != 0) {
echo '
';
}
echo '
' .
'- '.$value[3]['title'].' '.$value[3]['dates'].'
';
if (!empty($value[3]['coach'])) {
echo '- '.$value[3]['coach'].'
';
}
echo "
\n";
echo '
';
}
}
echo $value[1];
}
echo "\n
\n";
}
} */
echo '
'; // end of content section
// Register whether full admin or null admin course
// by course through an array dbname x user status
api_session_register('status');
/*
==============================================================================
RIGHT MENU
==============================================================================
*/
echo ' '; // end of menu
//footer
Display :: display_footer();
'.get_lang('Messages').'
echo ''; echo ' '; echo '