diff --git a/main/inc/lib/course.lib.php b/main/inc/lib/course.lib.php
index b45dd4dacb..3d21889845 100755
--- a/main/inc/lib/course.lib.php
+++ b/main/inc/lib/course.lib.php
@@ -2705,7 +2705,7 @@ class CourseManager {
$my_course['s'] = $course['status'];
// For each course, get if there is any notification icon to show
// (something that would have changed since the user's last visit).
- $show_notification = show_notification($my_course);
+ $show_notification = Display :: show_notification($my_course);
// New code displaying the user's status in respect to this course.
$status_icon = Display::return_icon('blackboard.png', get_lang('Course'), array('width' => '48px'));
diff --git a/main/inc/lib/display.lib.php b/main/inc/lib/display.lib.php
index 10cc8a72b9..4ef7288700 100755
--- a/main/inc/lib/display.lib.php
+++ b/main/inc/lib/display.lib.php
@@ -973,4 +973,95 @@ class Display {
}
}
}
+ /**
+ * Returns the "what's new" icon notifications
+ *
+ * The general logic of this function is to track the last time the user
+ * entered the course and compare to what has changed inside this course
+ * since then, based on the item_property table inside this course. Note that,
+ * if the user never entered the course before, he will not see notification
+ * icons. This function takes session ID into account (if any) and only shows
+ * the corresponding 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
+ */
+ 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' AND access_session_id ='".$my_course['id_session']."'";
+ $resLastTrackInCourse = Database::query($sqlLastTrackInCourse);
+
+ $oldestTrackDate = '3000-01-01 00:00:00';
+ while ($lastTrackInCourse = Database::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 AND tet.id_session = '".$my_course['id_session']."'
+ ORDER BY tet.lastedit_date";
+ $res = Database::query($sql);
+ // Get the group_id's with user membership.
+ $group_ids = GroupManager :: get_group_ids($course_database, $user_id);
+ $group_ids[] = 0; //add group 'everyone'
+ // Filter all selected items.
+ while ($res && ($item_property = Database::fetch_array($res))) {
+ // First thing to check is if the user never entered the tool
+ // or if his last visit was earlier than the last modification.
+ if ((!isset ($lastTrackInCourseDate[$item_property['tool']]) || $lastTrackInCourseDate[$item_property['tool']] < $item_property['lastedit_date'])
+ // Drop the tool elements that are part of a group that the
+ // user is not part of.
+ && ((in_array($item_property['to_group_id'], $group_ids)
+ // Drop the dropbox, notebook and chat tools because we don't care.
+ && ($item_property['tool'] != TOOL_DROPBOX && $item_property['tool'] != TOOL_NOTEBOOK && $item_property['tool'] != TOOL_CHAT)))
+ // Take only what's visible or invisible but where the user is a teacher or where the visibility is unset.
+ && ($item_property['visibility'] == '1' || ($my_course['s'] == '1' && $item_property['visibility'] == '0') || !isset($item_property['visibility']))) {
+
+ // Also drop announcements and events that are not for the user or his group.
+ if (($item_property['tool'] == TOOL_ANNOUNCEMENT || $item_property['tool'] == TOOL_CALENDAR_EVENT) && (($item_property['to_user_id'] != $user_id ) && (!isset($item_property['to_group_id']) || !in_array($item_property['to_group_id'], $group_ids)))) continue;
+ // If it's a survey, make sure the user's invited. Otherwise drop it.
+ if ($item_property['tool'] == TOOL_SURVEY) {
+ $survey_info = survey_manager::get_survey($item_property['ref'], 0, $my_course['k']);
+ $invited_users = SurveyUtil::get_invited_users($survey_info['code'], $course_database);
+ if (!in_array($user_id, $invited_users['course_users'])) continue;
+ }
+ $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]);
+ if (empty($my_course['id_session'])) {
+ $my_course['id_session'] = 0;
+ }
+ $retvalue .= ''.' ';
+ }
+ }
+ return $retvalue;
+ }
} //end class Display
\ No newline at end of file
diff --git a/main/inc/lib/social.lib.php b/main/inc/lib/social.lib.php
index 4761d1238a..99e5fc508f 100755
--- a/main/inc/lib/social.lib.php
+++ b/main/inc/lib/social.lib.php
@@ -367,7 +367,7 @@ class SocialManager extends UserManager {
* Helper functions definition
*/
public static function get_logged_user_course_html($my_course, $count) {
- global $nosession;
+ global $nosession, $nbDigestEntries, $orderKey, $digest, $thisCourseSysCode;
if (api_get_setting('use_session_mode')=='true' && !$nosession) {
global $now, $date_start, $date_end;
}
@@ -431,51 +431,17 @@ class SocialManager extends UserManager {
//display course entry
$result .= '
';
- //$result .= '
';
$result .= '';
$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) {
$result .= ' '.$course_title.'
';
- /*
- 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.'';
- $result .= '
'.$course_display_title.'';
- }
- } else {
- //$result .= '
'.$course_display_title.'';
- $result .= '
'.$course_display_title.'';
- }*/
} else {
$result .= $course_display_title." "." ".get_lang('CourseClosed')."";
}
- // show the course_code and teacher if chosen to display this
- // we dont need this!
- /*
- if (api_get_setting('display_coursecode_in_courselist') == 'true' OR api_get_setting('display_teacher_in_courselist') == 'true') {
- $result .= '
';
- }
- if (api_get_setting('display_coursecode_in_courselist') == 'true') {
- $result .= $course_display_code;
- }
- if (api_get_setting('display_coursecode_in_courselist') == 'true' AND api_get_setting('display_teacher_in_courselist') == 'true') {
- $result .= ' – ';
- }
- if (api_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 .= '
';
diff --git a/user_portal.php b/user_portal.php
index dabae3ad52..4455dd626f 100755
--- a/user_portal.php
+++ b/user_portal.php
@@ -154,8 +154,6 @@ Display :: display_header($nameTools);
FUNCTIONS
display_digest($toolsList, $digest, $orderKey, $courses)
- show_notification($my_course)
-
get_logged_user_course_html($my_course)
get_user_course_categories()
*/
@@ -405,7 +403,7 @@ function get_logged_user_course_html($course, $session_id = 0, $class = 'courses
$current_course_settings = CourseManager :: get_access_settings($my_course['k']);
// Display the "what's new" icons.
- $result .= show_notification($my_course);
+ $result .= Display :: show_notification($my_course);
if ((CONFVAL_showExtractInfo == SCRIPTVAL_InCourseList || CONFVAL_showExtractInfo == SCRIPTVAL_Both) && $nbDigestEntries > 0) {
@@ -573,97 +571,7 @@ function get_global_courses_list($user_id) {
return $output;
}
-/**
- * Returns the "what's new" icon notifications
- *
- * The general logic of this function is to track the last time the user
- * entered the course and compare to what has changed inside this course
- * since then, based on the item_property table inside this course. Note that,
- * if the user never entered the course before, he will not see notification
- * icons. This function takes session ID into account (if any) and only shows
- * the corresponding 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
- */
-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' AND access_session_id ='".$my_course['id_session']."'";
- $resLastTrackInCourse = Database::query($sqlLastTrackInCourse);
-
- $oldestTrackDate = '3000-01-01 00:00:00';
- while ($lastTrackInCourse = Database::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 AND tet.id_session = '".$my_course['id_session']."'
- ORDER BY tet.lastedit_date";
- $res = Database::query($sql);
- // Get the group_id's with user membership.
- $group_ids = GroupManager :: get_group_ids($course_database, $user_id);
- $group_ids[] = 0; //add group 'everyone'
- // Filter all selected items.
- while ($res && ($item_property = Database::fetch_array($res))) {
- // First thing to check is if the user never entered the tool
- // or if his last visit was earlier than the last modification.
- if ((!isset ($lastTrackInCourseDate[$item_property['tool']]) || $lastTrackInCourseDate[$item_property['tool']] < $item_property['lastedit_date'])
- // Drop the tool elements that are part of a group that the
- // user is not part of.
- && ((in_array($item_property['to_group_id'], $group_ids)
- // Drop the dropbox, notebook and chat tools because we don't care.
- && ($item_property['tool'] != TOOL_DROPBOX && $item_property['tool'] != TOOL_NOTEBOOK && $item_property['tool'] != TOOL_CHAT)))
- // Take only what's visible or invisible but where the user is a teacher or where the visibility is unset.
- && ($item_property['visibility'] == '1' || ($my_course['s'] == '1' && $item_property['visibility'] == '0') || !isset($item_property['visibility']))) {
-
- // Also drop announcements and events that are not for the user or his group.
- if (($item_property['tool'] == TOOL_ANNOUNCEMENT || $item_property['tool'] == TOOL_CALENDAR_EVENT) && (($item_property['to_user_id'] != $user_id ) && (!isset($item_property['to_group_id']) || !in_array($item_property['to_group_id'], $group_ids)))) continue;
- // If it's a survey, make sure the user's invited. Otherwise drop it.
- if ($item_property['tool'] == TOOL_SURVEY) {
- $survey_info = survey_manager::get_survey($item_property['ref'], 0, $my_course['k']);
- $invited_users = SurveyUtil::get_invited_users($survey_info['code'], $course_database);
- if (!in_array($user_id, $invited_users['course_users'])) continue;
- }
- $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]);
- if (empty($my_course['id_session'])) {
- $my_course['id_session'] = 0;
- }
- $retvalue .= ''.' ';
- }
- }
- return $retvalue;
-}
/**
* Retrieves the user defined course categories