whoisonline.php 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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. require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
  15. require_once api_get_path(LIBRARY_PATH).'social.lib.php';
  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 type="text/javascript">
  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. </script>';
  27. $htmlHeadXtra[] = '<script type="text/javascript" src="./main/inc/lib/javascript/jquery.js"></script>';
  28. $htmlHeadXtra[] = '<script type="text/javascript" src="./main/inc/lib/javascript/thickbox.js"></script>';
  29. $htmlHeadXtra[] = '<link rel="stylesheet" href="./main/inc/lib/javascript/thickbox.css" type="text/css" media="projection, screen">';
  30. $htmlHeadXtra[] = '<script type="text/javascript">
  31. $(document).ready(function (){
  32. $("input#id_btn_send_invitation").bind("click", function(){
  33. if (confirm("'.get_lang('SendMessageInvitation', '').'")) {
  34. $("#form_register_friend").submit();
  35. }
  36. });
  37. });
  38. function change_panel (mypanel_id,myuser_id) {
  39. $.ajax({
  40. contentType: "application/x-www-form-urlencoded",
  41. beforeSend: function(objeto) {
  42. $("#id_content_panel").html("'.get_lang('Loading', '').'"); },
  43. type: "POST",
  44. url: "main/messages/send_message.php",
  45. data: "panel_id="+mypanel_id+"&user_id="+myuser_id,
  46. success: function(datos) {
  47. $("div#id_content_panel_init").html(datos);
  48. $("div#display_response_id").html("");
  49. }
  50. });
  51. }
  52. function action_database_panel(option_id,myuser_id) {
  53. if (option_id==5) {
  54. my_txt_subject=$("#txt_subject_id").val();
  55. } else {
  56. my_txt_subject="clear";
  57. }
  58. my_txt_content=$("#txt_area_invite").val();
  59. if (my_txt_content.length==0 || my_txt_subject.length==0) {
  60. $("#display_response_id").html("&nbsp;&nbsp;&nbsp;'.get_lang('MessageEmptyMessageOrSubject', '').'");
  61. setTimeout("message_information_display()",3000);
  62. return false;
  63. }
  64. $.ajax({
  65. contentType: "application/x-www-form-urlencoded",
  66. beforeSend: function(objeto) {
  67. $("#display_response_id").html("'.get_lang('Loading', '').'"); },
  68. type: "POST",
  69. url: "main/messages/send_message.php",
  70. data: "panel_id="+option_id+"&user_id="+myuser_id+"&txt_subject="+my_txt_subject+"&txt_content="+my_txt_content,
  71. success: function(datos) {
  72. $("#display_response_id").html(datos);
  73. }
  74. });
  75. }
  76. function display_hide () {
  77. setTimeout("hide_display_message()",3000);
  78. }
  79. function message_information_display() {
  80. $("#display_response_id").html("");
  81. }
  82. function hide_display_message () {
  83. $("div#display_response_id").html("");
  84. try {
  85. $("#txt_subject_id").val("");
  86. $("#txt_area_invite").val("");
  87. }catch(e) {
  88. $("#txt_area_invite").val("");
  89. }
  90. }
  91. </script>';
  92. if ($_GET['chatid'] != '') {
  93. //send out call request
  94. $time = time();
  95. $time = date("Y-m-d H:i:s", $time);
  96. $chatid = addslashes($_GET['chatid']);
  97. if ($_GET['chatid'] == strval(intval($_GET['chatid']))) {
  98. $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).")";
  99. $result = Database::query($sql);
  100. //redirect caller to chat
  101. header("Location: ".api_get_path(WEB_CODE_PATH)."chat/chat.php?".api_get_cidreq()."&origin=whoisonline&target=".Security::remove_XSS($chatid));
  102. exit;
  103. }
  104. }
  105. // This if statement prevents users accessing the who's online feature when it has been disabled.
  106. 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'])) {
  107. if(isset($_GET['cidReq']) && strlen($_GET['cidReq']) > 0) {
  108. $user_list = who_is_online_in_this_course($_user['user_id'], api_get_setting('time_limit_whosonline'), $_GET['cidReq']);
  109. } else {
  110. $user_list = who_is_online(api_get_setting('time_limit_whosonline'));
  111. }
  112. $total = count($user_list);
  113. if (!isset($_GET['id'])) {
  114. Display::display_header(get_lang('UsersOnLineList'));
  115. if (api_get_setting('allow_social_tool') == 'true') {
  116. if (!api_is_anonymous()) {
  117. echo '<div id="social-content-left">';
  118. //this include the social menu div
  119. SocialManager::show_social_menu('whoisonline');
  120. echo '</div>';
  121. }
  122. /*
  123. if ($_GET['id'] == '') {
  124. echo '<p><a class="refresh" href="javascript:window.location.reload()">'.get_lang('Refresh').'</a></p>';
  125. }*/
  126. } else {
  127. echo '<div class="actions-title">';
  128. echo get_lang('UsersOnLineList');
  129. echo '</div>';
  130. }
  131. }
  132. if ($user_list) {
  133. if (!isset($_GET['id'])) {
  134. if (api_get_setting('allow_social_tool') == 'true') {
  135. echo '<div id="social-content-right">';
  136. //this include the social menu div
  137. if (!api_is_anonymous()) {
  138. echo UserManager::get_search_form($_GET['q']);
  139. }
  140. }
  141. SocialManager::display_user_list($user_list);
  142. echo '</div>';
  143. } else {
  144. //individual user information - also displays header info
  145. SocialManager::display_individual_user(Security::remove_XSS($_GET['id']));
  146. }
  147. } elseif (isset($_GET['id'])) {
  148. Display::display_header(get_lang('UsersOnLineList'));
  149. echo '<div class="actions-title">';
  150. echo get_lang('UsersOnLineList');
  151. echo '</div>';
  152. }
  153. } else {
  154. Display::display_header(get_lang('UsersOnLineList'));
  155. Display::display_error_message(get_lang('AccessNotAllowed'));
  156. }
  157. $referer = empty($_GET['referer']) ? 'index.php' : api_htmlentities(strip_tags($_GET['referer']), ENT_QUOTES);
  158. /*
  159. FOOTER
  160. */
  161. Display::display_footer();