whoisonlinesession.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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. $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. $result = api_sql_query("SELECT DISTINCT id,
  45. name,
  46. date_start,
  47. date_end
  48. FROM $tbl_session as session
  49. INNER JOIN $tbl_session_course as session_rel_course
  50. ON session_rel_course.id_coach = ".$_user['user_id']."
  51. AND session.id = session_rel_course.id_session
  52. ORDER BY date_start, date_end, name",__FILE__,__LINE__);
  53. while ($session = Database:: fetch_array($result))
  54. {
  55. $sessionIsCoach[$session['id']] = $session;
  56. }
  57. $result = api_sql_query("SELECT DISTINCT id,
  58. name,
  59. date_start,
  60. date_end
  61. FROM $tbl_session as session
  62. WHERE session.id_coach = ".$_user['user_id']."
  63. ORDER BY date_start, date_end, name",__FILE__,__LINE__);
  64. while ($session = Database:: fetch_array($result))
  65. {
  66. $sessionIsCoach[$session['id']] = $session;
  67. }
  68. foreach($sessionIsCoach as $session)
  69. {
  70. $sql = "SELECT DISTINCT last_access.access_user_id,
  71. last_access.access_date,
  72. last_access.access_cours_code,
  73. last_access.access_session_id,
  74. CONCAT(user.lastname,' ',user.firstname) as name,
  75. user.email
  76. FROM ".Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_LASTACCESS)." AS last_access
  77. INNER JOIN ".Database::get_main_table(TABLE_MAIN_USER)." AS user
  78. ON user.user_id = last_access.access_user_id
  79. WHERE access_session_id='".$session['id']."'
  80. AND NOW()-access_date<1000 GROUP BY access_user_id
  81. ";
  82. $result = api_sql_query($sql,__FILE__,__LINE__);
  83. while($a_userList = mysql_fetch_array($result))
  84. {
  85. $a_onlineStudent[$a_userList['access_user_id']] = $a_userList;
  86. }
  87. }
  88. if(count($a_onlineStudent)>0)
  89. {
  90. foreach($a_onlineStudent as $onlineStudent)
  91. {
  92. echo "<tr>
  93. <td>
  94. ";
  95. echo $onlineStudent['name'];
  96. echo " </td>
  97. <td align='center'>
  98. ";
  99. echo $onlineStudent['access_cours_code'];
  100. echo " </td>
  101. <td align='center'>
  102. ";
  103. if(!empty($onlineStudent['email']))
  104. {
  105. echo $onlineStudent['email'];
  106. }
  107. else
  108. {
  109. echo get_lang('NoEmail');
  110. }
  111. echo " </td>
  112. <td align='center'>
  113. ";
  114. echo '<a href="main/chat/chat.php?cidReq='.$onlineStudent['access_cours_code'].'&id_session='.$onlineStudent['access_session_id'].'"> -> </a>';
  115. echo " </td>
  116. </tr>
  117. ";
  118. }
  119. }
  120. else
  121. {
  122. echo ' <tr>
  123. <td colspan="4">
  124. '.get_lang('NoOnlineStudents').'
  125. </td>
  126. </tr>
  127. ';
  128. }
  129. ?>
  130. </table>
  131. <?php
  132. /*
  133. ==============================================================================
  134. FOOTER
  135. ==============================================================================
  136. */
  137. Display::display_footer();
  138. ?>