Пример #1
0
    chat_print_error('ERROR', get_string('invaliduserid', 'error'));
}
if (!($cm = get_coursemodule_from_instance('chat', $chat->id, $course->id))) {
    chat_print_error('ERROR', get_string('invalidcoursemodule', 'error'));
}
if (isguest()) {
    chat_print_error('ERROR', get_string('notlogged', 'chat'));
}
session_get_instance()->write_close();
chat_delete_old_users();
$chat_message = clean_text($chat_message, FORMAT_MOODLE);
if (!empty($beep_id)) {
    $chat_message = 'beep ' . $beep_id;
}
if (!empty($chat_message)) {
    $message = new object();
    $message->chatid = $chatuser->chatid;
    $message->userid = $chatuser->userid;
    $message->groupid = $chatuser->groupid;
    $message->message = $chat_message;
    $message->timestamp = time();
    $chatuser->lastmessageping = time() - 2;
    $DB->update_record('chat_users', $chatuser);
    if (!($DB->insert_record('chat_messages', $message) && $DB->insert_record('chat_messages_current', $message))) {
        chat_print_error('ERROR', get_string('cantlogin', 'chat'));
    } else {
        echo 200;
    }
    add_to_log($course->id, 'chat', 'talk', "view.php?id={$cm->id}", $chat->id, $cm->id);
    ob_end_flush();
}
Пример #2
0
    chat_print_error('ERROR', get_string('notlogged', 'chat'));
}
//Get the minimal course
if (!($course = $DB->get_record('course', array('id' => $chatuser->course), 'id,theme,lang'))) {
    chat_print_error('ERROR', get_string('invalidcourseid', 'error'));
}
//Get the user theme and enough info to be used in chat_format_message() which passes it along to
if (!($USER = $DB->get_record('user', array('id' => $chatuser->userid)))) {
    // no optimisation here, it would break again in future!
    chat_print_error('ERROR', get_string('invaliduserid', 'error'));
}
if (!($chat = $DB->get_record('chat', array('id' => $chatuser->chatid)))) {
    chat_print_error('ERROR', get_string('invalidcoursemodule', 'error'));
}
if (!($cm = get_coursemodule_from_instance('chat', $chatuser->chatid, $course->id))) {
    chat_print_error('ERROR', get_string('invalidcoursemodule', 'error'));
}
// setup $PAGE so that format_text will work properly
$PAGE->set_cm($cm, $course, $chat);
if ($CFG->chat_use_cache) {
    $cache = new file_cache();
    $users = $cache->get('user');
    if (empty($users)) {
        $users = chat_get_users($chatuser->chatid, $chatuser->groupid, $cm->groupingid);
        $cache->set('user', $users);
    }
} else {
    $users = chat_get_users($chatuser->chatid, $chatuser->groupid, $cm->groupingid);
}
$users = format_user_list($users, $course);
if (!empty($chat_init)) {