whoisonline.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. // This if statement prevents users accessing the who's online feature when it has been disabled.
  19. if ((api_get_setting('showonline', 'world') == 'true' && !$_user['user_id']) ||
  20. ((api_get_setting('showonline', 'users') == 'true' || api_get_setting('showonline', 'course') == 'true') && $_user['user_id'])
  21. ) {
  22. if (isset($_GET['cidReq']) && strlen($_GET['cidReq']) > 0) {
  23. $user_list = who_is_online_in_this_course(
  24. 0,
  25. MAX_ONLINE_USERS,
  26. api_get_user_id(),
  27. api_get_setting('time_limit_whosonline'),
  28. $_GET['cidReq']
  29. );
  30. } else {
  31. $user_list = who_is_online(0, MAX_ONLINE_USERS);
  32. }
  33. if ($user_list) {
  34. if (!isset($_GET['id'])) {
  35. if (api_get_setting('allow_social_tool') == 'true') {
  36. if (!api_is_anonymous()) {
  37. $query = isset($_GET['q']) ? $_GET['q'] : null;
  38. $social_search = UserManager::get_search_form($query);
  39. }
  40. }
  41. $social_right_content .= SocialManager::display_user_list($user_list);
  42. }
  43. }
  44. $whoisonline_list .= SocialManager::display_user_list($user_list);
  45. if (isset($_GET['id'])) {
  46. if (api_get_setting('allow_social_tool') == 'true' && api_user_is_login()) {
  47. header("Location: ".api_get_path(WEB_CODE_PATH)."social/profile.php?u=".intval($_GET['id']));
  48. exit;
  49. } else {
  50. $social_right_content .= SocialManager::display_individual_user($_GET['id']);
  51. }
  52. }
  53. } else {
  54. api_not_allowed();
  55. exit;
  56. }
  57. $tpl = new Template(get_lang('UsersOnLineList'));
  58. if (api_get_setting('allow_social_tool') === 'true' && !api_is_anonymous()) {
  59. $tpl->assign('whoisonline', $whoisonline_list);
  60. $tpl->assign('social_search', $social_search);
  61. } else {
  62. $tpl->assign('whoisonline', $social_right_content);
  63. }
  64. $social_layout = $tpl->get_template('social/whoisonline.tpl');
  65. $tpl->display($social_layout);