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