Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/mod/chat/gui_header_js/insert.php
Go to the documentation of this file.
00001 <?php
00002 
00003 include('../../../config.php');
00004 include('../lib.php');
00005 
00006 $chat_sid     = required_param('chat_sid', PARAM_ALPHANUM);
00007 $chat_message = required_param('chat_message', PARAM_RAW);
00008 
00009 $PAGE->set_url('/mod/chat/gui_header_js/insert.php', array('chat_sid'=>$chat_sid,'chat_message'=>$chat_message));
00010 
00011 if (!$chatuser = $DB->get_record('chat_users', array('sid'=>$chat_sid))) {
00012     print_error('notlogged', 'chat');
00013 }
00014 
00015 if (!$chat = $DB->get_record('chat', array('id'=>$chatuser->chatid))) {
00016     print_error('nochat', 'chat');
00017 }
00018 
00019 if (!$course = $DB->get_record('course', array('id'=>$chat->course))) {
00020     print_error('invalidcourseid');
00021 }
00022 
00023 if (!$cm = get_coursemodule_from_instance('chat', $chat->id, $course->id)) {
00024     print_error('invalidcoursemodule');
00025 }
00026 
00027 require_login($course, false, $cm);
00028 
00029 if (isguestuser()) {
00030     print_error('noguests');
00031 }
00032 
00033 session_get_instance()->write_close();
00034 
00036 
00037 chat_delete_old_users();
00038 
00040 
00041 $chat_message = clean_text($chat_message, FORMAT_MOODLE);  // Strip bad tags
00042 
00044 
00045 if (!empty($chat_message)) {
00046 
00047     $message = new stdClass();
00048     $message->chatid = $chatuser->chatid;
00049     $message->userid = $chatuser->userid;
00050     $message->groupid = $chatuser->groupid;
00051     $message->message = $chat_message;
00052     $message->timestamp = time();
00053 
00054     $DB->insert_record('chat_messages', $message);
00055     $DB->insert_record('chat_messages_current', $message);
00056 
00057     $chatuser->lastmessageping = time() - 2;
00058     $DB->update_record('chat_users', $chatuser);
00059 
00060     if ($cm = get_coursemodule_from_instance('chat', $chat->id, $course->id)) {
00061         add_to_log($course->id, 'chat', 'talk', "view.php?id=$cm->id", $chat->id, $cm->id);
00062     }
00063 }
00064 
00065 if ($chatuser->version == 'header_js') {
00066 
00067     $forcerefreshasap = ($CFG->chat_normal_updatemode != 'jsupdated'); // See bug MDL-6791
00068 
00069     $module = array(
00070         'name'      => 'mod_chat_header',
00071         'fullpath'  => '/mod/chat/gui_header_js/module.js'
00072     );
00073     $PAGE->requires->js_init_call('M.mod_chat_header.init_insert_nojsupdated', array($forcerefreshasap), true, $module);
00074 }
00075 
00076 redirect('../empty.php');
 All Data Structures Namespaces Files Functions Variables Enumerations