Skip to content

Commit 507e236

Browse files
committed
Refactor whoisonlinesession, check the current session see BT#14262
1 parent cf3373d commit 507e236

File tree

1 file changed

+26
-33
lines changed

1 file changed

+26
-33
lines changed

whoisonlinesession.php

Lines changed: 26 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
$sessionId = api_get_session_id();
1919
$courseId = api_get_course_int_id();
2020

21+
if (empty($sessionId)) {
22+
api_not_allowed(true);
23+
}
24+
2125
$allow = api_is_platform_admin(true) ||
2226
api_is_coach($sessionId, $courseId, false) ||
2327
SessionManager::get_user_status_in_course_session(api_get_user_id(), $courseId, $sessionId) == 2;
@@ -26,29 +30,20 @@
2630
api_not_allowed(true);
2731
}
2832

29-
/**
30-
* Header
31-
* include the HTTP, HTML headers plus the top banner.
32-
*/
33-
Display::display_header(get_lang('UserOnlineListSession'));
33+
$sessionInfo = api_get_session_info($sessionId);
34+
35+
Display::display_header(get_lang('UsersOnLineList'));
36+
echo Display::page_header($sessionInfo['name']);
3437
?>
3538
<br />
3639
<table class="data_table">
37-
<tr class="tableName">
38-
<td colspan="4">
39-
<strong><?php echo get_lang('UserOnlineListSession'); ?></strong>
40-
</td>
41-
</tr>
4240
<tr>
4341
<th>
4442
<?php echo get_lang('Name'); ?>
4543
</th>
4644
<th>
4745
<?php echo get_lang('InCourse'); ?>
4846
</th>
49-
<th>
50-
<?php echo get_lang('Email'); ?>
51-
</th>
5247
<th>
5348
<?php echo get_lang('Chat'); ?>
5449
</th>
@@ -72,14 +67,12 @@
7267

7368
$online_time = time() - $time_limit * 60;
7469
$current_date = api_get_utc_datetime($online_time);
75-
$students_online = [];
70+
$studentsOnline = [];
7671

7772
$sql = "SELECT DISTINCT last_access.login_user_id,
7873
last_access.login_date,
7974
last_access.c_id,
80-
last_access.session_id,
81-
".(api_is_western_name_order() ? "CONCAT(user.firstname,' ',user.lastname)" : "CONCAT(user.lastname,' ',user.firstname)")." as name,
82-
user.email
75+
last_access.session_id
8376
FROM ".Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE)." AS last_access
8477
INNER JOIN ".Database::get_main_table(TABLE_MAIN_USER)." AS user
8578
ON user.id = last_access.login_user_id
@@ -92,31 +85,31 @@
9285

9386
$result = Database::query($sql);
9487
while ($user_list = Database::fetch_array($result)) {
95-
$students_online[$user_list['login_user_id']] = $user_list;
88+
$studentsOnline[$user_list['login_user_id']] = $user_list;
9689
}
9790

98-
if (count($students_online) > 0) {
99-
foreach ($students_online as $student_online) {
91+
if (count($studentsOnline) > 0) {
92+
foreach ($studentsOnline as $student_online) {
93+
$userInfo = api_get_user_info($student_online['login_user_id']);
94+
if (empty($userInfo)) {
95+
continue;
96+
}
97+
10098
echo "<tr>
10199
<td>
102100
";
103-
echo $student_online['name'];
101+
echo $userInfo['complete_name_with_message_link'];
104102
echo " </td>
105103
<td>
106104
";
107105
$courseInfo = api_get_course_info_by_id($student_online['c_id']);
108-
echo $courseInfo['title'];
109-
echo " </td>
110-
<td>
111-
";
112-
if (!empty($student_online['email'])) {
113-
echo $student_online['email'];
114-
} else {
115-
echo get_lang('NoEmail');
116-
}
117-
echo " </td>
118-
<td>
119-
";
106+
echo Display::url(
107+
$courseInfo['title'],
108+
$courseInfo['course_public_url'].'?id_session='.$student_online['session_id'],
109+
['target' => '_blank']
110+
);
111+
echo " </td>";
112+
echo "<td>";
120113
echo '<a
121114
target="_blank"
122115
href="main/chat/chat.php?cidReq='.$courseInfo['code'].'&id_session='.$student_online['session_id'].'"> -> </a>';

0 commit comments

Comments
 (0)