Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 39 and 401] [Versions 400 and 401]

   1  <?php
   2  // This file is part of Moodle - http://moodle.org/
   3  //
   4  // Moodle is free software: you can redistribute it and/or modify
   5  // it under the terms of the GNU General Public License as published by
   6  // the Free Software Foundation, either version 3 of the License, or
   7  // (at your option) any later version.
   8  //
   9  // Moodle is distributed in the hope that it will be useful,
  10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12  // GNU General Public License for more details.
  13  //
  14  // You should have received a copy of the GNU General Public License
  15  // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
  16  
  17  define('NO_MOODLE_COOKIES', true); // Session not used here.
  18  
  19  require_once('../../../config.php');
  20  require_once($CFG->dirroot.'/mod/chat/lib.php');
  21  
  22  $chatsid = required_param('chat_sid', PARAM_ALPHANUM);
  23  $chatid   = required_param('chat_id', PARAM_INT);
  24  
  25  if (!$chatuser = $DB->get_record('chat_users', array('sid' => $chatsid))) {
  26      throw new \moodle_exception('notlogged', 'chat');
  27  }
  28  if (!$chat = $DB->get_record('chat', array('id' => $chatid))) {
  29      throw new \moodle_exception('invalidid', 'chat');
  30  }
  31  
  32  if (!$course = $DB->get_record('course', array('id' => $chat->course))) {
  33      throw new \moodle_exception('invalidcourseid');
  34  }
  35  
  36  if (!$cm = get_coursemodule_from_instance('chat', $chat->id, $course->id)) {
  37      throw new \moodle_exception('invalidcoursemodule');
  38  }
  39  
  40  $PAGE->set_url('/mod/chat/gui_header_js/chatinput.php', array('chat_sid' => $chatsid, 'chat_id' => $chatid));
  41  $PAGE->set_popup_notification_allowed(false);
  42  
  43  // Get the user theme.
  44  $USER = $DB->get_record('user', array('id' => $chatuser->userid));
  45  
  46  $module = array(
  47      'name'      => 'mod_chat_header',
  48      'fullpath'  => '/mod/chat/gui_header_js/module.js',
  49      'requires'  => array('node')
  50  );
  51  $PAGE->requires->js_init_call('M.mod_chat_header.init_input', array(false), false, $module);
  52  
  53  // Setup course, lang and theme.
  54  $PAGE->set_course($course);
  55  $PAGE->set_pagelayout('embedded');
  56  $PAGE->set_focuscontrol('input_chat_message');
  57  $PAGE->set_cacheable(false);
  58  echo $OUTPUT->header();
  59  
  60  echo html_writer::start_tag('form', array('action' => '../empty.php',
  61                                            'method' => 'post',
  62                                            'target' => 'empty',
  63                                            'id' => 'inputForm',
  64                                            'style' => 'margin:0'));
  65  echo html_writer::label(get_string('entermessage', 'chat'), 'input_chat_message', false, array('class' => 'accesshide'));
  66  echo html_writer::empty_tag('input', array('type' => 'text',
  67                                             'id' => 'input_chat_message',
  68                                             'name' => 'chat_message',
  69                                             'size' => '50',
  70                                             'value' => ''));
  71  echo html_writer::empty_tag('input', array('type' => 'checkbox', 'id' => 'auto', 'checked' => 'checked', 'value' => ''));
  72  echo html_writer::tag('label', get_string('autoscroll', 'chat'), array('for' => 'auto'));
  73  echo html_writer::end_tag('form');
  74  
  75  echo html_writer::start_tag('form', array('action' => 'insert.php', 'method' => 'post', 'target' => 'empty', 'id' => 'sendForm'));
  76  echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'chat_sid', 'value' => $chatsid));
  77  echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'chat_message', 'id' => 'insert_chat_message'));
  78  echo html_writer::end_tag('form');
  79  
  80  echo $OUTPUT->footer();