fixed deleting of old users when using chatd, other minor fixes, reverting of changes in chatmsg - found some weird problems in FF
This commit is contained in:
@@ -1,4 +1,2 @@
|
||||
<html>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
|
||||
$strchat = get_string('modulename', 'chat'); // must be before current_language() in chat_login_user() to force course language!!!
|
||||
|
||||
if (!$chat_sid = chat_login_user($chat->id, 'header_js', $groupid, $course, true)) {
|
||||
if (!$chat_sid = chat_login_user($chat->id, 'header_js', $groupid, $course)) {
|
||||
error('Could not log in to chat room!!');
|
||||
}
|
||||
|
||||
|
||||
@@ -49,12 +49,6 @@
|
||||
<meta http-equiv="content-type" content="text/html; charset=<?php echo get_string('thischarset'); ?>" />
|
||||
<script type="text/javascript">
|
||||
<!--
|
||||
if (parent.msg.document.getElementById("msgStarted") == null) {
|
||||
parent.msg.document.open("text/html","replace");
|
||||
parent.msg.document.write("<html><head>");
|
||||
parent.msg.document.write("<meta http-equiv=\"content-type\" content=\"text/html; charset=<?php echo get_string('thischarset'); ?>\" />");
|
||||
parent.msg.document.write("</head><body><div style=\"display: none\" id=\"msgStarted\"> </div>");
|
||||
}
|
||||
<?php
|
||||
$beep = false;
|
||||
$refreshusers = false;
|
||||
|
||||
@@ -44,8 +44,6 @@
|
||||
$groupname = '';
|
||||
}
|
||||
|
||||
chat_delete_old_users();
|
||||
|
||||
$strchat = get_string('modulename', 'chat'); // must be before current_language() in chat_login_user() to force course language!!!
|
||||
|
||||
if (!$chat_sid = chat_login_user($chat->id, 'sockets', $groupid, $course)) {
|
||||
|
||||
+12
-3
@@ -357,7 +357,7 @@ function chat_get_latest_message($chatid, $groupid=0) {
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// login if not already logged in
|
||||
|
||||
function chat_login_user($chatid, $version, $groupid, $course, $sendentermsg=false) {
|
||||
function chat_login_user($chatid, $version, $groupid, $course) {
|
||||
global $USER;
|
||||
if ($chatuser = get_record_select('chat_users', "chatid='$chatid' AND userid='$USER->id' AND groupid='$groupid'")) {
|
||||
$chatuser->version = $version;
|
||||
@@ -387,7 +387,9 @@ function chat_login_user($chatid, $version, $groupid, $course, $sendentermsg=fal
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($sendentermsg) {
|
||||
if ($version == 'sockets') {
|
||||
// do not send 'enter' message, chatd will do it
|
||||
} else {
|
||||
$message->chatid = $chatuser->chatid;
|
||||
$message->userid = $chatuser->userid;
|
||||
$message->groupid = $groupid;
|
||||
@@ -409,7 +411,14 @@ function chat_delete_old_users() {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$timeold = time() - $CFG->chat_old_ping;
|
||||
if ($CFG->chat_method == 'sockets') {
|
||||
// delete very outdated users not deleted by chatd,
|
||||
// let normal deleting to chatd, because it needs to output the message
|
||||
$timeold = time() - ($CFG->chat_old_ping * 3);
|
||||
} else {
|
||||
$timeold = time() - $CFG->chat_old_ping;
|
||||
}
|
||||
|
||||
$query = "lastping < '$timeold'";
|
||||
|
||||
if ($oldusers = get_records_select('chat_users', $query) ) {
|
||||
|
||||
Reference in New Issue
Block a user