$chat_sid)); if ($chat_lasttime !== 0) { $url->param('chat_lasttime', $chat_lasttime); } if ($chat_lastrow !== 1) { $url->param('chat_lastrow', $chat_lastrow); } $PAGE->set_url($url); if (!$chatuser = $DB->get_record('chat_users', array('sid'=>$chat_sid))) { print_error('notlogged', 'chat'); } //Get the minimal course if (!$course = $DB->get_record('course', array('id'=>$chatuser->course))) { print_error('invalidcourseid'); } //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! print_error('invaliduser'); } $USER->description = ''; //Setup course, lang and theme $PAGE->set_course($course); // force deleting of timed out users if there is a silence in room or just entering if ((time() - $chat_lasttime) > $CFG->chat_old_ping) { // must be done before chat_get_latest_message!!! chat_delete_old_users(); } if ($message = chat_get_latest_message($chatuser->chatid, $chatuser->groupid)) { $chat_newlasttime = $message->timestamp; } else { $chat_newlasttime = 0; } if ($chat_lasttime == 0) { //display some previous messages $chat_lasttime = time() - $CFG->chat_old_ping; //TO DO - any better value?? } $timenow = time(); $params = array('groupid'=>$chatuser->groupid, 'chatid'=>$chatuser->chatid, 'lasttime'=>$chat_lasttime); $groupselect = $chatuser->groupid ? " AND (groupid=:groupid OR groupid=0) " : ""; $messages = $DB->get_records_select("chat_messages_current", "chatid = :chatid AND timestamp > :lasttime $groupselect", $params, "timestamp ASC"); if ($messages) { $num = count($messages); } else { $num = 0; } $chat_newrow = ($chat_lastrow + $num) % 2; // no & in url, does not work in header! $refreshurl = "{$CFG->wwwroot}/mod/chat/gui_header_js/jsupdate.php?chat_sid=$chat_sid&chat_lasttime=$chat_newlasttime&chat_lastrow=$chat_newrow"; $refreshurlamp = "{$CFG->wwwroot}/mod/chat/gui_header_js/jsupdate.php?chat_sid=$chat_sid&chat_lasttime=$chat_newlasttime&chat_lastrow=$chat_newrow"; 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("Refresh: $CFG->chat_refresh_room; url=$refreshurl"); /// required stylesheets $stylesheetshtml = ''; /*foreach ($CFG->stylesheets as $stylesheet) { //TODO: MDL-21120 $stylesheetshtml .= ''; }*/ // use ob to be able to send Content-Length headers // needed for Keep-Alive to work ob_start(); ?> '; } ?> Refresh link