whoisonline.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Who is online list
  5. */
  6. if (!isset($_GET['cidReq'])) {
  7. $cidReset = true;
  8. }
  9. // including necessary files
  10. require_once './main/inc/global.inc.php';
  11. if (isset($_GET['cidReq']) && strlen($_GET['cidReq']) > 0) {
  12. api_protect_course_script(true);
  13. }
  14. $this_section = SECTION_SOCIAL;
  15. $social_right_content = '';
  16. $whoisonline_list = '';
  17. $social_search = '';
  18. $userId = api_get_user_id();
  19. // This if statement prevents users accessing the who's online feature when it has been disabled.
  20. if ((api_get_setting('showonline', 'world') == 'true' && !$userId) ||
  21. ((api_get_setting('showonline', 'users') == 'true' ||
  22. api_get_setting('showonline', 'course') == 'true') && $userId)
  23. ) {
  24. if (isset($_GET['cidReq']) && strlen($_GET['cidReq']) > 0) {
  25. $user_list = who_is_online_in_this_course(
  26. 0,
  27. MAX_ONLINE_USERS,
  28. api_get_user_id(),
  29. api_get_setting('time_limit_whosonline'),
  30. $_GET['cidReq']
  31. );
  32. } else {
  33. $user_list = who_is_online(0, MAX_ONLINE_USERS);
  34. }
  35. if ($user_list) {
  36. if (!isset($_GET['id'])) {
  37. if (api_get_setting('allow_social_tool') == 'true') {
  38. if (!api_is_anonymous()) {
  39. $query = isset($_GET['q']) ? $_GET['q'] : null;
  40. $social_search = UserManager::get_search_form($query);
  41. }
  42. }
  43. $social_right_content .= SocialManager::display_user_list($user_list);
  44. }
  45. }
  46. $whoisonline_list .= SocialManager::display_user_list($user_list);
  47. if (isset($_GET['id'])) {
  48. if (api_get_setting('allow_social_tool') == 'true' && api_user_is_login()) {
  49. header("Location: ".api_get_path(WEB_CODE_PATH)."social/profile.php?u=".intval($_GET['id']));
  50. exit;
  51. } else {
  52. $social_right_content .= SocialManager::display_individual_user($_GET['id']);
  53. }
  54. }
  55. } else {
  56. api_not_allowed(true);
  57. }
  58. $tpl = new Template(get_lang('UsersOnLineList'));
  59. if (api_get_setting('allow_social_tool') === 'true' && !api_is_anonymous()) {
  60. $tpl->assign('whoisonline', $whoisonline_list);
  61. $tpl->assign('social_search', $social_search);
  62. } else {
  63. $tpl->assign('whoisonline', $social_right_content);
  64. }
  65. $social_layout = $tpl->get_template('social/whoisonline.tpl');
  66. $tpl->display($social_layout);