whoisonline.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Who is online list
  5. */
  6. // language files that should be included
  7. $language_file = array('index', 'registration', 'messages', 'userInfo');
  8. if (!isset($_GET['cidReq'])) {
  9. $cidReset = true;
  10. }
  11. // including necessary files
  12. require_once './main/inc/global.inc.php';
  13. require_once api_get_path(LIBRARY_PATH).'fileManage.lib.php';
  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. function show_image(image,width,height) {
  22. width = parseInt(width) + 20;
  23. height = parseInt(height) + 20;
  24. window_x = window.open(image,\'windowX\',\'width=\'+ width + \', height=\'+ height + \'\');
  25. }
  26. $(document).ready(function (){
  27. $("input#id_btn_send_invitation").bind("click", function(){
  28. if (confirm("'.get_lang('SendMessageInvitation', '').'")) {
  29. $("#form_register_friend").submit();
  30. }
  31. });
  32. });
  33. function display_hide () {
  34. setTimeout("hide_display_message()",3000);
  35. }
  36. function hide_display_message () {
  37. $("div#display_response_id").html("");
  38. try {
  39. $("#txt_subject_id").val("");
  40. $("#txt_area_invite").val("");
  41. }catch(e) {
  42. $("#txt_area_invite").val("");
  43. }
  44. }
  45. function show_icon_edit(element_html) {
  46. ident="#edit_image";
  47. $(ident).show();
  48. }
  49. function hide_icon_edit(element_html) {
  50. ident="#edit_image";
  51. $(ident).hide();
  52. }
  53. $(document).ready(function() {
  54. $("#link_load_more_items").live("click", function() {
  55. page = $("#link_load_more_items").attr("data_link");
  56. $.ajax({
  57. beforeSend: function(objeto) {
  58. $("#display_response_id").html("'.addslashes(get_lang('Loading')).'");
  59. },
  60. type: "GET",
  61. url: "main/inc/ajax/online.ajax.php?a=load_online_user",
  62. data: "online_page_nr="+page,
  63. success: function(data) {
  64. $("#display_response_id").html("");
  65. if (data != "end") {
  66. $("#link_load_more_items").remove();
  67. var last = $("#online_grid_container li:last");
  68. last.after(data);
  69. } else {
  70. $("#link_load_more_items").remove();
  71. }
  72. }
  73. });
  74. });
  75. });
  76. </script>';
  77. if ($_GET['chatid'] != '') {
  78. //send out call request
  79. $time = time();
  80. $time = date("Y-m-d H:i:s", $time);
  81. $chatid = intval($_GET['chatid']);
  82. if ($_GET['chatid'] == strval(intval($_GET['chatid']))) {
  83. $sql = "update $track_user_table set chatcall_user_id = '".Database::escape_string($_user['user_id'])."', chatcall_date = '".Database::escape_string($time)."', chatcall_text = '' where (user_id = ".(int)Database::escape_string($chatid).")";
  84. $result = Database::query($sql);
  85. //redirect caller to chat
  86. header("Location: ".api_get_path(WEB_CODE_PATH)."chat/chat.php?".api_get_cidreq()."&origin=whoisonline&target=".Security::remove_XSS($chatid));
  87. exit;
  88. }
  89. }
  90. // This if statement prevents users accessing the who's online feature when it has been disabled.
  91. if ((api_get_setting('showonline', 'world') == 'true' && !$_user['user_id']) || ((api_get_setting('showonline', 'users') == 'true' || api_get_setting('showonline', 'course') == 'true') && $_user['user_id'])) {
  92. if(isset($_GET['cidReq']) && strlen($_GET['cidReq']) > 0) {
  93. $user_list = who_is_online_in_this_course(0, 9, api_get_user_id(), api_get_setting('time_limit_whosonline'), $_GET['cidReq']);
  94. } else {
  95. $user_list = who_is_online(0, 9);
  96. }
  97. if (!isset($_GET['id'])) {
  98. if (api_get_setting('allow_social_tool') == 'true') {
  99. if (!api_is_anonymous()) {
  100. //this include the social menu div
  101. $social_left_content = SocialManager::show_social_menu('whoisonline');
  102. }
  103. }
  104. }
  105. if ($user_list) {
  106. if (!isset($_GET['id'])) {
  107. if (api_get_setting('allow_social_tool') == 'true') {
  108. if (!api_is_anonymous()) {
  109. $query = isset($_GET['q']) ? $_GET['q']: null;
  110. $social_right_content .= '<div class="span9">'.UserManager::get_search_form($query).'</div>';
  111. }
  112. }
  113. $social_right_content .= SocialManager::display_user_list($user_list);
  114. }
  115. }
  116. if (isset($_GET['id'])) {
  117. if (api_get_setting('allow_social_tool') == 'true') {
  118. header("Location: ".api_get_path(WEB_CODE_PATH)."social/profile.php?u=".intval($_GET['id']));
  119. exit;
  120. } else {
  121. SocialManager::display_individual_user($_GET['id']);
  122. }
  123. }
  124. } else {
  125. api_not_allowed();
  126. exit;
  127. }
  128. $tpl = new Template(get_lang('UsersOnLineList'));
  129. if (api_get_setting('allow_social_tool') == 'true' && !api_is_anonymous()) {
  130. $tpl->assign('social_left_content', $social_left_content);
  131. //$tpl->assign('social_left_menu', $social_left_menu);
  132. $tpl->assign('social_right_content', $social_right_content);
  133. $social_layout = $tpl->get_template('layout/social_layout.tpl');
  134. $content = $tpl->fetch($social_layout);
  135. } else {
  136. $content = $social_right_content;
  137. }
  138. $tpl->assign('actions', $actions);
  139. $tpl->assign('message', $show_message);
  140. $tpl->assign('header', get_lang('UsersOnLineList'));
  141. $tpl->assign('content', $content);
  142. $tpl->display_one_col_template();