whoisonlinesession.php 3.4 KB

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