chat.php 3.7 KB

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