See Release Notes
Long Term Support Release
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 require_once('../../../config.php'); 18 require_once ('../lib.php'); 19 20 $chatsid = required_param('chat_sid', PARAM_ALPHANUM); 21 $chatmessage = required_param('chat_message', PARAM_RAW); 22 23 $PAGE->set_url('/mod/chat/gui_header_js/insert.php', array('chat_sid' => $chatsid, 'chat_message' => $chatmessage)); 24 25 if (!$chatuser = $DB->get_record('chat_users', array('sid' => $chatsid))) { 26 throw new \moodle_exception('notlogged', 'chat'); 27 } 28 29 if (!$chat = $DB->get_record('chat', array('id' => $chatuser->chatid))) { 30 throw new \moodle_exception('nochat', 'chat'); 31 } 32 33 if (!$course = $DB->get_record('course', array('id' => $chat->course))) { 34 throw new \moodle_exception('invalidcourseid'); 35 } 36 37 if (!$cm = get_coursemodule_from_instance('chat', $chat->id, $course->id)) { 38 throw new \moodle_exception('invalidcoursemodule'); 39 } 40 41 require_login($course, false, $cm); 42 43 if (isguestuser()) { 44 throw new \moodle_exception('noguests'); 45 } 46 47 \core\session\manager::write_close(); 48 49 // Delete old users now. 50 51 chat_delete_old_users(); 52 53 // Clean up the message. 54 55 $chatmessage = clean_text($chatmessage, FORMAT_MOODLE); // Strip bad tags. 56 57 // Add the message to the database. 58 59 if (!empty($chatmessage)) { 60 61 chat_send_chatmessage($chatuser, $chatmessage, 0, $cm); 62 63 $chatuser->lastmessageping = time() - 2; 64 $DB->update_record('chat_users', $chatuser); 65 } 66 67 if ($chatuser->version == 'header_js') { 68 69 $forcerefreshasap = ($CFG->chat_normal_updatemode != 'jsupdated'); // See bug MDL-6791. 70 71 $module = array( 72 'name' => 'mod_chat_header', 73 'fullpath' => '/mod/chat/gui_header_js/module.js' 74 ); 75 $PAGE->requires->js_init_call('M.mod_chat_header.init_insert_nojsupdated', array($forcerefreshasap), true, $module); 76 } 77 78 redirect('../empty.php');
title
Description
Body
title
Description
Body
title
Description
Body
title
Body