config error:'.__FILE__.'
set or '); else { $orderKey = array ('keyCourse', 'keyTools', 'keyTime'); } } /* ----------------------------------------------------------- Header include the HTTP, HTML headers plus the top banner ----------------------------------------------------------- */ Display :: display_header($nameTools); /* ============================================================================== FUNCTIONS display_admin_links() display_create_course_link() display_edit_course_list_links() display_digest($toolsList, $digest, $orderKey, $courses) show_notification($my_course) get_personal_course_list($user_id) get_logged_user_course_html($my_course) get_user_course_categories() ============================================================================== */ /* ----------------------------------------------------------- Database functions some of these can go to database layer. ----------------------------------------------------------- */ /** * Database function that gets the list of courses for a particular user. * @param $user_id, the id of the user * @return an array with courses */ function get_personal_course_list($user_id) { // initialisation $personal_course_list = array(); // table definitions $main_user_table = Database :: get_main_table(TABLE_MAIN_USER); $main_course_table = Database :: get_main_table(TABLE_MAIN_COURSE); $main_course_user_table = Database :: get_main_table(TABLE_MAIN_COURSE_USER); $tbl_session_course = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE); $tbl_session_course_user= Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER); $tbl_session = Database :: get_main_table(TABLE_MAIN_SESSION); $personal_course_list = array (); //Courses in which we suscribed out of any session $personal_course_list_sql = "SELECT course.code k, course.directory d, course.visual_code c, course.db_name db, course.title i, course.tutor_name t, course.course_language l, course_rel_user.status s, course_rel_user.sort sort, course_rel_user.user_course_cat user_course_cat FROM ".$main_course_table." course,".$main_course_user_table." course_rel_user WHERE course.code = course_rel_user.course_code"." AND course_rel_user.user_id = '".$user_id."' ORDER BY course_rel_user.user_course_cat, course_rel_user.sort ASC,i"; $course_list_sql_result = api_sql_query($personal_course_list_sql, __FILE__, __LINE__); while ($result_row = mysql_fetch_array($course_list_sql_result)) { $personal_course_list[] = $result_row; } //$personal_course_list = array_merge($personal_course_list, $course_list_sql_result); $personal_course_list_sql = "SELECT DISTINCT course.code k, course.directory d, course.visual_code c, course.db_name db, course.title i, course.tutor_name t, course.course_language l, 5 as s FROM $main_course_table as course, $tbl_session_course_user as srcru WHERE srcru.course_code=course.code AND srcru.id_user='$user_id'"; $course_list_sql_result = api_sql_query($personal_course_list_sql, __FILE__, __LINE__); while ($result_row = mysql_fetch_array($course_list_sql_result)) { $personal_course_list[] = $result_row; } //$personal_course_list = array_merge($personal_course_list, $course_list_sql_result); $personal_course_list_sql = "SELECT DISTINCT course.code k, course.directory d, course.visual_code c, course.db_name db, course.title i, course.tutor_name t, course.course_language l, 2 as s FROM $main_course_table as course, $tbl_session_course as src, $tbl_session as session WHERE session.id_coach='$user_id' AND session.id=src.id_session AND src.course_code=course.code"; $course_list_sql_result = api_sql_query($personal_course_list_sql, __FILE__, __LINE__); //$personal_course_list = array_merge($personal_course_list, $course_list_sql_result); while ($result_row = mysql_fetch_array($course_list_sql_result)) { $personal_course_list[] = $result_row; } return $personal_course_list; } /* ----------------------------------------------------------- Display functions ----------------------------------------------------------- */ /** * Warning: this function defines a global. * @todo use the correct get_path function */ function display_admin_links() { global $rootAdminWeb; echo "
  • ".get_lang('PlatformAdmin')."
  • "; } /** * Enter description here... * */ function display_create_course_link() { echo "
  • ".get_lang('CourseCreate')."
  • "; } /** * Enter description here... * */ function display_edit_course_list_links() { echo "
  • ".get_lang('CourseManagement')."
  • "; } /** * Displays a digest e.g. short summary of new agenda and announcements items. * This used to be displayed in the right hand menu, but is now * disabled by default (see config settings in this file) because most people like * the what's new icons better. * * @version 1.0 */ function display_digest($toolsList, $digest, $orderKey, $courses) { if (is_array($digest) && (CONFVAL_showExtractInfo == SCRIPTVAL_UnderCourseList || CONFVAL_showExtractInfo == SCRIPTVAL_Both)) { // // // LEVEL 1 // // // reset($digest); echo "

    \n"; while (list ($key1) = each($digest)) { if (is_array($digest[$key1])) { // // // Title of LEVEL 1 // // // echo "\n"; if ($orderKey[0] == 'keyTools') { $tools = $key1; echo $toolsList[$key1]['name']; } elseif ($orderKey[0] == 'keyCourse') { $courseSysCode = $key1; echo "", $courses[$key1]['courseCode'], "\n"; } elseif ($orderKey[0] == 'keyTime') { echo format_locale_date(CONFVAL_dateFormatForInfosFromCourses, strtotime($digest[$key1])); } echo "\n"; // // // End Of Title of LEVEL 1 // // // // // // LEVEL 2 // // // reset($digest[$key1]); while (list ($key2) = each($digest[$key1])) { // // // Title of LEVEL 2 // // // echo "

    \n", "\n"; if ($orderKey[1] == 'keyTools') { $tools = $key2; echo $toolsList[$key2][name]; } elseif ($orderKey[1] == 'keyCourse') { $courseSysCode = $key2; echo "", $courses[$key2]['courseCode'], "\n"; } elseif ($orderKey[1] == 'keyTime') { echo format_locale_date(CONFVAL_dateFormatForInfosFromCourses, strtotime($key2)); } echo "\n"; echo "

    "; // // // End Of Title of LEVEL 2 // // // // // // LEVEL 3 // // // reset($digest[$key1][$key2]); while (list ($key3, $dataFromCourse) = each($digest[$key1][$key2])) { // // // Title of LEVEL 3 // // // if ($orderKey[2] == 'keyTools') { $level3title = "".$toolsList[$key3]['name'].""; } elseif ($orderKey[2] == 'keyCourse') { $level3title = "• ".$courses[$key3]['courseCode']."\n"; } elseif ($orderKey[2] == 'keyTime') { $level3title = "• ".format_locale_date(CONFVAL_dateFormatForInfosFromCourses, strtotime($key3)).""; } // // // End Of Title of LEVEL 3 // // // // // // LEVEL 4 (data) // // // reset($digest[$key1][$key2][$key3]); while (list ($key4, $dataFromCourse) = each($digest[$key1][$key2][$key3])) { echo $level3title, ' – ', substr(strip_tags($dataFromCourse), 0, CONFVAL_NB_CHAR_FROM_CONTENT); //adding ... (three dots) if the texts are too large and they are shortened if (strlen($dataFromCourse) >= CONFVAL_NB_CHAR_FROM_CONTENT) { echo '...'; } } echo "
    \n"; } } } } } } // end function display_digest /** * Display code for one specific course a logged in user is subscribed to. * Shows a link to the course, what's new icons... * * $my_course['d'] - course directory * $my_course['i'] - course title * $my_course['c'] - visual course code * $my_course['k'] - system course code * $my_course['db'] - course database * * @version 1.0.3 * @todo refactor into different functions for database calls | logic | display * @todo replace single-character $my_course['d'] indices * @todo move code for what's new icons to a separate function to clear things up * @todo add a parameter user_id so that it is possible to show the courselist of other users (=generalisation). This will prevent having to write a new function for this. */ function get_logged_user_course_html($my_course) { global $nosession; if(api_get_setting('use_session_mode')=='true' && !$nosession) { global $now, $date_start, $date_end; } //initialise $result = ''; // Table definitions //$statistic_database = Database::get_statistic_database(); $course_database = $my_course['db']; $course_tool_table = Database :: get_course_table(TABLE_TOOL_LIST, $course_database); $tool_edit_table = Database :: get_course_table(TABLE_ITEM_PROPERTY, $course_database); $course_group_user_table = Database :: get_course_table(TOOL_USER, $course_database); $user_id = api_get_user_id(); $course_system_code = $my_course['k']; $course_visual_code = $my_course['c']; $course_title = $my_course['i']; $course_directory = $my_course['d']; $course_teacher = $my_course['t']; $course_teacher_email = isset($my_course['email'])?$my_course['email']:''; $course_info = Database :: get_course_info($course_system_code); $course_access_settings = CourseManager :: get_access_settings($course_system_code); $course_id = isset($course_info['course_id'])?$course_info['course_id']:null; $course_visibility = $course_access_settings['visibility']; $user_in_course_status = CourseManager :: get_user_in_course_status(api_get_user_id(), $course_system_code); //function logic - act on the data $is_virtual_course = CourseManager :: is_virtual_course_from_system_code($my_course['k']); if ($is_virtual_course) { // If the current user is also subscribed in the real course to which this // virtual course is linked, we don't need to display the virtual course entry in // the course list - it is combined with the real course entry. $target_course_code = CourseManager :: get_target_of_linked_course($course_system_code); $is_subscribed_in_target_course = CourseManager :: is_user_subscribed_in_course(api_get_user_id(), $target_course_code); if ($is_subscribed_in_target_course) { return; //do not display this course entry } } $has_virtual_courses = CourseManager :: has_virtual_courses_from_code($course_system_code, api_get_user_id()); if ($has_virtual_courses) { $return_result = CourseManager :: determine_course_title_from_course_info(api_get_user_id(), $course_info); $course_display_title = $return_result['title']; $course_display_code = $return_result['code']; } else { $course_display_title = $course_title; $course_display_code = $course_visual_code; } $s_course_status=$my_course['s']; $s_htlm_status_icon=""; if($s_course_status==1) { $s_htlm_status_icon=Display::return_icon('teachers.gif'); } if($s_course_status==2) { $s_htlm_status_icon=Display::return_icon('coachs.gif'); } if($s_course_status==5) { $s_htlm_status_icon=Display::return_icon('students.gif'); } //display course entry $result.="\n\t"; $result .= '
  • '.$s_htlm_status_icon.'
    '; //show a hyperlink to the course, unless the course is closed and user is not course admin if ($course_visibility != COURSE_VISIBILITY_CLOSED || $user_in_course_status == COURSEMANAGER) { if(api_get_setting('use_session_mode')=='true' && !$nosession) { if(empty($my_course['id_session'])) { $my_course['id_session'] = 0; } if($user_in_course_status == COURSEMANAGER || ($date_start <= $now && $date_end >= $now) || $date_start=='0000-00-00') { $result .= ''.$course_display_title.''; } } else { $result .= ''.$course_display_title.''; } } else { $result .= $course_display_title." "." ".get_lang('CourseClosed').""; } // show the course_code and teacher if chosen to display this if (get_setting('display_coursecode_in_courselist') == 'true' OR get_setting('display_teacher_in_courselist') == 'true') { $result .= '
    '; } if (get_setting('display_coursecode_in_courselist') == 'true') { $result .= $course_display_code; } if (get_setting('display_coursecode_in_courselist') == 'true' AND get_setting('display_teacher_in_courselist') == 'true') { $result .= ' – '; } if (get_setting('display_teacher_in_courselist') == 'true') { $result .= $course_teacher; if(!empty($course_teacher_email)) { $result .= ' ('.$course_teacher_email.')'; } } $current_course_settings = CourseManager :: get_access_settings($my_course['k']); // display the what's new icons $result .= show_notification($my_course); if ((CONFVAL_showExtractInfo == SCRIPTVAL_InCourseList || CONFVAL_showExtractInfo == SCRIPTVAL_Both) && $nbDigestEntries > 0) { reset($digest); $result .= ''; } $result .= '
  • '; if(api_get_setting('use_session_mode')=='true' && !$nosession) { $session = ''; $active = false; if(!empty($my_course['session_name'])) { $session = $my_course['session_name']; if($my_course['date_start']=='0000-00-00') { $session .= ' - '.get_lang('WithoutTimeLimits'); $active = true; } else { $session .= ' - '.get_lang('From').' '.$my_course['date_start'].' '.get_lang('To').' '.$my_course['date_end']; $active = ($date_start <= $now && $date_end >= $now)?true:false; } } $output = array ($my_course['user_course_cat'], $result, $my_course['id_session'], $session, 'active'=>$active); } else { $output = array ($my_course['user_course_cat'], $result); } return $output; } /** * Returns the "what's new" icon notifications * @param array Course information array, containing at least elements 'db' and 'k' * @return string The HTML link to be shown next to the course * @version */ function show_notification($my_course) { $statistic_database = Database :: get_statistic_database(); $user_id = api_get_user_id(); $course_database = $my_course['db']; $course_tool_table = Database::get_course_table(TABLE_TOOL_LIST, $course_database); $tool_edit_table = Database::get_course_table(TABLE_ITEM_PROPERTY, $course_database); $course_group_user_table = Database :: get_course_table(TABLE_GROUP_USER, $course_database); $t_track_e_access = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_LASTACCESS); // get the user's last access dates to all tools of this course $sqlLastTrackInCourse = "SELECT * FROM $t_track_e_access USE INDEX (access_cours_code, access_user_id) WHERE access_cours_code = '".$my_course['k']."' AND access_user_id = '$user_id'"; $resLastTrackInCourse = api_sql_query($sqlLastTrackInCourse, __FILE__, __LINE__); $oldestTrackDate = "3000-01-01 00:00:00"; while ($lastTrackInCourse = mysql_fetch_array($resLastTrackInCourse)) { $lastTrackInCourseDate[$lastTrackInCourse['access_tool']] = $lastTrackInCourse['access_date']; if ($oldestTrackDate > $lastTrackInCourse['access_date']) $oldestTrackDate = $lastTrackInCourse['access_date']; } // get the last edits of all tools of this course $sql = "SELECT tet.*, tet.lastedit_date last_date, tet.tool tool, tet.ref ref, tet.lastedit_type type, tet.to_group_id group_id, ctt.image image, ctt.link link FROM $tool_edit_table tet, $course_tool_table ctt WHERE tet.lastedit_date > '$oldestTrackDate' AND ctt.name = tet.tool AND ctt.visibility = '1' AND tet.lastedit_user_id != $user_id ORDER BY tet.lastedit_date"; $res = api_sql_query($sql); //get the group_id's with user membership $group_ids = GroupManager :: get_group_ids($course_database, $user_id); $groups_ids[] = 0; //add group 'everyone' //filter all selected items while ($res && ($item_property = mysql_fetch_array($res))) { if ((!isset ($lastTrackInCourseDate[$item_property['tool']]) || $lastTrackInCourseDate[$item_property['tool']] < $item_property['lastedit_date']) && (in_array($item_property['to_group_id'], $groups_ids) || $item_property['to_user_id'] == $user_id) && ($item_property['visibility'] == '1' || ($my_course['s'] == '1' && $item_property['visibility'] == '0') || !isset ($item_property['visibility']))) { $notifications[$item_property['tool']] = $item_property; } } //show all tool icons where there is something new $retvalue = ' '; if (isset ($notifications)) { while (list ($key, $notification) = each($notifications)) { $lastDate = date('d/m/Y H:i', convert_mysql_date($notification['lastedit_date'])); $type = $notification['lastedit_type']; //$notification[image]=str_replace(".png","gif",$notification[image]); //$notification[image]=str_replace(".gif","_s.gif",$notification[image]); $retvalue .= ''.' '; } } return $retvalue; } /** * retrieves the user defined course categories * @author Patrick Cool , Ghent University * @return array containing all the titles of the user defined courses with the id as key of the array */ function get_user_course_categories() { global $_user; $output = array(); $table_category = Database::get_user_personal_table(TABLE_USER_COURSE_CATEGORY); $sql = "SELECT * FROM ".$table_category." WHERE user_id='".$_user['user_id']."'"; $result = api_sql_query($sql,__FILE__,__LINE__); while ($row = mysql_fetch_array($result)) { $output[$row['id']] = $row['title']; } return $output; } /* ============================================================================== MAIN CODE ============================================================================== */ /* ============================================================================== PERSONAL COURSE LIST ============================================================================== */ if (!isset ($maxValvas)) { $maxValvas = CONFVAL_maxValvasByCourse; // Maximum number of entries } if (!isset ($maxAgenda)) { $maxAgenda = CONFVAL_maxAgendaByCourse; // collected from each course } if (!isset ($maxCourse)) { $maxCourse = CONFVAL_maxTotalByCourse; // and displayed in summary. } $maxValvas = (int) $maxValvas; $maxAgenda = (int) $maxAgenda; $maxCourse = (int) $maxCourse; // 0 if invalid if ($maxCourse > 0) { unset ($allentries); // we shall collect all summary$key1 entries in here: $toolsList['agenda']['name'] = get_lang('Agenda'); $toolsList['agenda']['path'] = api_get_path(WEB_CODE_PATH)."calendar/agenda.php?cidReq="; $toolsList['valvas']['name'] = get_lang('Valvas'); $toolsList['valvas']['path'] = api_get_path(WEB_CODE_PATH)."announcements/announcements.php?cidReq="; } echo '
    '; // 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 ""; } echo "\n\n\t\n"; if ($key<>0 OR $value[0]<>0) // there are courses in the previous category { 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 ""; } echo "\n\n\t\n"; echo "

    \n"; } if(count($listInactives)>0 && !$display_actives){ echo ""; } echo "\n\n\t\n"; echo "

    \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(); ?>