whoisonline.php 6.6 KB

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