Refactor whoisonlinesession, check the current session see BT#14262

pull/2539/head
jmontoyaa 8 years ago
parent cf3373de42
commit 507e2369b0
  1. 59
      whoisonlinesession.php

@ -18,6 +18,10 @@ if (empty($userId)) {
$sessionId = api_get_session_id(); $sessionId = api_get_session_id();
$courseId = api_get_course_int_id(); $courseId = api_get_course_int_id();
if (empty($sessionId)) {
api_not_allowed(true);
}
$allow = api_is_platform_admin(true) || $allow = api_is_platform_admin(true) ||
api_is_coach($sessionId, $courseId, false) || api_is_coach($sessionId, $courseId, false) ||
SessionManager::get_user_status_in_course_session(api_get_user_id(), $courseId, $sessionId) == 2; SessionManager::get_user_status_in_course_session(api_get_user_id(), $courseId, $sessionId) == 2;
@ -26,19 +30,13 @@ if (!$allow) {
api_not_allowed(true); api_not_allowed(true);
} }
/** $sessionInfo = api_get_session_info($sessionId);
* Header
* include the HTTP, HTML headers plus the top banner. Display::display_header(get_lang('UsersOnLineList'));
*/ echo Display::page_header($sessionInfo['name']);
Display::display_header(get_lang('UserOnlineListSession'));
?> ?>
<br /> <br />
<table class="data_table"> <table class="data_table">
<tr class="tableName">
<td colspan="4">
<strong><?php echo get_lang('UserOnlineListSession'); ?></strong>
</td>
</tr>
<tr> <tr>
<th> <th>
<?php echo get_lang('Name'); ?> <?php echo get_lang('Name'); ?>
@ -46,9 +44,6 @@ Display::display_header(get_lang('UserOnlineListSession'));
<th> <th>
<?php echo get_lang('InCourse'); ?> <?php echo get_lang('InCourse'); ?>
</th> </th>
<th>
<?php echo get_lang('Email'); ?>
</th>
<th> <th>
<?php echo get_lang('Chat'); ?> <?php echo get_lang('Chat'); ?>
</th> </th>
@ -72,14 +67,12 @@ if (api_is_multiple_url_enabled()) {
$online_time = time() - $time_limit * 60; $online_time = time() - $time_limit * 60;
$current_date = api_get_utc_datetime($online_time); $current_date = api_get_utc_datetime($online_time);
$students_online = []; $studentsOnline = [];
$sql = "SELECT DISTINCT last_access.login_user_id, $sql = "SELECT DISTINCT last_access.login_user_id,
last_access.login_date, last_access.login_date,
last_access.c_id, last_access.c_id,
last_access.session_id, last_access.session_id
".(api_is_western_name_order() ? "CONCAT(user.firstname,' ',user.lastname)" : "CONCAT(user.lastname,' ',user.firstname)")." as name,
user.email
FROM ".Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE)." AS last_access FROM ".Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE)." AS last_access
INNER JOIN ".Database::get_main_table(TABLE_MAIN_USER)." AS user INNER JOIN ".Database::get_main_table(TABLE_MAIN_USER)." AS user
ON user.id = last_access.login_user_id ON user.id = last_access.login_user_id
@ -92,31 +85,31 @@ $sql = "SELECT DISTINCT last_access.login_user_id,
$result = Database::query($sql); $result = Database::query($sql);
while ($user_list = Database::fetch_array($result)) { while ($user_list = Database::fetch_array($result)) {
$students_online[$user_list['login_user_id']] = $user_list; $studentsOnline[$user_list['login_user_id']] = $user_list;
} }
if (count($students_online) > 0) { if (count($studentsOnline) > 0) {
foreach ($students_online as $student_online) { foreach ($studentsOnline as $student_online) {
$userInfo = api_get_user_info($student_online['login_user_id']);
if (empty($userInfo)) {
continue;
}
echo "<tr> echo "<tr>
<td> <td>
"; ";
echo $student_online['name']; echo $userInfo['complete_name_with_message_link'];
echo " </td> echo " </td>
<td> <td>
"; ";
$courseInfo = api_get_course_info_by_id($student_online['c_id']); $courseInfo = api_get_course_info_by_id($student_online['c_id']);
echo $courseInfo['title']; echo Display::url(
echo " </td> $courseInfo['title'],
<td> $courseInfo['course_public_url'].'?id_session='.$student_online['session_id'],
"; ['target' => '_blank']
if (!empty($student_online['email'])) { );
echo $student_online['email']; echo " </td>";
} else { echo "<td>";
echo get_lang('NoEmail');
}
echo " </td>
<td>
";
echo '<a echo '<a
target="_blank" target="_blank"
href="main/chat/chat.php?cidReq='.$courseInfo['code'].'&id_session='.$student_online['session_id'].'"> -> </a>'; href="main/chat/chat.php?cidReq='.$courseInfo['code'].'&id_session='.$student_online['session_id'].'"> -> </a>';

Loading…
Cancel
Save