whoisonlinesession.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <?php
  2. // Dokeos Header here
  3. /**
  4. * @todo variables are sometimes in cammelcase, or even worse a mixture of CammelCase and udnerscoring: $a_userList
  5. *
  6. */
  7. // name of the language file that needs to be included
  8. $language_file = array ('index', 'chat', 'tracking');
  9. include_once("./main/inc/global.inc.php");
  10. api_block_anonymous_users();
  11. /*
  12. -----------------------------------------------------------
  13. Header
  14. include the HTTP, HTML headers plus the top banner
  15. -----------------------------------------------------------
  16. */
  17. Display::display_header(get_lang('UserOnlineListSession'));
  18. ?>
  19. <br/><br/>
  20. <table class="data_table" width="60%">
  21. <tr class="tableName">
  22. <td colspan="4">
  23. <strong><?php echo get_lang('UserOnlineListSession'); ?></strong>
  24. </td>
  25. </tr>
  26. <tr>
  27. <th class="head">
  28. <?php echo get_lang('Name'); ?>
  29. </th>
  30. <th class="head">
  31. <?php echo get_lang('InCourse'); ?>
  32. </th>
  33. <th class="head">
  34. <?php echo get_lang('Email'); ?>
  35. </th>
  36. <th class="head">
  37. <?php echo get_lang('Chat'); ?>
  38. </th>
  39. </tr>
  40. <?php
  41. $result = api_sql_query("SELECT DISTINCT id,
  42. name,
  43. date_start,
  44. date_end
  45. FROM session
  46. INNER JOIN session_rel_course
  47. ON session_rel_course.id_coach = ".$_user['user_id']."
  48. ORDER BY date_start, date_end, name",__FILE__,__LINE__);
  49. $sessionIsCoach = api_store_result($result);
  50. $result = api_sql_query("SELECT DISTINCT id,
  51. name,
  52. date_start,
  53. date_end
  54. FROM session
  55. WHERE session.id_coach = ".$_user['user_id']."
  56. ORDER BY date_start, date_end, name",__FILE__,__LINE__);
  57. $sessionIsCoach = array_merge($sessionIsCoach , api_store_result($result));
  58. foreach($sessionIsCoach as $session)
  59. {
  60. $sql = "SELECT DISTINCT last_access.access_user_id,
  61. last_access.access_date,
  62. last_access.access_cours_code,
  63. last_access.access_session_id,
  64. CONCAT(user.lastname,' ',user.firstname) as name,
  65. user.email
  66. FROM ".Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_LASTACCESS)." AS last_access
  67. INNER JOIN ".Database::get_main_table(TABLE_MAIN_USER)." AS user
  68. ON user.user_id = last_access.access_user_id
  69. WHERE access_session_id='".$session['id']."'
  70. AND NOW()-access_date<1000 GROUP BY access_user_id
  71. ";
  72. $result = api_sql_query($sql,__FILE__,__LINE__);
  73. while($a_userList = mysql_fetch_array($result))
  74. {
  75. $a_onlineStudent[$a_userList['access_user_id']] = $a_userList;
  76. }
  77. }
  78. if(count($a_onlineStudent)>0)
  79. {
  80. foreach($a_onlineStudent as $onlineStudent)
  81. {
  82. echo "<tr>
  83. <td>
  84. ";
  85. echo $onlineStudent['name'];
  86. echo " </td>
  87. <td align='center'>
  88. ";
  89. echo $onlineStudent['access_cours_code'];
  90. echo " </td>
  91. <td align='center'>
  92. ";
  93. if(!empty($onlineStudent['email']))
  94. {
  95. echo $onlineStudent['email'];
  96. }
  97. else
  98. {
  99. echo get_lang('NoEmail');
  100. }
  101. echo " </td>
  102. <td align='center'>
  103. ";
  104. echo '<a href="main/chat/chat.php?cidReq='.$onlineStudent['access_cours_code'].'&id_session='.$onlineStudent['access_session_id'].'"> -> </a>';
  105. echo " </td>
  106. </tr>
  107. ";
  108. }
  109. }
  110. else
  111. {
  112. echo ' <tr>
  113. <td colspan="4">
  114. '.get_lang('NoOnlineStudents').'
  115. </td>
  116. </tr>
  117. ';
  118. }
  119. ?>
  120. </table>
  121. <?php
  122. /*
  123. ==============================================================================
  124. FOOTER
  125. ==============================================================================
  126. */
  127. Display::display_footer();
  128. ?>