whoisonline.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. require_once './main/inc/global.inc.php';
  10. if (isset($_GET['cidReq']) && strlen($_GET['cidReq']) > 0) {
  11. api_protect_course_script(true);
  12. }
  13. $this_section = SECTION_SOCIAL;
  14. $social_right_content = '';
  15. $whoisonline_list = '';
  16. $social_search = '';
  17. $userId = api_get_user_id();
  18. $access = accessToWhoIsOnline();
  19. if (!$access) {
  20. api_not_allowed(true);
  21. }
  22. if (isset($_GET['cidReq']) && strlen($_GET['cidReq']) > 0) {
  23. $user_list = who_is_online_in_this_course(
  24. 0,
  25. MAX_ONLINE_USERS,
  26. api_get_user_id(),
  27. api_get_setting('time_limit_whosonline'),
  28. $_GET['cidReq']
  29. );
  30. } else {
  31. $user_list = who_is_online(0, MAX_ONLINE_USERS);
  32. }
  33. if ($user_list) {
  34. if (!isset($_GET['id'])) {
  35. if (api_get_setting('allow_social_tool') == 'true') {
  36. if (!api_is_anonymous()) {
  37. $query = isset($_GET['q']) ? $_GET['q'] : null;
  38. $social_search = UserManager::getSearchForm($query);
  39. }
  40. }
  41. $social_right_content .= SocialManager::display_user_list($user_list);
  42. }
  43. }
  44. $whoisonline_list .= SocialManager::display_user_list($user_list);
  45. if (isset($_GET['id'])) {
  46. if (api_get_setting('allow_social_tool') == 'true' && api_user_is_login()) {
  47. header("Location: ".api_get_path(WEB_CODE_PATH)."social/profile.php?u=".intval($_GET['id']));
  48. exit;
  49. }
  50. }
  51. $tpl = new Template(get_lang('Online users list'));
  52. if (api_get_setting('allow_social_tool') === 'true' && !api_is_anonymous()) {
  53. $tpl->assign('whoisonline', $whoisonline_list);
  54. $tpl->assign('social_search', $social_search);
  55. } else {
  56. $tpl->assign('whoisonline', $social_right_content);
  57. }
  58. $social_layout = $tpl->get_template('social/whoisonline.tpl');
  59. $tpl->display($social_layout);