whoisonlinesession.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <?php
  2. /* For licensing terms, see /dokeos_license.txt */
  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. $tbl_session = Database :: get_main_table(TABLE_MAIN_SESSION);
  12. $tbl_session_course = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE);
  13. /*
  14. -----------------------------------------------------------
  15. Header
  16. include the HTTP, HTML headers plus the top banner
  17. -----------------------------------------------------------
  18. */
  19. Display::display_header(get_lang('UserOnlineListSession'));
  20. ?>
  21. <br/><br/>
  22. <table class="data_table" width="60%">
  23. <tr class="tableName">
  24. <td colspan="4">
  25. <strong><?php echo get_lang('UserOnlineListSession'); ?></strong>
  26. </td>
  27. </tr>
  28. <tr>
  29. <th class="head">
  30. <?php echo get_lang('Name'); ?>
  31. </th>
  32. <th class="head">
  33. <?php echo get_lang('InCourse'); ?>
  34. </th>
  35. <th class="head">
  36. <?php echo get_lang('Email'); ?>
  37. </th>
  38. <th class="head">
  39. <?php echo get_lang('Chat'); ?>
  40. </th>
  41. </tr>
  42. <?php
  43. $sessionIsCoach = array();
  44. if (isset($_user['user_id']) && $_user['user_id']!='') {
  45. $_user['user_id'] = intval($_user['user_id']);
  46. $result = api_sql_query("SELECT DISTINCT id,
  47. name,
  48. date_start,
  49. date_end
  50. FROM $tbl_session as session
  51. INNER JOIN $tbl_session_course as session_rel_course
  52. ON session_rel_course.id_coach = ".$_user['user_id']."
  53. AND session.id = session_rel_course.id_session
  54. ORDER BY date_start, date_end, name",__FILE__,__LINE__);
  55. while ($session = Database:: fetch_array($result)) {
  56. $sessionIsCoach[$session['id']] = $session;
  57. }
  58. $result = api_sql_query("SELECT DISTINCT id,
  59. name,
  60. date_start,
  61. date_end
  62. FROM $tbl_session as session
  63. WHERE session.id_coach = ".$_user['user_id']."
  64. ORDER BY date_start, date_end, name",__FILE__,__LINE__);
  65. while ($session = Database:: fetch_array($result)) {
  66. $sessionIsCoach[$session['id']] = $session;
  67. }
  68. foreach($sessionIsCoach as $session) {
  69. $sql = "SELECT DISTINCT last_access.access_user_id,
  70. last_access.access_date,
  71. last_access.access_cours_code,
  72. last_access.access_session_id,
  73. CONCAT(user.lastname,' ',user.firstname) as name,
  74. user.email
  75. FROM ".Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_LASTACCESS)." AS last_access
  76. INNER JOIN ".Database::get_main_table(TABLE_MAIN_USER)." AS user
  77. ON user.user_id = last_access.access_user_id
  78. WHERE access_session_id='".$session['id']."'
  79. AND NOW()-access_date<1000 GROUP BY access_user_id";
  80. $result = api_sql_query($sql,__FILE__,__LINE__);
  81. while($a_userList = mysql_fetch_array($result)) {
  82. $a_onlineStudent[$a_userList['access_user_id']] = $a_userList;
  83. }
  84. }
  85. if(count($a_onlineStudent)>0) {
  86. foreach($a_onlineStudent as $onlineStudent) {
  87. echo "<tr>
  88. <td>
  89. ";
  90. echo $onlineStudent['name'];
  91. echo " </td>
  92. <td align='center'>
  93. ";
  94. echo $onlineStudent['access_cours_code'];
  95. echo " </td>
  96. <td align='center'>
  97. ";
  98. if(!empty($onlineStudent['email']))
  99. {
  100. echo $onlineStudent['email'];
  101. }
  102. else
  103. {
  104. echo get_lang('NoEmail');
  105. }
  106. echo " </td>
  107. <td align='center'>
  108. ";
  109. echo '<a href="main/chat/chat.php?cidReq='.$onlineStudent['access_cours_code'].'&id_session='.$onlineStudent['access_session_id'].'"> -> </a>';
  110. echo " </td>
  111. </tr>
  112. ";
  113. }
  114. } else {
  115. echo ' <tr>
  116. <td colspan="4">
  117. '.get_lang('NoOnlineStudents').'
  118. </td>
  119. </tr>
  120. ';
  121. }
  122. }
  123. ?>
  124. </table>
  125. <?php
  126. /*
  127. ==============================================================================
  128. FOOTER
  129. ==============================================================================
  130. */
  131. Display::display_footer();
  132. ?>