whoisonline.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. $_SESSION['who_is_online_counter'] = 2;
  15. //$htmlHeadXtra[] = api_get_js('jquery.endless-scroll.js');
  16. //social tab
  17. $this_section = SECTION_SOCIAL;
  18. // table definitions
  19. $track_user_table = Database::get_main_table(TABLE_MAIN_USER);
  20. $htmlHeadXtra[] = '<script>
  21. </script>';
  22. $social_right_content = null;
  23. $whoisonline_list = null;
  24. /* if (isset($_GET['chatid'])) {
  25. //send out call request
  26. $time = time();
  27. $time = date("Y-m-d H:i:s", $time);
  28. $chatid = intval($_GET['chatid']);
  29. if ($_GET['chatid'] == strval(intval($_GET['chatid']))) {
  30. $sql = "update $track_user_table set chatcall_user_id = ".intval($_user['user_id']).", chatcall_date = '".Database::escape_string($time)."', chatcall_text = '' where (user_id = ".(int)Database::escape_string($chatid).")";
  31. $result = Database::query($sql);
  32. //redirect caller to chat
  33. header("Location: ".api_get_path(WEB_CODE_PATH)."chat/chat.php?".api_get_cidreq()."&origin=whoisonline&target=".Security::remove_XSS($chatid));
  34. exit;
  35. }
  36. }
  37. */
  38. // This if statement prevents users accessing the who's online feature when it has been disabled.
  39. if ((api_get_setting('showonline', 'world') == 'true' && !$_user['user_id']) ||
  40. ((api_get_setting('showonline', 'users') == 'true' || api_get_setting('showonline', 'course') == 'true') && $_user['user_id'])
  41. ) {
  42. if (isset($_GET['cidReq']) && strlen($_GET['cidReq']) > 0) {
  43. $user_list = who_is_online_in_this_course(0, 9, api_get_user_id(), api_get_setting('time_limit_whosonline'), $_GET['cidReq']);
  44. } else {
  45. $user_list = who_is_online(0, 9);
  46. }
  47. /* if (!isset($_GET['id'])) {
  48. if (api_get_setting('allow_social_tool') == 'true') {
  49. if (!api_is_anonymous()) {
  50. //this include the social menu div
  51. $social_left_content = SocialManager::show_social_menu('whoisonline');
  52. }
  53. }
  54. }
  55. */
  56. if ($user_list) {
  57. if (!isset($_GET['id'])) {
  58. if (api_get_setting('allow_social_tool') == 'true') {
  59. if (!api_is_anonymous()) {
  60. $query = isset($_GET['q']) ? $_GET['q']: null;
  61. $social_search .= UserManager::get_search_form($query);
  62. }
  63. }
  64. //$social_right_content .= SocialManager::display_user_list($user_list);
  65. }
  66. }
  67. $whoisonline_list .= SocialManager::display_user_list($user_list);
  68. if (isset($_GET['id'])) {
  69. if (api_get_setting('allow_social_tool') == 'true' && api_user_is_login()) {
  70. header("Location: ".api_get_path(WEB_CODE_PATH)."social/profile.php?u=".intval($_GET['id']));
  71. exit;
  72. } else {
  73. $social_right_content .= SocialManager::display_individual_user($_GET['id']);
  74. }
  75. }
  76. } else {
  77. api_not_allowed();
  78. exit;
  79. }
  80. $tpl = new Template(get_lang('UsersOnLineList'));
  81. if (api_get_setting('allow_social_tool') == 'true' && !api_is_anonymous()) {
  82. $tpl->assign('whoisonline', $whoisonline_list);
  83. $tpl->assign('social_search', $social_search);
  84. $social_layout = $tpl->get_template('social/whoisonline.tpl');
  85. $tpl->display($social_layout);
  86. } else {
  87. $content = $social_right_content;
  88. $tpl->assign('actions', $actions);
  89. $tpl->assign('message', $show_message);
  90. $tpl->assign('header', get_lang('UsersOnLineList'));
  91. $tpl->assign('content', $content);
  92. $tpl->display_one_col_template();
  93. }