Permalink
Browse files

fixed deleting of old users when using chatd, other minor fixes, reve…

…rting of changes in chatmsg - found some weird problems in FF
  • Loading branch information...
1 parent 5bbbe0b commit a32c7772c6fea8f48fc7fe649905dc77741e6454 skodak committed Feb 10, 2005
@@ -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\">&nbsp;</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)) {
View
@@ -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) ) {

0 comments on commit a32c777

Please sign in to comment.