Skip to content

Commit

Permalink
fixed deleting of old users when using chatd, other minor fixes, reve…
Browse files Browse the repository at this point in the history
…rting of changes in chatmsg - found some weird problems in FF
  • Loading branch information
skodak committed Feb 10, 2005
1 parent 5bbbe0b commit a32c777
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 14 deletions.
2 changes: 0 additions & 2 deletions mod/chat/gui_header_js/chatmsg.php
@@ -1,4 +1,2 @@
<html>
<body>
</body>
</html>
2 changes: 1 addition & 1 deletion mod/chat/gui_header_js/index.php
Expand Up @@ -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!!');
}

Expand Down
6 changes: 0 additions & 6 deletions mod/chat/gui_header_js/jsupdate.php
Expand Up @@ -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;
Expand Down
2 changes: 0 additions & 2 deletions mod/chat/gui_sockets/index.php
Expand Up @@ -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)) {
Expand Down
15 changes: 12 additions & 3 deletions mod/chat/lib.php
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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) ) {
Expand Down

0 comments on commit a32c777

Please sign in to comment.