chat_message.php 4.3 KB

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