whoisonlinesession.php 3.3 KB

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