whoisonline.php 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Who is online list
  5. */
  6. if (!isset($_GET['cidReq'])) {
  7. $cidReset = true;
  8. }
  9. // including necessary files
  10. require_once './main/inc/global.inc.php';
  11. if (isset($_GET['cidReq']) && strlen($_GET['cidReq']) > 0) {
  12. api_protect_course_script(true);
  13. }
  14. $_SESSION['who_is_online_counter'] = 2;
  15. $this_section = SECTION_SOCIAL;
  16. // table definitions
  17. $social_right_content = null;
  18. $whoisonline_list = null;
  19. $social_search = '';
  20. // This if statement prevents users accessing the who's online feature when it has been disabled.
  21. if ((api_get_setting('showonline', 'world') == 'true' && !$_user['user_id']) ||
  22. ((api_get_setting('showonline', 'users') == 'true' || api_get_setting('showonline', 'course') == 'true') && $_user['user_id'])
  23. ) {
  24. if (isset($_GET['cidReq']) && strlen($_GET['cidReq']) > 0) {
  25. $user_list = who_is_online_in_this_course(0, 9, api_get_user_id(), api_get_setting('time_limit_whosonline'), $_GET['cidReq']);
  26. } else {
  27. $user_list = who_is_online(0, 9);
  28. }
  29. /* if (!isset($_GET['id'])) {
  30. if (api_get_setting('allow_social_tool') == 'true') {
  31. if (!api_is_anonymous()) {
  32. //this include the social menu div
  33. $social_left_content = SocialManager::show_social_menu('whoisonline');
  34. }
  35. }
  36. }
  37. */
  38. if ($user_list) {
  39. if (!isset($_GET['id'])) {
  40. if (api_get_setting('allow_social_tool') == 'true') {
  41. if (!api_is_anonymous()) {
  42. $query = isset($_GET['q']) ? $_GET['q']: null;
  43. $social_search = UserManager::get_search_form($query);
  44. }
  45. }
  46. $social_right_content .= SocialManager::display_user_list($user_list);
  47. }
  48. }
  49. $whoisonline_list .= SocialManager::display_user_list($user_list);
  50. if (isset($_GET['id'])) {
  51. if (api_get_setting('allow_social_tool') == 'true' && api_user_is_login()) {
  52. header("Location: ".api_get_path(WEB_CODE_PATH)."social/profile.php?u=".intval($_GET['id']));
  53. exit;
  54. } else {
  55. $social_right_content .= SocialManager::display_individual_user($_GET['id']);
  56. }
  57. }
  58. } else {
  59. api_not_allowed();
  60. exit;
  61. }
  62. $tpl = new Template(get_lang('UsersOnLineList'));
  63. if (api_get_setting('allow_social_tool') == 'true' && !api_is_anonymous()) {
  64. $tpl->assign('whoisonline', $whoisonline_list);
  65. $tpl->assign('social_search', $social_search);
  66. $social_layout = $tpl->get_template('social/whoisonline.tpl');
  67. $tpl->display($social_layout);
  68. } else {
  69. $content = $social_right_content;
  70. $tpl->assign('header', get_lang('UsersOnLineList'));
  71. $tpl->assign('content', $content);
  72. $tpl->display_one_col_template();
  73. }