<link rel="stylesheet" type="text/css" href="<?php echo $CFG->httpswwwroot;?>/lib/yui/layout/assets/skins/sam/layout.css" />
<link rel="stylesheet" type="text/css" href="<?php echo $CFG->httpswwwroot;?>/lib/yui/button/assets/skins/sam/button.css" />
<?php
-print_js_config(array('userid'=>$USER->id, 'sid'=>$chat_sid,'timer'=>5000, 'chat_lasttime'=>0,'chat_lastrow'=>null,'header_title'=>$str_chat,'chatroom_name'=>$str_title), 'chat_cfg');
+print_js_config(array('home'=>$CFG->httpswwwroot.'/mod/chat/view.php?id='.$cm->id, 'userid'=>$USER->id, 'sid'=>$chat_sid,'timer'=>5000, 'chat_lasttime'=>0,'chat_lastrow'=>null,'header_title'=>$str_chat,'chatroom_name'=>$str_title), 'chat_cfg');
print_js_config(array('send'=>$str_send, 'sending'=>$str_sending, 'inputarea'=>$str_inputarea, 'userlist'=>$str_userlist), 'chat_lang');
?>
<script type="text/javascript" src="<?php echo $CFG->httpswwwroot;?>/lib/yui/yahoo-dom-event/yahoo-dom-event.js"></script>
function append_msg(msg) {
var list = document.getElementById('msg_list');
var el = document.createElement('li');
- console.info('New message:'+msg);
+ console.info('New message:'+msg.msg);
el.innerHTML = msg.msg;
if(msg.type && msg.type == 'beep'){
document.getElementById('notify').innerHTML = '<embed src="../beep.wav" autostart="true" hidden="true" name="beep" />';
alert(o.responseText);
return;
}
+ if(data.error) {
+ if(data.error.level == 'ERROR'){
+ clearInterval(interval);
+ window.location = chat_cfg.home;
+ }
+ }
if(!data)
return false;
chat_cfg.chat_lasttime = data['lasttime'];
require_once('../lib.php');
require_once('common.php');
+ob_start();
header('Expires: Sun, 28 Dec 1997 09:32:45 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Cache-Control: no-cache, must-revalidate');
header('Pragma: no-cache');
header('Content-Type: text/html; charset=utf-8');
+header('X-Powered-By: MOODLE-Chat-V2');
+
$time_start = microtime_float();
$response = array();
if (!$chatuser = $DB->get_record('chat_users', array('sid'=>$chat_sid))) {
- $response['error'] = get_string('notlogged', 'chat');
+ 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')) {
- $response['error'] = get_string('invalidcourseid', 'error');
+ 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!
- $response['error'] = get_string('invaliduserid', 'error');
+ chat_print_error('ERROR', get_string('invaliduserid', 'error'));
}
if (!$cm = get_coursemodule_from_instance('chat', $chatuser->chatid, $course->id)) {
- $response['error'] = get_string('invalidcoursemodule', 'error');
+ chat_print_error('ERROR', get_string('invalidcoursemodule', 'error'));
}
if($CFG->chat_use_cache){
$users = chat_get_users($chatuser->chatid, $chatuser->groupid, $cm->groupingid);
}
-if (empty($users)) {
- $response['error'] = get_string('nousers', 'error');
-}
-
$users = format_user_list($users, $course);
if(!empty($chat_init)) {
$chat_newrow = ($chat_lastrow + $num) % 2;
-ob_start();
-
$send_user_list = false;
if ($messages && ($chat_lasttime != $chat_newlasttime)) {
foreach ($messages as $n => &$message) {
echo json_encode($response);
-header('X-Powered-By: MOODLE-Chat-V2');
header('Content-Length: ' . ob_get_length() );
ob_end_flush();