online_whoisonline.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <?php // $Id: online_whoisonline.php 20467 2009-05-11 08:38:29Z ivantcholakov $
  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. // name of the language file that needs to be included
  29. $language_file='chat';
  30. include('../inc/global.inc.php');
  31. $this_section=SECTION_COURSES;
  32. $showPic=intval($_GET['showPic']);
  33. $tbl_user = Database::get_main_table(TABLE_MAIN_USER);
  34. $tbl_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
  35. $tbl_online_connected = Database::get_course_table(TABLE_ONLINE_CONNECTED);
  36. $query="SELECT username FROM $tbl_user WHERE user_id='".$_user['user_id']."'";
  37. $result=Database::query($query,__FILE__,__LINE__);
  38. list($pseudoUser)=Database::fetch_row($result);
  39. $isAllowed=(empty($pseudoUser) || !$_cid)?false:true;
  40. $isMaster=$is_courseAdmin?true:false;
  41. if(!$isAllowed)
  42. {
  43. exit();
  44. }
  45. $pictureURL=api_get_path(WEB_CODE_PATH).'upload/users/';
  46. $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";
  47. $result=Database::query($query,__FILE__,__LINE__);
  48. $Users=Database::store_result($result);
  49. include('header_frame.inc.php');
  50. ?>
  51. <table border="0" cellpadding="0" cellspacing="0" width="100%">
  52. <?php
  53. foreach($Users as $enreg)
  54. {
  55. ?>
  56. <tr>
  57. <td width="1%" rowspan="2" valign="middle"><img src="../img/whoisonline.png" border="0" alt="" style="margin-right: 3px;"></td>
  58. <td width="99%"><a <?php if($enreg['status'] == 1) echo 'class="master"'; ?> name="user_<?php echo $enreg['user_id']; ?>" href="<?php echo api_get_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>
  59. </tr>
  60. <tr>
  61. <td width="99%"><small><?php echo api_get_person_name($enreg['firstname'], $enreg['lastname']); ?></small></td>
  62. </tr>
  63. <?php if($showPic == $enreg['user_id']): ?>
  64. <tr>
  65. <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>
  66. </tr>
  67. <?php endif; ?>
  68. <tr>
  69. <td height="5"></td>
  70. </tr>
  71. <?php
  72. }
  73. unset($Users);
  74. ?>
  75. </table>
  76. <?php
  77. include('footer_frame.inc.php');
  78. ?>