chat_message.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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. $language_file = array('chat');
  12. require_once '../inc/global.inc.php';
  13. require_once api_get_path(SYS_PATH).'vendor/autoload.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. require_once api_get_path(LIBRARY_PATH).'document.lib.php';
  41. require_once api_get_path(LIBRARY_PATH).'fileUpload.lib.php';
  42. /* Constants and variables */
  43. $tbl_user = Database::get_main_table(TABLE_MAIN_USER);
  44. $sent = isset($_REQUEST['sent']) ? $_REQUEST['sent'] : null;
  45. require 'header_frame.inc.php';
  46. $chat_size = 0;
  47. if ($sent) {
  48. saveMessage(
  49. $_POST['message'],
  50. $userId,
  51. $_course,
  52. $session_id,
  53. $group_id,
  54. false
  55. );
  56. }
  57. ?>
  58. <form
  59. id="formMessage"
  60. name="formMessage"
  61. method="post"
  62. 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; }"
  63. autocomplete="off"
  64. >
  65. <input type="hidden" name="sent" value="1">
  66. <div class="message-form-chat">
  67. <div class="tabbable">
  68. <ul class="nav nav-tabs">
  69. <li class="active">
  70. <a href="#tab1" data-toggle="tab">
  71. <?php echo get_lang('Write'); ?>
  72. </a>
  73. </li>
  74. <li>
  75. <a href="#tab2" id="preview" data-toggle="tab">
  76. <?php echo get_lang('Preview'); ?>
  77. </a>
  78. </li>
  79. <li>
  80. <a href="#tab3" id="emojis" data-toggle="tab">
  81. <?php echo Emojione\Emojione::toImage(':smile:'); ?>
  82. </a>
  83. </li>
  84. </ul>
  85. <div class="tab-content">
  86. <div class="tab-pane active" id="tab1">
  87. <table border="0" cellpadding="5" cellspacing="0" width="100%">
  88. <tr>
  89. <td width="320" valign="middle">
  90. <?php
  91. $talkboxsize = (api_get_course_setting('allow_open_chat_window')) ? 'width: 350px; height: 80px' : 'width: 450px; height: 35px';
  92. ?>
  93. <textarea id="message" class="message-text" name="message" style=" <?php echo $talkboxsize; ?>"></textarea>
  94. </td>
  95. </tr>
  96. <tr>
  97. <td>
  98. <div class="btn-group">
  99. <button id="send" type="submit" value="<?php echo get_lang('Send'); ?>" class="btn btn-primary">
  100. <?php echo get_lang('Send'); ?>
  101. </button>
  102. </div>
  103. </td>
  104. </tr>
  105. </table>
  106. </div>
  107. <div class="tab-pane" id="tab2">
  108. <table border="0" cellpadding="5" cellspacing="0" width="100%">
  109. <tr>
  110. <td width="320" valign="middle">
  111. <div id="html-preview" class="emoji-wysiwyg-editor-preview">
  112. </div>
  113. </td>
  114. </tr>
  115. </table>
  116. </div>
  117. </div>
  118. </div>
  119. </div>
  120. </form>
  121. <?php
  122. require 'footer_frame.inc.php';