chat_message.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. use ChamiloSession as Session;
  4. use Chamilo\CoreBundle\Framework\Container;
  5. /**
  6. * Allows to type the messages that will be displayed on chat_chat.php
  7. *
  8. * @author Olivier Brouckaert
  9. * Modified by Alex Aragón (BeezNest)
  10. * @package chamilo.chat
  11. */
  12. define('FRAME', 'message');
  13. //require_once '../inc/global.inc.php';
  14. require_once api_get_path(SYS_CODE_PATH).'chat/chat_functions.lib.php';
  15. $userId = api_get_user_id();
  16. $userInfo = api_get_user_info();
  17. $course = api_get_course_id();
  18. $session_id = api_get_session_id();
  19. $group_id = api_get_group_id();
  20. $_course = api_get_course_info();
  21. // Juan Carlos Raña inserted smileys and self-closing window.
  22. ?>
  23. <script>
  24. function close_chat_window() {
  25. var chat_window = top.window.self;
  26. chat_window.opener = top.window.self;
  27. chat_window.top.close();
  28. }
  29. </script>
  30. <?php
  31. // Mode open in a new window: close the window when there isn't an user login
  32. if (empty($userId)) {
  33. echo '<script languaje="javascript" type="text/javascript"> close_chat_window(); </script>';
  34. } else {
  35. api_protect_course_script();
  36. }
  37. if (empty($course) || empty($userId)) {
  38. exit;
  39. }
  40. /* Constants and variables */
  41. $tbl_user = Database::get_main_table(TABLE_MAIN_USER);
  42. $sent = isset($_REQUEST['sent']) ? $_REQUEST['sent'] : null;
  43. require 'header_frame.inc.php';
  44. $chat_size = 0;
  45. if ($sent) {
  46. saveMessage(
  47. $_POST['message'],
  48. $userId,
  49. $_course,
  50. $session_id,
  51. $group_id,
  52. false
  53. );
  54. }
  55. ?>
  56. <form
  57. id="formMessage"
  58. name="formMessage"
  59. method="post"
  60. action="<?php echo api_get_self().'?'.api_get_cidreq(); ?>" onsubmit="javascript: if(document.formMessage.message.value == '') { alert('<?php echo addslashes(api_htmlentities(get_lang('TypeMessage'), ENT_QUOTES)); ?>'); document.formMessage.message.focus(); return false; }"
  61. autocomplete="off"
  62. >
  63. <input type="hidden" name="sent" value="1">
  64. <div class="message-form-chat">
  65. <div class="tabbable">
  66. <ul class="nav nav-tabs">
  67. <li class="active">
  68. <a href="#tab1" data-toggle="tab">
  69. <?php echo get_lang('Write'); ?>
  70. </a>
  71. </li>
  72. <li>
  73. <a href="#tab2" id="preview" data-toggle="tab">
  74. <?php echo get_lang('Preview'); ?>
  75. </a>
  76. </li>
  77. <li>
  78. <a href="#tab3" id="emojis" data-toggle="tab">
  79. <?php echo Emojione\Emojione::toImage(':smile:'); ?>
  80. </a>
  81. </li>
  82. </ul>
  83. <div class="tab-content">
  84. <div class="tab-pane active" id="tab1">
  85. <table border="0" cellpadding="5" cellspacing="0" width="100%">
  86. <tr>
  87. <td width="320" valign="middle">
  88. <?php
  89. $talkboxsize = (api_get_course_setting('allow_open_chat_window')) ? 'width: 350px; height: 80px' : 'width: 450px; height: 35px';
  90. ?>
  91. <textarea id="message" class="message-text" name="message" style=" <?php echo $talkboxsize; ?>"></textarea>
  92. </td>
  93. </tr>
  94. <tr>
  95. <td>
  96. <div class="btn-group">
  97. <button id="send" type="submit" value="<?php echo get_lang('Send'); ?>" class="btn btn-primary">
  98. <?php echo get_lang('Send'); ?>
  99. </button>
  100. </div>
  101. </td>
  102. </tr>
  103. </table>
  104. </div>
  105. <div class="tab-pane" id="tab2">
  106. <table border="0" cellpadding="5" cellspacing="0" width="100%">
  107. <tr>
  108. <td width="320" valign="middle">
  109. <div id="html-preview" class="emoji-wysiwyg-editor-preview">
  110. </div>
  111. </td>
  112. </tr>
  113. </table>
  114. </div>
  115. </div>
  116. </div>
  117. </div>
  118. </form>
  119. <?php
  120. require 'footer_frame.inc.php';
  121. // Hide headers
  122. Container::$legacyTemplate = 'layout_one_col_no_content.html.twig';