chat.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. $language_file = array('chat');
  4. require_once '../inc/global.inc.php';
  5. require_once api_get_path(LIBRARY_PATH).'groupmanager.lib.php';
  6. $this_section = SECTION_COURSES;
  7. $nameTools = get_lang('ToolChat');
  8. if ($_GET["origin"] != 'whoisonline') {
  9. api_protect_course_script(true);
  10. } else {
  11. $origin = $_SESSION['origin'];
  12. $target = $_SESSION['target'];
  13. $_SESSION['origin']=$_GET["origin"];
  14. $_SESSION['target']=$_GET["target"];
  15. }
  16. /* TRACKING */
  17. event_access_tool(TOOL_CHAT);
  18. header('Content-Type: text/html; charset='.api_get_system_encoding());
  19. /*
  20. * Choose CSS style (platform's, user's, or course's)
  21. */
  22. $my_style = api_get_visual_theme();
  23. $mycourseid = api_get_course_id();
  24. if (!empty($mycourseid) && $mycourseid != -1) {
  25. $open_chat_window = api_get_course_setting('allow_open_chat_window');
  26. }
  27. $cidreq = Security::remove_XSS($_GET['cidReq']);
  28. $toolgroup = Security::remove_XSS($_GET['toolgroup']); //fix when change by vertical or horizontal menu from a chat group to chat course.
  29. if (empty($toolgroup) && empty($open_chat_window)){
  30. unset($_SESSION['_gid']);
  31. }
  32. ?>
  33. <!DOCTYPE html
  34. PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  35. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  36. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo api_get_language_isocode(); ?>" lang="<?php echo api_get_language_isocode(); ?>">
  37. <head>
  38. <meta http-equiv="Content-Type" content="text/html; charset=<?php echo api_get_system_encoding(); ?>" />
  39. <?php
  40. echo'<title>'.get_lang('Chat').' - '.$mycourseid.' - '.api_get_setting('siteName').'</title>';
  41. // If it is a group chat then the breadcrumbs.
  42. if ($_SESSION['_gid'] OR $_GET['group_id']) {
  43. if (isset($_SESSION['_gid'])) {
  44. $_clean['group_id'] = (int)$_SESSION['_gid'];
  45. }
  46. if (isset($_GET['group_id'])) {
  47. $_clean['group_id'] = (int)Database::escape_string($_GET['group_id']);
  48. }
  49. $group_properties = GroupManager :: get_group_properties($_clean['group_id']);
  50. $interbreadcrumb[] = array('url' => '../group/group.php', 'name' => get_lang('Groups'));
  51. $interbreadcrumb[] = array('url' => '../group/group_space.php?gidReq='.$_SESSION['_gid'], 'name' => get_lang('GroupSpace').' '.$group_properties['name']);
  52. $noPHP_SELF = true;
  53. $shortBanner = false;
  54. $add_group_to_title = ' ('.$group_properties['name'].')';
  55. $groupfilter = 'group_id="'.$_clean['group_id'].'"';
  56. // Ensure this tool in groups whe it's private or deactivated
  57. /*if ($group_properties['chat_state'] == 0) {
  58. echo api_not_allowed();
  59. } elseif ($group_properties['chat_state'] == 2) {
  60. if (!api_is_allowed_to_edit(false,true) and !GroupManager :: is_user_in_group($_user['user_id'], $_SESSION['_gid'])) {
  61. echo api_not_allowed();
  62. }
  63. }*/
  64. } else {
  65. $groupfilter = 'group_id=0';
  66. }
  67. //$is_allowed_to_edit = api_is_allowed_to_edit(false, true);
  68. if (empty($open_chat_window)) {
  69. Display::display_header($tool_name, 'Chat');
  70. }
  71. echo '<iframe src="chat_whoisonline.php?cidReq='.$cidreq.'" name="chat_whoisonline" scrolling="auto" style="height:320px; width:19%; border: 0px none; float:left"></iframe>';
  72. echo '<iframe src="chat_chat.php?origin='.Security::remove_XSS($_GET['origin']).'&target='.Security::remove_XSS($_GET['target']).'&amp;cidReq='.$cidreq.'" name="chat_chat" scrolling="auto" height="240" style="width:80%; border: 0px none; float:right"></iframe>';
  73. echo '<iframe src="chat_message.php?cidReq='.$cidreq.'" name="chat_message" scrolling="no" height="80" style="width:80%; border: 0px none; float:right"></iframe>';
  74. echo '<iframe src="chat_hidden.php?cidReq='.$cidreq.'" name="chat_hidden" height="0" style="border: 0px none"></iframe>';
  75. if (empty($open_chat_window)) {
  76. Display::display_footer();
  77. }
  78. echo '</html>';