Skip to content

Commit 53adbbc

Browse files
committed
Show users only from current portal in who is online see BT#14262
1 parent fed1248 commit 53adbbc

File tree

1 file changed

+31
-9
lines changed

1 file changed

+31
-9
lines changed

main/inc/lib/online.inc.php

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -417,10 +417,9 @@ function who_is_online_in_this_course($from, $number_of_items, $uid, $time_limit
417417
return false;
418418
}
419419

420+
$time_limit = (int) $time_limit;
420421
if (empty($time_limit)) {
421422
$time_limit = api_get_setting('time_limit_whosonline');
422-
} else {
423-
$time_limit = intval($time_limit);
424423
}
425424

426425
$online_time = time() - $time_limit * 60;
@@ -431,16 +430,28 @@ function who_is_online_in_this_course($from, $number_of_items, $uid, $time_limit
431430
$courseInfo = api_get_course_info($course_code);
432431
$courseId = $courseInfo['real_id'];
433432

434-
$from = intval($from);
435-
$number_of_items = intval($number_of_items);
433+
$from = (int) $from;
434+
$number_of_items = (int) $number_of_items;
435+
436+
$urlCondition = '';
437+
$urlJoin = '';
438+
if (api_is_multiple_url_enabled()) {
439+
$accessUrlUser = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
440+
$urlId = api_get_current_access_url_id();
441+
$urlJoin = " INNER JOIN $accessUrlUser a ON (a.user_id = u.id) ";
442+
$urlCondition = " AND a.access_url_id = $urlId ";
443+
}
436444

437445
$query = "SELECT o.login_user_id, o.login_date
438-
FROM $track_online_table o INNER JOIN $tableUser u
446+
FROM $track_online_table o
447+
INNER JOIN $tableUser u
439448
ON (o.login_user_id = u.id)
449+
$urlJoin
440450
WHERE
441451
u.status <> '".ANONYMOUS."' AND
442452
o.c_id = $courseId AND
443453
o.login_date >= '$current_date'
454+
$urlCondition
444455
LIMIT $from, $number_of_items ";
445456

446457
$result = Database::query($query);
@@ -470,9 +481,7 @@ function who_is_online_in_this_course_count(
470481
}
471482
$track_online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE);
472483
$tableUser = Database::get_main_table(TABLE_MAIN_USER);
473-
474484
$time_limit = Database::escape_string($time_limit);
475-
476485
$online_time = time() - $time_limit * 60;
477486
$current_date = api_get_utc_datetime($online_time);
478487
$courseId = api_get_course_int_id($coursecode);
@@ -481,13 +490,26 @@ function who_is_online_in_this_course_count(
481490
return false;
482491
}
483492

493+
$urlCondition = '';
494+
$urlJoin = '';
495+
if (api_is_multiple_url_enabled()) {
496+
$accessUrlUser = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
497+
$urlId = api_get_current_access_url_id();
498+
$urlJoin = " INNER JOIN $accessUrlUser a ON (a.user_id = u.id) ";
499+
$urlCondition = " AND a.access_url_id = $urlId ";
500+
}
501+
484502
$query = "SELECT count(login_user_id) as count
485-
FROM $track_online_table o INNER JOIN $tableUser u
503+
FROM $track_online_table o
504+
INNER JOIN $tableUser u
486505
ON (login_user_id = u.id)
506+
$urlJoin
487507
WHERE
488508
u.status <> '".ANONYMOUS."' AND
489509
c_id = $courseId AND
490-
login_date >= '$current_date' ";
510+
login_date >= '$current_date'
511+
$urlCondition
512+
";
491513
$result = Database::query($query);
492514
if (Database::num_rows($result) > 0) {
493515
$row = Database::fetch_array($result);

0 commit comments

Comments
 (0)