Browse Source

Remove anon users in "whoisonline" pages see BT#13324

jmontoyaa 7 years ago
parent
commit
493eda437f
3 changed files with 28 additions and 15 deletions
  1. 1 3
      main/inc/lib/banner.lib.php
  2. 21 7
      main/inc/lib/online.inc.php
  3. 6 5
      whoisonlinesession.php

+ 1 - 3
main/inc/lib/banner.lib.php

@@ -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>';

+ 21 - 7
main/inc/lib/online.inc.php

@@ -411,6 +411,7 @@ 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'];
@@ -418,8 +419,13 @@ function who_is_online_in_this_course($from, $number_of_items, $uid, $time_limit
     $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);
@@ -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;
@@ -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);
@@ -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)
 {
@@ -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) {

+ 6 - 5
whoisonlinesession.php

@@ -1,5 +1,6 @@
 <?php
 /* For licensing terms, see /license.txt */
+
 /**
  * Shows who is online in a specific session
  * @package chamilo.main
@@ -18,8 +19,8 @@ $tbl_session_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_US
 
 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>
@@ -109,12 +110,12 @@ if (isset($_user['user_id']) && $_user['user_id'] != '') {
                 ";
             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'];
@@ -122,7 +123,7 @@ if (isset($_user['user_id']) && $_user['user_id'] != '') {
                 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>