online_whoisonline.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <?php // $Id: online_whoisonline.php 9246 2006-09-25 13:24:53Z bmol $
  2. /*
  3. ==============================================================================
  4. Dokeos - elearning and course management software
  5. Copyright (c) 2004 Dokeos S.A.
  6. Copyright (c) 2003 Ghent University (UGent)
  7. Copyright (c) 2001 Universite catholique de Louvain (UCL)
  8. Copyright (c) Olivier Brouckaert
  9. For a full list of contributors, see "credits.txt".
  10. The full license can be read in "license.txt".
  11. This program is free software; you can redistribute it and/or
  12. modify it under the terms of the GNU General Public License
  13. as published by the Free Software Foundation; either version 2
  14. of the License, or (at your option) any later version.
  15. See the GNU General Public License for more details.
  16. Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
  17. ==============================================================================
  18. */
  19. /**
  20. ==============================================================================
  21. * Shows the list of connected users
  22. *
  23. * @author Olivier Brouckaert
  24. * @package dokeos.online
  25. ==============================================================================
  26. */
  27. define('FRAME','online');
  28. $langFile='chat';
  29. include('../inc/global.inc.php');
  30. $this_section=SECTION_COURSES;
  31. $showPic=intval($_GET['showPic']);
  32. $tbl_user=Database::get_main_table(MAIN_USER_TABLE);
  33. $tbl_course_user = Database::get_main_table(MAIN_COURSE_USER_TABLE);
  34. $tbl_online_connected=Database::get_course_table(ONLINE_CONNECTED_TABLE);
  35. $query="SELECT username FROM $tbl_user WHERE user_id='$_uid'";
  36. $result=api_sql_query($query,__FILE__,__LINE__);
  37. list($pseudoUser)=mysql_fetch_row($result);
  38. $isAllowed=(empty($pseudoUser) || !$_cid)?false:true;
  39. $isMaster=$is_courseAdmin?true:false;
  40. if(!$isAllowed)
  41. {
  42. exit();
  43. }
  44. $pictureURL=api_get_path(WEB_CODE_PATH).'upload/users/';
  45. $query="SELECT t1.user_id,t1.username,t1.firstname,t1.lastname,t1.picture_uri,t3.status FROM $tbl_user t1,$tbl_online_connected t2,$tbl_course_user t3 WHERE t1.user_id=t2.user_id AND t3.user_id=t1.user_id AND t3.course_code = '".$_course[sysCode]."' AND t2.last_connection>'".date('Y-m-d H:i:s',time()-60*5)."' ORDER BY t1.username";
  46. $result=api_sql_query($query,__FILE__,__LINE__);
  47. $Users=api_store_result($result);
  48. include('header_frame.inc.php');
  49. ?>
  50. <table border="0" cellpadding="0" cellspacing="0" width="100%">
  51. <?php
  52. foreach($Users as $enreg)
  53. {
  54. ?>
  55. <tr>
  56. <td width="1%" rowspan="2" valign="middle"><img src="../img/whoisonline.png" border="0" alt="" style="margin-right: 3px;"></td>
  57. <td width="99%"><a <?php if($enreg['status'] == 1) echo 'class="master"'; ?> name="user_<?php echo $enreg['user_id']; ?>" href="<?php echo $_SERVER['PHP_SELF']; ?>?showPic=<?php if($showPic == $enreg['user_id']) echo '0'; else echo $enreg['user_id']; ?>#user_<?php echo $enreg['user_id']; ?>"><b><?php echo $enreg['username']; ?></b></a></td>
  58. </tr>
  59. <tr>
  60. <td width="99%"><small><?php echo ucfirst($enreg['lastname']).' '.ucfirst($enreg['firstname']); ?></small></td>
  61. </tr>
  62. <?php if($showPic == $enreg['user_id']): ?>
  63. <tr>
  64. <td colspan="2" align="center"><img src="<?php if(empty($enreg['picture_uri'])) echo '../img/unknown.jpg'; else echo $pictureURL.$enreg['picture_uri']; ?>" border="0" width="100" alt="" style="margin-top: 5px;"></td>
  65. </tr>
  66. <?php endif; ?>
  67. <tr>
  68. <td height="5"></td>
  69. </tr>
  70. <?php
  71. }
  72. unset($Users);
  73. ?>
  74. </table>
  75. <?php
  76. include('footer_frame.inc.php');
  77. ?>