whoisonline.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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::get_search_form($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. } else {
  50. $social_right_content .= SocialManager::display_individual_user($_GET['id']);
  51. }
  52. }
  53. $tpl = new Template(get_lang('UsersOnLineList'));
  54. if (api_get_setting('allow_social_tool') === 'true' && !api_is_anonymous()) {
  55. $tpl->assign('whoisonline', $whoisonline_list);
  56. $tpl->assign('social_search', $social_search);
  57. } else {
  58. $tpl->assign('whoisonline', $social_right_content);
  59. }
  60. $social_layout = $tpl->get_template('social/whoisonline.tpl');
  61. $tpl->display($social_layout);