chat.php 3.8 KB

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