'; // 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']) && !strstr($_GET['include'], '/') && strstr($_GET['include'], '.html'))
{
include ('./home/'.$_GET['include']);
$pageIncluded = true;
}
else
{
/*--------------------------------------
DISPLAY COURSES
--------------------------------------*/
$list = '';
$personal_course_list = UserManager::get_personal_session_course_list($_user['user_id']);
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 = api_sql_query($query);
// collect from announcements, but only if tool is visible for the course
if ($result && $maxValvas > 0 && mysql_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 = api_sql_query($sqlGetLastAnnouncements, __FILE__, __LINE__);
if ($resGetLastAnnouncements)
{
while ($annoncement = mysql_fetch_array($resGetLastAnnouncements))
{
$keyTools = "valvas";
$keyTime = $annoncement['publicationDate'];
$keyCourse = $thisCourseSysCode;
$digest[$$orderKey[0]][$$orderKey[1]][$$orderKey[2]][] = htmlspecialchars(substr(strip_tags($annoncement["content"]), 0, CONFVAL_NB_CHAR_FROM_CONTENT));
$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 = api_sql_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 && mysql_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 = api_sql_query($sqlGetNextAgendaEvent, __FILE__, __LINE__);
if ($resGetNextAgendaEvent)
{
while ($agendaEvent = mysql_fetch_array($resGetNextAgendaEvent))
{
$keyTools = 'agenda';
$keyTime = $agendaEvent['start_date'];
$keyCourse = $thisCourseSysCode;
$digest[$$orderKey[0]][$$orderKey[1]][$$orderKey[2]][] = htmlspecialchars(substr(strip_tags($agendaEvent["content"]), 0, CONFVAL_NB_CHAR_FROM_CONTENT));
$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 (is_array($list))
{
//Courses whithout sessions
$old_user_category = 0;
foreach($list as $key=>$value)
{
if($value[2]==0){
$userdefined_categories = get_user_course_categories();
echo "
\n";
if ($old_user_category<>$value[0])
{
if ($key<>0 OR $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'])
$listActives[] = $value;
else if(!empty($value[2]))
$listInactives[] = $value;
}
$old_user_category = 0;
$userdefined_categories = get_user_course_categories();
if(count($listActives)>0 && $display_actives){
echo "
\n";
foreach ($listActives as $key => $value)
{
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 "\n
";
}
echo "\n\n\t
\n";
echo "
";
}
}
echo $value[1];
}
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 "\n
";
}
echo "\n\n\t
\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();
?>