whoisonline.php 5.8 KB

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