|
|
|
|
@ -215,6 +215,7 @@ function returnNotificationMenu() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$user_id = api_get_user_id(); |
|
|
|
|
$sessionId = api_get_session_id(); |
|
|
|
|
|
|
|
|
|
$html = ''; |
|
|
|
|
|
|
|
|
|
@ -250,11 +251,15 @@ function returnNotificationMenu() |
|
|
|
|
.' '.$number_online_in_course.' </a></li>'; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (isset($user_id) && api_get_session_id() != 0) { |
|
|
|
|
|
|
|
|
|
if (isset($user_id) && $sessionId != 0) { |
|
|
|
|
$numberOnlineInSession = getOnlineUsersInSessionCount($sessionId); |
|
|
|
|
|
|
|
|
|
$html .= '<li><a href="'.api_get_path(WEB_PATH) |
|
|
|
|
.'whoisonlinesession.php?id_coach='.$user_id.'&referer='.urlencode($_SERVER['REQUEST_URI']) |
|
|
|
|
.'" target="_self">' |
|
|
|
|
.Display::return_icon('session.png', get_lang('UsersConnectedToMySessions'), array(), ICON_SIZE_TINY) |
|
|
|
|
.' '.$numberOnlineInSession |
|
|
|
|
.'</a></li>'; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
@ -887,3 +892,38 @@ function getOnlineUsersInCourseCount($userId, $_course) |
|
|
|
|
|
|
|
|
|
return $numberOnlineInCourse; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Helper function to get the number of users online in a session, using cache if available |
|
|
|
|
* @param int $sessionId The session ID |
|
|
|
|
* @return int The number of users currently online |
|
|
|
|
*/ |
|
|
|
|
function getOnlineUsersInSessionCount($sessionId) |
|
|
|
|
{ |
|
|
|
|
$cacheAvailable = api_get_configuration_value('apc'); |
|
|
|
|
|
|
|
|
|
if (!$sessionId) { |
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ($cacheAvailable === true) { |
|
|
|
|
$apcVar = api_get_configuration_value('apc_prefix').'my_campus_whoisonline_session_count_simple_'.$sessionId; |
|
|
|
|
|
|
|
|
|
if (apcu_exists($apcVar)) { |
|
|
|
|
return apcu_fetch($apcVar); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$numberOnlineInCourse = whoIsOnlineInIhisSessionCount( |
|
|
|
|
api_get_setting('time_limit_whosonline'), |
|
|
|
|
$sessionId |
|
|
|
|
); |
|
|
|
|
apcu_store($apcVar, $numberOnlineInCourse, 15); |
|
|
|
|
|
|
|
|
|
return $numberOnlineInCourse; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return whoIsOnlineInIhisSessionCount( |
|
|
|
|
api_get_setting('time_limit_whosonline'), |
|
|
|
|
$sessionId |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|