Skip to content

Commit

Permalink
Remove anon users in "whoisonline" pages see BT#13324
Browse files Browse the repository at this point in the history
  • Loading branch information
jmontoyaa committed Sep 21, 2017
1 parent 7dce46d commit 493eda4
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 15 deletions.
4 changes: 1 addition & 3 deletions main/inc/lib/banner.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,7 @@ function returnNotificationMenu()
if (isset($user_id) && $sessionId != 0) {
$numberOnlineInSession = getOnlineUsersInSessionCount($sessionId);

$html .= '<li><a href="'.api_get_path(WEB_PATH)
.'whoisonlinesession.php?id_coach='.$user_id.'&amp;referer='.urlencode($_SERVER['REQUEST_URI'])
.'" target="_self">'
$html .= '<li><a href="'.api_get_path(WEB_PATH).'whoisonlinesession.php?id_coach='.$user_id.'" target="_self">'
.Display::return_icon('session.png', get_lang('UsersConnectedToMySessions'), array(), ICON_SIZE_TINY)
.' '.$numberOnlineInSession
.'</a></li>';
Expand Down
28 changes: 21 additions & 7 deletions main/inc/lib/online.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -411,15 +411,21 @@ function who_is_online_in_this_course($from, $number_of_items, $uid, $time_limit
$online_time = time() - $time_limit * 60;
$current_date = api_get_utc_datetime($online_time);
$track_online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE);
$tableUser = Database::get_main_table(TABLE_MAIN_USER);
$course_code = Database::escape_string($course_code);
$courseInfo = api_get_course_info($course_code);
$courseId = $courseInfo['real_id'];

$from = intval($from);
$number_of_items = intval($number_of_items);

$query = "SELECT login_user_id, login_date FROM $track_online_table
WHERE login_user_id <> 2 AND c_id = $courseId AND login_date >= '$current_date'
$query = "SELECT o.login_user_id, o.login_date
FROM $track_online_table o INNER JOIN $tableUser u
ON (o.login_user_id = u.id)
WHERE
u.status <> '".ANONYMOUS."' AND
o.c_id = $courseId AND
o.login_date >= '$current_date'
LIMIT $from, $number_of_items ";

$result = Database::query($query);
Expand Down Expand Up @@ -447,6 +453,8 @@ function who_is_online_in_this_course_count(
return false;
}
$track_online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE);
$tableUser = Database::get_main_table(TABLE_MAIN_USER);

$time_limit = Database::escape_string($time_limit);

$online_time = time() - $time_limit * 60;
Expand All @@ -458,9 +466,10 @@ function who_is_online_in_this_course_count(
}

$query = "SELECT count(login_user_id) as count
FROM $track_online_table
FROM $track_online_table o INNER JOIN $tableUser u
ON (login_user_id = u.id)
WHERE
login_user_id <> 2 AND
u.status <> '".ANONYMOUS."' AND
c_id = $courseId AND
login_date >= '$current_date' ";
$result = Database::query($query);
Expand All @@ -477,7 +486,6 @@ function who_is_online_in_this_course_count(
* @param string $timeLimit
* @param int $sessionId
* @return bool
* @internal param int $uid
*/
function whoIsOnlineInThisSessionCount($timeLimit, $sessionId)
{
Expand All @@ -486,14 +494,20 @@ function whoIsOnlineInThisSessionCount($timeLimit, $sessionId)
}

$tblTrackOnline = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE);
$tableUser = Database::get_main_table(TABLE_MAIN_USER);

$timeLimit = Database::escape_string($timeLimit);

$online_time = time() - $timeLimit * 60;
$current_date = api_get_utc_datetime($online_time);

$query = "SELECT count(login_user_id) as count
FROM $tblTrackOnline
WHERE login_user_id <> 2 AND session_id = $sessionId AND login_date >= '$current_date' ";
FROM $tblTrackOnline o INNER JOIN $tableUser u
ON (login_user_id = u.id)
WHERE
u.status <> '".ANONYMOUS."' AND
session_id = $sessionId AND
login_date >= '$current_date' ";
$result = Database::query($query);

if (Database::num_rows($result) > 0) {
Expand Down
11 changes: 6 additions & 5 deletions whoisonlinesession.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
/* For licensing terms, see /license.txt */

/**
* Shows who is online in a specific session
* @package chamilo.main
Expand All @@ -18,8 +19,8 @@

Display::display_header(get_lang('UserOnlineListSession'));
?>
<br /><br />
<table class="data_table" width="60%">
<br />
<table class="data_table">
<tr class="tableName">
<td colspan="4">
<strong><?php echo get_lang('UserOnlineListSession'); ?></strong>
Expand Down Expand Up @@ -109,20 +110,20 @@
";
echo $student_online['name'];
echo " </td>
<td align='center'>
<td>
";
$courseInfo = api_get_course_info_by_id($student_online['c_id']);
echo $courseInfo['title'];
echo " </td>
<td align='center'>
<td>
";
if (!empty($student_online['email'])) {
echo $student_online['email'];
} else {
echo get_lang('NoEmail');
}
echo " </td>
<td align='center'>
<td>
";
echo '<a href="main/chat/chat.php?cidReq='.$courseInfo['code'].'&id_session='.$student_online['access_session_id'].'"> -> </a>';
echo " </td>
Expand Down

0 comments on commit 493eda4

Please sign in to comment.